WWW.DISSERS.RU


...
    !

Pages:     | 1 |   ...   | 15 | 16 || 18 | 19 |   ...   | 21 |

Mo y O v e r l a y Moy Overlay oeceae oepy cce oepee Mo y C r t Crt oeceae aop ceax cpec oe oa/oa a PC: oca, epeex popa. x oo cooa pao c pao (paoa c oa, ypaee ypcopo, ypaee eo). Ec oooc o c aayp ypa yo cao.

Mo y P r i n t e r B oye Printer oec epeea ecooo aa LST, oopa caec c paepo ycpoca, oo oca caap o a eaaee ycpoco, coy Write Writeln. Hapep, oy Printer popay, oo cea ceyee:

write (Lst,'The sum of',A:4,'and',B:4,'is');

c:=A+B;

writeln (Lst,c:8);

Mo y G r a p h o a e xo a TURBO.TPL, o oe axoc o e ece, e cooaee a, pacpe oopx.BGI .CHR. GRAPH.TPU oeaec ey cpao, coyec cpao oye yaa ooo y o GRAPH.TPU. (Ec coyec ec c popaa Install, ccea ye ycaoea a, o oo cooa Graph). a Graph o aop cpoecyx ex paecx opopa, oope oo oo epe cooa paece oooc PC. o oy peaye eac o ycpoca paec paep, oepa paece aaep CGA, EGA, Hercules, AT&T400, MCGA, 3270 PC, VGA 8514.

C p y y p a o y Cpyypa oy oxoa a cpyypy popa, o ee co o:

unit ;

interface uses ;

{oe oe} implementation uses ;

{e oe} {peaa poeyp y} begin {o aa} end.

aooo oy coo unit, a oop ceye oy eaop. Cey ee eoe coo interface. o coo ooaae aao paea epeca oy, ocyoo cex pyx oye popa, coyx o oy. B peoe uses yaac oy, oope oe cooa o oy.

Coo uses oe oc yx ecax:

cpay e oce coa interface; o cyae, oca ax, oee epecax x oye, oy cooa x oex;

cpay e oce coa implementation; o cyae, e oe oo oy oy cooac oo yp paea peaa.

Pa e e p e c a o "opa" ac oy, oa aaec e coo interface, cey cpay a aooo, opaea e coo implementation. epec opeee, o ec (ocy) eoopo popa ( pyx oye), coyx o oy. a popaa, coya o oy, ee ocy eea.

B epece oy oo o oca, ax, epeee, poeyp y. a popae, o oy pacooe o ope, .e pae oy cpeac oopo (type...var......type...const...var) poeyp y, ocye popa, coye o oy ocac paee epeca. Ax ecee ea oepaop, peaye x, paee peaa.

Oee forward e papeaec. Tea cex ox poeyp y axoc paee peaa oce paea epeca, oopo epece x ea aoo. uses oe oc paee implementation. Ec paee peaa ee eco uses, o o coo ceye cpay e a coo implementation.

Pa e p e a a Pae peaa apa, eocya ac aaec co coa implementation. Bce, o oeo ac epeca o paea peaa: oca, , epeee, poeyp y. poe oo, paee peaa oy co cocee ooee oe, eocye popaa, coy o oy. popa e oy opaac ccac a x. Oao eocye ee oy cooac (, a pao, o eaec) poeypa y, aoo oopx oc paee epeca. peoee uses oe oc paee implementation. B o cyae uses ceye eocpeceo a e coo implementation.

Ec poeyp oe a ee, o cxoo ae oa pea {$L aa} o ece o oa oy end. Oe poeyp y, oee paee epeca, oope e c cpoe, o oc paee peaa. aooo procedure (function) paee peaa oe ao e, a paee epeca, e e opoy opy. B pao ope a e coo (procedure function) ceye eaop (). opopaa coep co cocee oae oe (e, oca, , epeee, poeyp y). a ceye eo ao popa. Hapep, paee epeca oe:

procedure ISwap (var v1,v2: integer);

function IMax (v1,V2:integer);

Pae peaa oe :

procedure ISwap;

var Temp : integer;

begin Temp := V1;V1:= V2;V2 := Temp;

end; {poeyp ISwap} function IMax (v1,v2:integer):integer;

begin if V1 > V2 then IMax := Velse IMax := Vend; {y IMax} opopa paea peaa (eocae ce epeca), o e o aooo procedure/function.

Pa e a a Pae peaa oy ae ey coa implementation end. Ho ec pcycye coo begin epe end, oepaop ey coa, o oyc cocao oepaop, oxo a eo ao popa, caoc paeo aa oy.

ec apyc cpyyp ax (epeex), coyee oye ocye popaa, coye o oy. Moo cooa eo op ao. Hapep, caap oy Printer coye o pae op a o ecooo aa Lst. a Lst ocec oo cooa popaax oepaopax Write Writeln.

p oe popa, coye eoop oy, pae aa aec epe oee ea ao popa. Ec popae coyec ecoo oye, pae aa aoo oy aec ( ope, yaao oepaope uses popa) o oe ea ao popa.

c o o a e o y e Moy, oope coye popaa, ye oopoa xpac ceao ao oe; o e a a Include.

ae pae epeca xpac ceao oo opae, oop coye aca. oee oo, caape oy xpac ceao ae TURBO.TPL aoaec apyac a c aca.

B peyae oe oye popae pe o popa yeaec eaeo, peo a oy ceyy. Ec oy apyac oex cox ao, o oe opeoac ooeoe pe -a e c ca.

cooa oye eoxoo, o aae pcycoao peoee uses, a oop ceye cco e cex oye, paeex a.

program MyProg;

uses thisUnit,thatUnit,theotherUnit;

p o o opa ae coo paec opa paea epeca, a paea peaa cao popae a o. opo oca oye peoe uses e ee ooo ae. Ec thisUnit coye thatUnit, o oo o x o ope. oop ca opee, oop x oe ceoa ep. ae oop, ec thisUnit coye thatUnit, a popaa MyProg e ae ae-o popa opopae thatUnit, o oo "cpa" opopa popay thatUnit, oyca x oepaope uses:

unit thisUnit uses thatUnit...

program MyProg;

uses thisUnit,theotherUnit;

...

B o pepe thisUnit oe a opopay thatUnit, a MyProg opopa thisUnit theotherUnit. MyProg e oe a thatUnit, a a a opopaa e ocaa eo peoe uses.

Ec peoee uses ocycye, Turbo Pascal ocoee caap oy System.

Cc a o c a e o y Ec oy e popay, o ce oca, ax, epeee, poeyp y, oee epece oo oy, caoc ocy o popa.

oyc, ec oy:

unit MyStuff;

interface const MyValue := 915;

type MyStars=(Deneb,Antares,Betelgeuse);

var MyWord : string[20];

procedure SetMyWord(Star : MyStars);

function TheAnswer : integer;

implementation...

end.

ac oy, oopa ocaa epece, ocya oe cooaa popae. ooy, oo aca ceyy popay:

program TestStuff;

uses MyStuff;

var I : integer;

AStar : MyStars;

begin Writeln(MyValue);

AStar := Deneb;

SetMyWord(AStar);

Writeln(MyWord);

I := TheAnswer;

Writeln(I);

end.

oce e peoe uses MyStuff popay, oac oooc ccac a ce oe oca ce epeca oy MyStuff (MyWord, MyValue, .). Paccop ceyy cya:

program TestStuff;

uses MyStuff;

const MyValue := 22;

var I : integer;

AStar : MyStars;

function TheAnswer : integer;

begin TheAnswer := -1;

end;

begin Writeln(MyValue);

AStar := Deneb;

SetMyWord(AStar);

Writeln(MyWord);

I := TheAnswer;

Writeln(I);

end.

B o popae eoope eaop, oee MyStuff, epeopeec. p oe a popaa ye cooa cocee oca MyValue TheAnswer, a a o oca oe, e MyStuff.

Ec yo cooa eaop MyStuff, o o cyae p oca epe a eaopo oeaec MyStuff c oo (.). Hapep:

program TestStuff;

uses MyStuff;

const MyValue = 22;

var I : integer;

Astar : MyStars;

function TheAnswer : integer;

begin TheAnswer := -1;

end;

begin Writeln(MyStuff.MyValue);

Astar := Deneb;

SetMyWord(AStar);

Writeln(MyWord);

I:= MyStuff.TheAnswer;

Writeln(I);

end.

a popaa opaaae a e, a epa, ae ec MyValue TheAnswer epeopeee. B eceoc, epy popay oo o aca:

program TestStuff;

uses MyStuff;

var I : integer;

AStar : MyStuff.MyStars;

begin Writeln(MyStuff.MyValue);

AStar := MyStuff.Deneb;

MyStuff.SetMyWord(AStar);

Writeln(MyStuff.MyWord);

I := MyStuff.TheAnswer;

Writeln(I);

end.

ae, o eaop oca, ax, epeee opopa oy peape ee oy.

p e o e e u s e s p a e a p e a a aca 7.0 ae oooc cooa peoee uses paee peaa. o peoee oo eeeo ceoa a e coo implementation a e, a peoee uses paee epeca oec cpay e a e coo interface.

peoee uses paee peaa ooe cea eocy eoope ea oy, ocoy oy, coyee paee peaa, e ooae oo oy. Oao oee ao, o o a e ooe ocpypoa ao-ace oy.

ocoy Turbo Pascal oy eoaeo o cpoo epapxec, oo aaa ece cc oye. Cey pae oaae pep, oop eocppye ece cc oye.

B peoe Uses ao popa oo e yaa ea cex oye, coyex popao, a a popaa ee eo paey epapxecy cpyypy (pc. 18).

Uses A, B, D aa popaa Uses C, D, E Uses E Moy A Moy B Moy C Moy D Moy E Pc. 18 epapxeca cpyypa popa e c e c c o y e Ceya popaa oaae, a a oy oy cooa py pya. aa popaa Circular ae oy Display. Moy Display coep oy popay paee epeca, WriteXY, oopa ee p apaepa: (X, Y) oopa o ooe a pa cooee. Ec aee oopa (X, Y) axoc peeax oc a pae, o opopaa WriteXY ycaaae ypcop oy c oopaa (X, Y) o cooee. B poo cyae aec opopaa a oo.

a, WriteXY ce oopa Write. a opopaa a oox cooe ae cooee coy o e opopay WriteXY. a, popaa WriteXY ae opopay ShowError, oopa co oepe ae WriteXY a cooe a pa, .e. pacea oopa.

Paccop popay Circular. Oa c pa p paa opaaec popae WriteXY:

program Circular;

{o eca popao WriteXY} uses Crt,Display;

begin ClrScr;

writeXY(1,1,epx e yo paa);

writeXY(100,100,e paa);

end.

oopa (X, Y) p opo oe WriteXY ycaoe eco a (100, 100) p pae 80 25.

ocop, a paoae popaa WriteXY. He pee cxo o oy Display, oop coep poeypy WriteXY. Ec oopa (X, Y) eceo axoc peeax paa, oa o cooee, poo cyae oc cooee o oe.

unit Display;

{coep opopay a cooe} interface procedure WriteXY(X,Y : integer;

Message : string);

implementation uses Crt, Error;

Procedure WriteXY;

begin if (X in[1..80]) and (Y in[1..25]) then begin GotoXY(X,Y);

Write(Message);

end else ShowError(eep oopa writeXY);

end;

end.

poeypa ShowError, aea WriteXY, oea ceye e ece oy Error. popaa ShowError cea o co cooe a 25 cpoe paa.

unit Error;

{coep opopay a oo} interface procedure ShowError (ErrMsg : string);

implementation uses Display;

procedure ShowError (ErrMess : string);

begin WriteXY (1, 25, ErrMsg); {Cooee o oe} end;

end.

Pages:     | 1 |   ...   | 15 | 16 || 18 | 19 |   ...   | 21 |



2011 www.dissers.ru -

, .
, , , , 1-2 .