დაპროგრამების საფუძვლები - გ. ჯანელიძე

Download as pdf or txt
Download as pdf or txt
You are on page 1of 196

saqarTvelos teqnikuri universiteti

g. janeliZe

daprogramebis safuZvlebi

damtkicebulia stu-s
saswavlo-meToduri
sabWos mier

Tbilisi
2002
uak 681.3.06

wignSi ganxilulia daprogrameba Turbo Pascal-is,


Object Pascal-is da farTod gavrcelebuli obieqtur-
orientirebuli daprogramebis Delphi-is garemoSi. wigni
gaTvaliswinebulia damwyebTaTvis, maTTvis vinc ar flobs
programirebis sxva enebs.
wigni gankuTvnilia informatikis sferos
studentebisaTvis.

recenzentebi: prof. g. surgulaZe


doc. m. kiknaZe

 saqarTvelos teqnikuri universiteti, 2002


ISBN 99928-943-2-6

2
programirebis ena
Turbo Pascal.

Sesavali

programirebis sistemas saxeli “paskali~ daerqva


cnobili frangi maTematikosisa da filosofosis blez
paskalis pativsacemad. igi programebis Seqmnis metad
efeqturi saSualebaa. SemdgomSi paskals ewoda ena “turbo
paskali~. mas gaaCnia sakmaod moxerxebuli servisuli
saSualebani.
Pascal-is failebi ganTavsebulia calke katalogSi,
romelsac hqvia TP (an PAS, TURBOPAS, PASCAL da a.S.).
Turbo Pascal-is garemos gamosaZaxeblad aucilebelia
movZebnoT faili TURBO.EXE saxelwodebiT, es faili
Seicavs Turbo Pascal-Si programirebisaTvis gamzadebul
dialogur sistemas. dialogur sistemaSi normaluri
muSaobisaTvis saWiroa ZiriTadi biblioTeka, romelic
ganTavsebulia TURBO.TPL failSi da sacnobaro samsaxuri,
(TURBO.HLP faili). es CamoTvlili failebi ganTavsebulia
C diskze, TP katalogSi.
sacnobaro samsaxuri turbo paskalis garemos ganuyreli
nawilia. turbo paskalTan muSaobisas dabrkolebis
SemTxvevaSi sakmarisia davaWiroT F1 Rilaks da ekranze
saWiro cnoba gamonaTdeba. es cnoba damokidebulia mimdinare
garemos mdgomareobaze (aseT sacnobaro samsaxurs
konteqsturad damokidebuls uwodeben). magaliTad, Tu
F1 Rilaks davaWerT im momentSi, rodesac garemom aRmoaCina
Secdoma programaSi, cnobarSi iqneba damatebiTi cnoba am
Secdomis warmomSob mizezze da mis aRmosafxvrelad.
sacnobaro samsaxurze mimarTva SesaZlebelia turbo
paskalis mTavari menius meSveobiT.
3
funqcionaluri Rilakebi

funqcionaluri Rilakebi gamoiyeneba Turbo Pascal-is


garemos samarTavad.
F1 – sacnobaro sistemis gamoZaxeba;
F2 – programis teqstis damaxsovreba diskze;
F3 – diskze Cawerili failis gaxsna;
F4 – gamoiyeneba programis gawyobis reJimSi, programis
Sesruleba gaCerdeba im striqonis win, sadac kursori
dgas.
F5 – aqtiuri fanjris mTel ekranze gaSla.
F6 – momdevno fanjris gaaqtiureba;
F7 – gamoiyeneba programis gawyobis reJimSi: Sesruldes
programis momdevno striqoni, Tu striqonSi aris
proceduraze an funqciaze mimarTva, Sevides am proceduraSi
(funqciaSi) da gaCerdes misi pirveli operatoris
Sesrulebis win;
F8 – gamoiyeneba programis gawyobis reJimSi: Sesruldes
programis momdevno striqoni; Tu striqonSi aris
proceduraze an funqciaze mimarTva, Sesruldes igi.
F9 – programis kompilacia;
F10 – dialoguri sistemis mTavar meniuSi Sesvla;
Ctrl - F9 - programis Sesrulebaze gaSveba ;
Alt – F5 - Sedegis gamotanis fanjaraze gadasvla ;
Alt – X - gasvla Turbo Pascal – is garemodan.

pirveli programa.
turbo paskalis enis gasacnobad SevadginoT martivi
programa, romelic raime Setyobinebis gamotanas
ganaxorcielebs paskalis enaze. davuSvaT es aris fraza
`me vaprogrameb turbo paskalze~.

4
Program My_First_Program;
const
Text=’me vaprogrameb turbo paskalze’;
begin
Writeln(Text);
End.

upirveles yovlisa gavaanalizoT teqstis formis


warmodgena. programaSi eqvsi striqonia. programis
striqonebi Cveulebriv, teqstis zogierT azrobriv
fragments gamoyofs da ar ukavSirdeba programaSi
konkretul moqmedebebs: programis teqstis striqonze
ganTavseba Cveni survilisamebr xdeba da ara enis sintaqsis
moTxovniT.
igive programa SeiZleba ase eweros:

Program My_First_Program, Const Text=’me vaprogrameb


turbo paskalze’; Begin Writeln(Text); End.

mniSvneloba ara aqvs asoebis zomas _ My Tu my.


pirveli striqoni : Program My_First_Program iwyeba
Program sityviT da programis saxels Seicavs. sityva
Program darezervebulia turbo paskalSi, e.i. ar SeiZleba
gamoyenebul iqnes sxva mniSvnelobiT, garda programis
saxelis gamocxadebisa. turbo paskalSi SeiZleba
gamotovebul iqnes Program operatori, es programaze ar
imoqmedebs.
`Cemi pirveli programa~ dawerilia probelebis (adgilis
gamotovebis) gareSe. probeli warmoadgens gamyofs da
misi TviTneburad gamoyeneba ar SeiZleba. probelebis nacvlad
identifikatorebSi xazgasmis `_~ niSani gamoiyeneba.
pirveli striqoni mTavrdeba gansakuTrebuli gamyofiT

5
wertil-mZimiT (;). es gamyofi turbo paskal enaSi
operatoris an aRweris dasasruls aRniSnavs.

meore striqoni
Const
moicavs erTaderT darezervebul sityvas Const, romelic
aRniSnavs, rom SemdgomSi erTi an ramodenime konstanta
iqneba aRwerili (Constants-konstantebi), enaSi konstantebad
iTvleba programis iseTi obieqtebi romelTac Tavisi
mniSvnelobebis Secvla ar SeuZliaT. konstantas SeiZleba
hqondes sakuTari saxeli. konstantis aRwera turbo
paskalSi niSnavs _ mieTiTos misi saxeli da mniSvneloba.
aseT miTiTebas mesame striqoni Seicavs.

Text = ’me vaprogrameb turbo paskalze’;

sadac konstanta _ Text-s miniWebuli aqvs ’me vaprogrameb


turbo paskalze’ simboloebis striqoni.

turbo paskalSi SeiZleba gamoviyenoT sxvadasxva ti pis


mudmiva: mTeli da namdvili ricxvebis, simboloebis,
simboloebis striqoni, masivebi da a.S. imis niSnad, rom
Text warmoadgens simboloebis striqonis ti pis mudmivas,
igi Casmulia or apostrofSi. TviT apostrofi striqons
ar miekuTvneba, is mxolod kompilators miuTiTebs, rom
masSi moTavsebuli simboloebi unda ganixilos rogorc
erTi mTliani_teqsturi konstanta. Tu dagvWirdeba
apostrofis CarTva teqstur konstantaSi, sakmarisia igi
daiweros orjer zedized. mag.
Text=’Turbo’’Pascal’;
programis pirveli sami striqoni raime konkretuli
moqmedebebiT ar aris dakavSirebuli programis muSaobasTan.
isini kompilators zogierT cnobas miawvdian TviT

6
programasa da masSi gamoyenebul obieqtebze. programis am
nawils aRweris ganyofileba ewodeba.
meoTxe striqonSi darezervebuli sityva begin
kompilators acnobebs, programis sxva nawilis _
operatorebis ganyofilebis dasawyiss, Cvens magaliTSi es
ganyofileba Seicavs operators:
Writeln(Text); romelsac kompiuteris ekranze Setyobineba
gamoaqvs. mTels programas daasrulebs darezervebuli
sityva End wertiliT. wertili kompilators programis
teqstis dasasruls Seatyobinebs.
End-is Semdeg ganTavsebul teqsts kompilatori ar
kiTxulobs. sanam Sesrulebaze gavuSvebdeT Cvens programas,
ganvixiloT erTaderTi Sesrulebadi operatori:
Writeln(Text); romelic monacemTa gamotanis proceduras
mimarTavs.
procedura operatorebis mimdevrobaa, romelTac SeiZleba
saxeliT mivmarToT.
Writeln procedura miekuTvneba standartul proceduras,
mas winaswar aRwera ar sWirdeba, is nebismieri
programisaTvis xelmisawvdomia, sadac misadmi mimarTvaa.
Writeln procedura miekuTvneba gamotanis operators. misi
sruli saxelia WriteLine _ dawereT striqoni. parametrebi
proceduras gadaecema siis saxiT, romelic Casmulia mrgval
frCxilebSi. Cvens magaliTSi proceduras gadaecema
erTaderTi parametri, mudmiva _ Text.
oTxi gamoyenebuli sityva (Program, const, Begin, End)
darezervebulia. sityva Writeln ar miekuTvneba darezervebuls,
magram misi gamoyeneba sxva daniSnulebiT dauSvebelia.
sityvebi: My_First_Program da Text aris identifikatori.
programists identifikatorad SeuZlia gamoiyenos
simboloebis nebismieri mimdevroba, romlebic Semdeg
moTxovnebs akmayofileben:

7
• identifikatori SeiZleba Sedgebodes
laTinuri anbanis asoebisagan, cifrebisagan,
xazgasmis niSnisagan. danarCeni simboloebi identi-
fikatorSi dauSvebelia.
• identifikatori ar SeiZleba cifriT
iwyebodes.
• identifikatori ar unda emTxveodes arc
erT darezervebul sityvas.
• identifikatoris sigrZe SeiZleba nebismieri
iyos, xolo mniSvnelovnad iTvleba pirveli 63
simbolo.
identifikatorSi yuradReba ar eqceva asoebis simaRles:
Text, text, TEXT.
programis Sesrulebaze gaSvebisas vaWerT [Ctrl-F9] _s,
Tu programaSi Secdoma ar aris Sedegi ekranze daiwereba.
ekranze Sedegis naxvisaTvis vaWerT [Alt-F5] _s. nebismieri
Rilakis daWerisas isev vbrundebiT ZiriTad ekranze.
ganxiluli programis struqturas Semdegi saxe aqvs:
Program My_First_Program;

{aRweris ganyofileba}

Begin

{operatorebis ganyofileba}

End.
sityvebi Program, Begin da End gamoyofs programis or
nawils_aRweris ganyofilebas da operatorebis
ganyofilebas, aseTi struqtura aucilebelia nebismieri
programisaTvis. es enis mkacri moTxovnaa. Sesrulebad
operatorSi gamoyenebuli nebismieri arastandartuli
identifikatori, winaswar unda iyos aRwerili aRweris

8
ganyofilebaSi.

monacemTa ti pebi

ti pis cneba erT-erTi fundamenturi cnebaa turbo


paskalSi.
ganvixiloT monacemTa Semdegi ti pebi:
• INTEGER - mTeli ti pis monacemebi, Siga
warmodgenaSi 2 baits ikavebs. SesaZlo
mniSvnelobebis diapazonia -32768 dan +32768
–mde. monacemebi zustad unda iyos warmodgenili.
• REAL - namdvili ti pis monacemebi, Siga
warmodgenaSi ikavebs 6 baits. SesaZlo
mniSvnelobebis diapazonia 2,9E-39 dan 1,7E+38 –
mde monacemTa warmodgenis sizuste –11 . .……12
niSna ciframdea.
• CHAR – simbolo ikavebs erT baits.
• BOOLEAN – logikuri ti pi, ikavebs erT
baits da aqvs ori mniSvneloba: FALSE (mcdari)
da TRUE (WeSmariti).
• STRING –simboloebis striqoni ikavebs
MAX+1 baits, sadac MAX striqonSi simboloebis
ricxvia.

mTeli ti pis monacemebi

ti pi mniSvnelobaTa diapazoni

Byte 0 255
Word 0 65535
Shortint -128 127

9
Integer -32768 32768
Cardinal 0 2147483647
Longint -2147483648
147483647

ganvixiloT monacemTa ti pebis aRweris magaliTi:

Const
C1 = 17;
C2 = 3.14;
C3 = ’a’;
C4 = ’123.14’;
C5 = False;

kompilatori am programis fragmentis gaanalizebisas


pirvel mudmivas INTEGER-is ti ps miakuTvnebs, meores ki
REAL-is ti ps, mesames CHAR, meoTxes striqonul ti ps -
STRING; mexuTes – BOOLEAN - logikur ti ps. ra niSnis
mixedviT ansxvaveben?: C2-Si gvaqvs aTobiTi wertilis
aRmniSvneli mniSvneloba, amitomac is REAL ti pisaa, C2 da
C4 konstantebi sxvadasxva ti pebs miekuTvneba:
C2-REAL (konstantaSi aris aTobiTi wertili), xolo
C4-STRING (konstanta apostrofSia Casmuli), C3-CNAR
(radgan erTaderTi simboloa apostrofSi, gansxvavebiT
STRING – sadac ramodenime simboloa).
cvladebis ganyofilebis aRwerisas dasawyisSi unda idges
darezervebuli sityva VAR (VARiables-cvladebi). mag:

Var
sigma : real;
a,b,c,d : char;
flag : boolean;
(ramdenime erTi ti pis cvladi SeiZleba gavaerTianoT

10
da gamovyoT mZimeebiT).
cvladebis aRwerisas identifikatoris Semdeg iwereba
` : ~ da ti pis saxeli.
ganvixiloT kidev erTi martivi programa. misi
daniSnulebaa Seitanos klaviaturidan ori mTeli ricxvi,
i povos pirveli ricxvis meoreze gayofis Sedegi da
gamoitanos ekranze:

Var
n1, n2 : Integer; {n1,n2-Sesatani mTelebia}
x : Real; {x-Sedegi}
Begin {dasawyisi}
Write(‘n1=’); {vatyobinebT n1-is Setanaze}
readln(n1); {Segvaqvs n1}
Write(‘n2=’);
Readln(n2);
X:=n1/n2; {vpoulobT Sedegs};
Writeln(‘n1/n2=’,X); {gamogvaqvs Sedegi};
End. {dasasruli}
komentarebi turbo paskalSi nebismieri simboloebis
Tanmimdevrobaa, romlebic figurul frCxilebSi Caismis.
komentaris Casma SeiZleba programis nebismier adgilas,
sadac azrobrivad probeli (carieli adgili) SeiZleba
iyos. komentarebis Casasmelad gamoiyeneba figuruli
frCxilebi { da } agreTve wyvili simbolo (* da *)
{ es komentaria}
(*esec komentaria*)
operatorebis wyvili:
Write(..); Readln(..);

11
Semdegnairad muSaobs: dasawyiSi operator Write-s
gamohyavs ekranze striqoni da kursors tovebs axlaxan
gamoyvanili teqstis striqonis bolos. SevniSnoT, rom
operatori
Writeln(Text);
teqstis gamotanis Semdeg asrulebs striqonze gadasvlas
da kursors ayenebs Semdegi striqonis dasawyisSi. Writeln
da Write procedurebi axal striqonze gadasvliT gansxvavdeba
erTmaneTisagan.
< := >, simboloebis wyvili akavSirebs operatoris
marcxena da marjvena nawilebs da niSnavs `mivaniWoT
mniSvneloba~. < := > ganixileba rogorc erTi specialuri
simbolo da aucileblad erTad iwereba.

@monacemTa ti pebis gardaqmna da maTze


moqmedebebi.

monacemTa ti pebi saSualebas iZleva, rom ara mxolod


Sida warmodgenaSi ganisazRvros maTi sigrZe, aramed
kontrols gauwios im moqmedebas, romelic unda Sesruldes
maT mimarT. kontroli mimdinareobs kompilaciis etapze.
turbo paskalSi TiTqmis dauSvebelia monacemTa ti pebis
avtomaturi gardasaxva. mag. Tu X da Y aRwerilia
Semdegnairad:
Var
X : integer;
Y : real;
maSin operatori
y := x+2;
iqneba sintaqsurad swori, xolo Canaweri

12
x := 2.0;
iqneba araswori, vinaidan real ti pis integer ti pad
gardaqmna paskalSi dauSvebelia. Tumca turbo paskalSi
aris monacemTa ti pebis gardaqmnis saSualebebi. isini unda
iqnan cxadad gamoyenebuli. monacemTa gardaqmnisaTvis enaSi
arsebobs Casmuli funqciebi, romlebic parametris saxiT
miiRebs erTi ti pis mniSvnelobas, xolo abrunebs sxva
ti pis mniSvnelobas. kerZod, real ti pis integer ti pad
gardaqmnisaTvis aris ori Casmuli funqcia:
ROUND amrgvalebs REAL-s uaxloes mTel ricxvamde.
TRUNC CamoaWris REAL - s wilad nawils. mag. arasworia
Canaweri:
X := Y/X;
magram sworia:
X := ROUND(Y/X);
CHAR (simbolo) ti pis mTel ti pad gardaqmnisaTvis
aris funqcia ORD, xolo ukugardaqmnisaTvis e.i. INTEGER-
is CHAR ti pad gardaqmnas axorcielebs funqcia CHR.
turbo paskalSi gamoiyeneba oTxive ariTmetikuli
operacia:
+ -Sekreba;
_ -gamokleba;
* -gamravleba;
/ -gayofa;
DIV – mTelricxva gayofa.
mag. Canaweri

VAR
N: integer;
begin
N:=1/2;

13
dauSvebelia, vinaidan N aRwerilia, rogorc mTeli
ti pi da is ver miiRebs REAL ti pis mniSvnelobas.
xolo Canaweri:

VAR
X : Real;
begin
X := 1 div 2;
marTebulia.

DIV mTelricxva gayofis operaciis gamoyeneba


moxerxebulia maSin, rodesac programisti Segnebulad
ugulvebelyofs wilad nawils.

Integer - is ti pis monacemebisaTvis turbo paskalSi


gamoiyeneba MOD funqcia, romelic gvaZlevs ricxvis ricxvze
gayofis Sedegad miRebul naSTs.
5 mod 2 =1
31 mod 16 = 15
16 mod 3 = 1
Integer, Real, Char ti pis monacemebisaTvis gansazRvrulia
Semdegi damokidebulebis (Sedarebis) operaciebi.
= tolia;
< > _ ar aris toli;
< _ naklebia;
> _ metia;
<= _ naklebi an toli;
>= _ meti an toli;
damokidebulebis operaciis Sedegad miiReba BOOLEAN
ti pis monacemi, romelsac aqvs ori mniSvneloba: TRUE -
WeSmariti da FALSE - mcdari. aRvniSnoT, rom ORD funqcia

14
gardaqmnis ara marto simbolos mTel ti pad, aramed
logikur sididesac. amitomac

ORD(FALSE)=0
ORD(TRUE)=1

turbo paskalSi gamoiyeneba Semdegi logikuri operaciebi:


not _logikuri uaryofa (ara);
and _logikuri gamravleba (da);
xor _gamomricxveli Sekreba (an);
or _logikuri Sekreba (an);
rTul logikur gamosaxulebaSi saWiroa maTi Casma mrgval
frcxilebSi. mag. Canaweri:
a>b and c<d
sintaqsurad SecdomiT aris Cawerili, xolo sworia
(a>b) and (c<d).

enis operatorebi
Sedgenili da carieli operatorebi.

erT-erTi yvelaze xSirad gamoyenebuli operatori _


miniWebis operatori ukve ganvixileT.
Sedgenili operatori _ programis nebismieri
operatorebis Tanmimdevrobaa, romelic Casmulia
begin…end operatorul frCxilebSi.
Sedgenili operatorebi _ turbo paskalis mniSvnelovani
instrumentia, romelic saSualebas iZleva daiweros
programa struqturuli programirebis Tanamedrove

15
teqnologiiT (GOTO) gadasvlis operatoris gareSe).

begin
…….
begin
…….
begin
…….
…….
end;
……
end;
…….
end;

faqtiurad, mTeli operatorebis ganyofileba, romelic


begin…end sityvebiT Semoifargleba, warmoadgens erT
Sedgenil operators. darezervebuli sityva end
operatoruli frCxilebis daxurvis maCvenebelia. is
erTdroulad miuTiTebs wina operatoris dasasruls, amitom
` ; ~ simbolos dasma end-is win ar aris aucilebeli. end-
is win ` ; ~ - is arseboba wina magaliTSi aRniSnavda, rom
bolo operatorsa da operatorul frCxil end _s Soris
Tavsdeba carieli operatori. carieli operatori ar
Seicavs araviTar moqmedebebs, ubralod programaSi emateba
zedmeti wertil-mZime. ZiriTadad carieli operatori
gamoiyeneba Sedgenili operatoris bolos marTvis
gadasacemad.

16
mTeli ti pebis sademonstracio programa:

Program IntegerDemo;

var
Pay : Integer;
OverTimePay : Integer;
TotalPay : Integer;

begin
Pay : = 500;
OverTimePay : =100;
TotalPay := Pay + OverTimePay;
Writeln (‘sruli daricxva=’, TotalPay);
Readln; {Enter - is daWeramde, rom fanjara Ria darCes}
end.

namdvili ti pebis sademonstracio programa:

Program RealDemo;

const
TaxRate = 0.0075;

var
Pay : Real;
OverTimePay : Real;
GrossPay : Real;
NetPay : Real;

begin
Pay : = 500.55;

17
OverTimePay : =100.10;
GrossPay := Pay + OverTimePay;
NetPay := GrossPay - (GrossPay * TaxRate);
Writeln (‘sruli daricxuli Tanxa’, Grosspay : 7 : 2);
Writeln (‘ xelxe gasacemi Tanxa=’, NetPay : 7 : 2);
Readln; {Enter - is daWeramde, rom fanjara Ria darCes}
end.

logikuri ti pis sademonstracio magaliTi:

Program BooleanDemo;

var
OKtoGo : Boolean;
MyFlag : Boolean;

begin
OKtoGo := False;
MyFlag := not OKtoGo;
Writeln (‘OKtoGo-s droSaze arCeulia’, OKtoGo);
Writeln (‘MyFlag-is droSaze arCeulia’, MyFlag);
Writeln(‘ori droSis logikuri `an~ tolia’, OKtoGo or
MyFlag);
Writeln(‘ori droSis logikuri `da~ tolia’, OKtoGo
and MyFlag);
Readln;
end.

18
simboluri ti pis sademonstracio magaliTi:

Program CharDemo;

var
Answer : Char;
Question : Char;
begin
Question :=’A’;
Answer :=’B’;
Writeln (‘SekiTxva udris’, Questin);
Writeln (‘ pasuxi udris’, Answer);

Answer := Question;
Question := ‘B’;

Writeln (‘SekiTxva exla udris’, Questin);


Writeln (‘ pasuxi exla udris’, Answer);
Readln;
end.

aq ramodenime saintereso momentia. ori simbolos tipis


cvladis - Answer da Question, gamocxadebis Semdeg TiToeul
maTgans eniWeba mniSvneloba, Question -s simbolo ‘A’, xolo
Answer - s simbolo ‘B’. mas Semdeg roca xdeba maTi
mniSvnelobebis ekranze gamotana, programa Ansver cvlads
aniWebs Question cvladis mniSvnelobas da piriqiT. miniWeba
dasaSvebia, radgan orive cvladebi erTnairi ti pisaa.

19
striqonis ti pis sademonstracio programa:

Program StringDemo;

var
LastName : String;
FirstName : String[4];
NewFirstName : String[30];

begin

LastName := ‘Mepho’;
FirstName := ‘Tata;
NewFirstName := ‘Kate’;
Writeln (‘saxeli-’, FirstName);
Writel (‘gvari-’, LastName);

FirstName := NewFirstName;

Writeln (‘Secvlili saxelia-’, FirstName);


Readln;
end.

Cvens mier aRwerili pirveli striqoni SeiZleba Seicavdes


maqsimum 255 simbolos, radgan aq ar aris miTiTebuli
simboloebis dasaSvebi raodenoba, meore da mesame
striqonebi Seicaven maqsimum oTx simbolos, rac
miTiTebulia kvadratul frCxilebSi. miniWebis operatori
dasaSvebia striqonuli ti pebisaTvis.

20
pirobis operatori

pirobis operatori saSualebas gvaZlevs SevamowmoT


zogierTi piroba da Semowmebis Sedegis mixedviT
SevasruloT esa Tu is moqmedeba. amgvarad, pirobis
operatori _ gamoTvliTi procesis ganStoebis saSualebaa.
pirobis operatoris struqturas aqvs Semdegi saxe:

IF < piroba> THEN <operatori1> ELSE < operatori2>

sadac IF, THEN, ELSE _ darezervebuli sityvebia (Tu,


maSin, winaaRmdeg SemTxvevaSi).
<piroba> _ logikuri ti pis nebismieri gamosaxulebaa.
<operatori1>, <operatori2> _ turbo paskalis
nebismieri operatorebia.
pirobis operatori muSaobs Semdegi algoriTmis mixedviT:
pirvelad gamoiTvleba logikuri gamosaxuleba <piroba>.
Tu Sedegi aris TRUE (WeSmariti), maSin sruldeba
<operatori1>, xolo <operatori2> gamoitoveba. Tu Sedegi
aris FALSE (mcdari), piriqiT <operatori1> gamoitoveba,
xolo <operatori2> Sesruldeba. mag.:
var
x, y, max : integer;
begin
…………..
if x > max then
x := max
else y := x;
…………..
am fragmentis Sesrulebisas y cvladi Rebulobs x
cvladis mniSvnelobas, mxolod Tu es mniSvneloba(x) max_s
ar aRemateba, winaaRmdeg SemTxvevaSi x gaxdeba max-is toli.
pirobis operatoris ELSE <operatori2> nawili
21
SeiZleba gamotovebul iqnas. am SemTxvevaSi igi ar
Sesruldeba da marTva gadaecema rigiT momdevno opera-
tors.
var
x, y, max : integer;
begin
……………
if x > max then
max := x;
y := x;
…………….
am SemTxvevaSi y cvlads yovelTvis x cvladis mniSvneloba
eqneba, xolo max_Si x_is maqsimaluri mniSvneloba
daixsomeba.
Tu CarTuli pirobis operatorebidan yvelas ar aqvs
else, ismis kiTxva, romel then operators ekuTvnis romeli
else. es ganisazRvreba Semdegnairad: nebismier else_s Seesabameba
masTan zemodan uaxloesi - then.
ganvixiloT magaliTi:

var
a,b,c,d : integer;
begin
a:=1; b:=2; c:=3; d:=4;
IF a>b then
IF c<d then
IF c<0 then
c:=0
else
a:=b;

IF a>b then

22
IF c then
IF c then
c:=0
else
else
else
a:=b;

ganvixiloT programa, romelic ipovis or namdvil ricxvs


Soris udidess:

var
X, Y, Max : real;
begin
Writeln(‘X=’); Readln(X);
Writeln(‘Y=’); Readln(Y);
If X>Y Then Max := X Else Max := Y;
Writeln(‘Max=’, Max);
Readln;
End.

ganxilul magaliTSi X da Y namdvili tipis cvladebia,


romelTa Soris udidesi unda ganisazRvros. am cvladebis
Setana xdeba klaviaturidan, ris Semdegac daismeba piroba,
Tu X meti aRmoCndeba Y -ze, maSin Max -s mieniWeba X -is
mniSvneloba, xolo winaaRmdeg SemTxvevaSi, Tu Y Ymeti
aRmoCndeba X -ze, Max -s mieniWeba Y-is mniSvneloba. End-
is win gamoyenebuli Readln niSnavs, rom ekranze, Sedegi
naCvenebi iqneba manam, sanam ar davaWerT Enter Rilaks.

23
ganvixiloT programis fragmenti, sadac sruldeba Semdegi
piroba, Tu ori namdvili ricxvidan pirveli metia meoreze,
maSin, pirveli davadidoT orjer, xolo Tu meore metia
pirvelze, maSin meore gavadidoT orjer. davuSvaT es
cvladebia a da b.
................................
If a > b Then a := 2 * a
Else b := 2 * b;
-----------------

Else pirobis operatoris araaucilebel nawils


warmoadgens, rac niSnavs, rom Tu misi programaSi gamoyeneba
ar aris saWiro, igi SeiZleba gamovtovoT da Cveulebrivad
gadavideT rigiT momdevno operatorze.
ganvixiloT magaliTi sadac Else ar aris gamoyenebuli:
klaviaturidan Setanili nebismieri X mTeli ricxvi
Tu dadebiTia maSin igi gavadidoT samjer, Tu nulis tolia
gavadidoT 3-iT, xolo Tu uaryofiTia, maSin gavadidoT
(-3)-jer.

Var
X : Integer;
Begin
Writeln(‘X=’); Readln(X);
If X > 0 Then X : = 3 * X;
If X = 0 Then X : = 3 + X;
If X < 0 Then X : = -3 * X;
Writeln(‘X=’, X);
Readln;
End.

24
If.....Then.....Else operatoris gamoyenebis martivi programa:

Program IfDemo;

var
UserInput : Integer;

begin
Write (‘ramdeni wlisa xarT?’);
Readln (UserInput);
If (UserInput < 1) or (UserInput > 130) Then
Writeln(‘pasuxi arasworia’)
else
Writeln (‘Tqven ’, UserInput, ‘ wlisa xarT.’);
Writeln(‘programis dasrulebisaTvis daaWireT Enter-s’);
Readln;
end.

mocemul programaSi gamoiyeneba erTaderTi cvladi:


UserInput, romlis Setanis Semdeg mowmdeba piroba, Tu es
cvladi naklebia erTze da metia 130, ekranze gamova
Setyobineba, rom Tqven araswori informacia SeitaneT, xolo
sxva danarCen SemTxvevaSi, gamova Setyobineba, rom Tqven
UserInput wlisa xarT.

25
ciklis (ganmeorebis) operatorebi
FOR – TO cikli

turbo paskalSi aris sami gansxvavebuli operatori,


romlis meSveobiT SeiZleba daprogramdes ganmeorebiTi
procesi.
FOR - TO ciklis operators aqvs aseTi struqtura:
FOR < ciklis parametri> := <sawyisi mniSvneloba>
TO < saboloo mniSvneloba> DO < operatorebi>.
aq FOR, TO, DO _ darezervebuli sityvebia (saTvis,
mde, Sesruleba).
< ciklis parametri> integer ti pis cvladia.
<sawyisi mniSvneloba> da <saboloo mniSvneloba> igive
ti pis gamosaxulebaa.
<operatorebi> turbo paskalis nebismieri
operatorebia. FOR operatoris Sesrulebis dasawyisSi
<ciklis parametrs> eniWeba <sawyisi mniSvneloba>, ris
Semdegac igi ciklurad meordeba, sanam WeSmaritia piroba:
<ciklis parametri> <= <saboloo mniSvneloba>,
winaaRmdeg SemTxvevaSi cikli amTavrebs muSaobas. muSaobis
periodSi ciklis parametri izrdeba erTi erTeuliT, e.i.
ciklis yoveli ganmeorebisas ciklis parametri izrdeba
1 erTeuliT.
FOR operatoris ilustraciisaTvis ganvixiloT programa,
romelic klaviaturidan N nebismier mTel ricxvs Seitans
da 1-dan N-mde gamoiTvlis yvela mTeli ricxvebis jams.
Program summ_of_integer;
(programas Seaqvs mTeli dadebiTi ricxvi N da
gamoiTvlis yvela mTeli ricxvebis jams 1-dan N-mde).

26
var
I, N, S : integer; {cvladebi}
begin
Write(‘N=’); Readln(N); {N Setana}
S := 0; {jamis sawyisi mniSvneloba}
FOR I:=1 TO N do {jamis daTvlis cikli}
S := S + I;
Writeln(‘S=’, S); {Sedegis gamotana}
end.
sanam I icvleba 1-dan N-mde, sruldeba <operatorebi>.
rogorc ki I-s mniSvneloba gadaaWarbebs N-s, cikli wyvets
muSaobas da marTva gadaecema rigiT momdevno operators.
ciklis parametris gazrda +1 erTeuliT mkacrad
gansazRvrulia. arsebobs operatoris sxva forma:
FOR <ciklis parametri> := <sawyisi mniSvneloba>
DOWNTO <saboloo mniSvneloba> DO <operatorebi>

darezervebuli TO sityvis DOWNTO sityviT Secvla


niSnavs, ciklis parametris cvlas (-1) erTeuliT. wina
magaliTis modificireba SeiZleba ise, rom gamosadegi iyos
rogorc dadebiTi, aseve uaryofiTi jamis gamoTvlisaTvis :

————————
S := 0;
If N >= 0 then
for I := 1 to N do
S := S + I
else

27
for I := -1 downto N do
S := S+I;
—————————

ganvixiloT magaliTi, romelic amobeWdavs N-dan 1-mde


yvela naturalur ricxvs.

Var
I, N : integer; {cvladebi}
begin
Write(‘N=’); Readln(N); {Segvaqvs N}
FOR I:= N DOWNTO 1 DO
Write(I : 4);
Readln;
end.

ganxilul programaSi gamoyenebulia ……FOR -…DOWNTO
cikli, radgan ciklis parametri (-1)-iT unda Seicvalos.
gamotanis operatori …Write(I : 4), niSnavs, rom I-is
yoveli momdevno mniSvnelobis gamotana moxdeba imave
striqonze, amave dros yoveli momdevno I ekranze daibeWdeba
wina mniSvnelobidan meoTxe poziciaze.

28
ciklis operatori wina pirobiT.
WHILE – DO cikli.

WHILE – DO ciklis zogadi struqturaa:


WHILE <piroba> DO < operatorebi>
aq WHILE, DO _ darezervebuli sityvebia (sanam,
gavakeToT)
<piroba> _ logikuri ti pis gamosaxulebaa,
<operatorebi> _ turbo paskalis nebismieri
operatorebia.
Tu gamosaxuleba <piroba> _s aqvs FALSE mniSvneloba,
operatori WHILE wyvets Tavis muSaobas.

ganvixiloT magaliTi, romelic 1-dan n - mde mxolod


kent ricxvebs amobeWdavs.

var
i, n : integer;
begin
Writeln(‘n=’); Readln(n);
i := 1;
While i <= n do begin
Writeln (i);
i := i + 2; end;
Readln;
end.

29
WHILE – DO ciklSi ciklis parametri, Cvens SemTx-
vevaSi i, icvleba nebismieri intervaliT, amitom misi
cvlileba aucileblad unda iyos miTiTebuli.

ganvixiloT programa, romelic gamoiTvlis 1-dan N-


mde luwi ricxvebis jams.

var
i, n, s : integer;
begin
Writeln(‘n=’); Readln(n);
i := 2;
s := 0;
While i <= n do begin
s := s + i;
i := i + 2; end;
Writeln(‘s=’, s);
Readln;
end.

jamis sawyisi mniSvneloba 0-is tolia, xolo ciklis


parametris sawyisi mniSvneloba - 2-is, cikli meordeba
manam, sanam ciklis parametris mniSvneloba ar gadaaWarbebs
N-s (ciklis parametris saboloo mniSvnelobas).

30
ciklis operatori bolo pirobiT
REPEAT – UNTIL cikli

REPEAT – UNTIL ciklis operators aqvs Semdegi


struqtura:

REPEAT <operatorebis mimdevroba> UNTIL <piroba>.

aq REPEAT , UNTIL darezervebuli sityvebia, (vimeoroT


manam, sanam ar iqneba Sesrulebuli piroba).
<operatorebis mimdevroba> turbo paskalis nebismieri
operatorebia.
<piroba> logikuri ti pis gamosaxulebaa.
<operatorebis mimdevroba meordeba Tundac erTxel,
mas Semdeg rac Semowmdeba <piroba>, Tu misi mniSvneloba
mcdaria, cikli agrZelebs muSaobas. rogorc ki <piroba>
WeSmariti gaxdeba , cikli amTavrebs muSaobas.
REPEAT – UNTIL ciklis ilustraciisaTvis ganvixiloT
pograma, romelsac ekranze gamoaqvs 2 _ dan n _ mde luwi
ricxvebi:

var
i, n : integer;
begin
Writeln(‘n =’); Readln(n);
i := 2;
Repeat
Writeln (i);
i := i + 2;
Until i > n;
End.

31
Until _ is win ` ; ~-is dasma ar aris aucilebeli.
FOR – TO, WHILE – DO, REPEAT – UNTIL ciklis
operatorebis moqnili marTvisaTvis turbo paskalSi
gamoyenebulia ori procedura:
BREAK _ romelic ciklidan dauyovnebliv gamosvlas
axorcielebs da marTva gadaecema ciklis dasasrulis
momdevno operators.
CONTINUE _ uzrunvelyofs ciklis momdevno
ganmeorebis vadaze adre dasrulebas. igi ciklis
operatoris bolo operatorze mimarTvis eqvivalenturia.
am procedurebis Semotana praqtikulad gamoricxavs
GOTO gadasvlis upirobo operatoris gamoyenebas.

ganvixiloT martivi programebi ciklis operatorebis


gamoyenebiT:

Program ForDemo;

var
count : Integer;

begin
For Count := 1 to 10 do
Writeln (‘gamarjobaT!’);
Writeln(‘programis dasrulebisaTvis daaWireT Enter-s’);
Readln;
end.

programa aTjer gamoitans sityvas `gamarjobaT~.

32
Program WhileDoDemo;
Var
I : Char;

begin
I := ‘ ‘;
While (I < > ‘q’) and (I < > ‘Q’) Do
begin
Write (‘S e i t a n e T s i m b o l o ( p r o g r a m i s
dasrulebisaTvis SeitaneT q an Q) : ‘);
Readln(I);
end;
Writeln (‘programis dasrulebisaTvis daaWireT Enter-s’);
Readln;
end.

While-Do ciklis operatori daamTavrebs muSaobas maSin,


roca klaviaturidan SevitanT `q~ an `Q~ simbolos.

Program RepeatDemo;

Var
I : Char;

begin
Repeat
Write (‘SeitaneT simbolo (programis dasrulebisaTvis
SeitaneT q an Q) : ‘);
Readln(I);
Until (I = ‘q’) or (I = ‘Q’) ;

33
Writeln (‘programis dasrulebisaTvis daaWireT Enter-s’);
Readln;
end.

amorCevis operatori

amorCevis operatori saSualebas iZleva amovirCioT erTi


ramodenime SesaZleblobidan. amorCeva xdeba amorCevis
gasaRebis mixedviT, romelic warmoadgens rigiTi ti pis
nebismier gamosaxulebas (nebismieri garda REAL da STRING
ti pisa).
amorCevis operatoris struqturas aqvs Semdegi saxe:

CASE < amorCevis gasaRebi> OF < amorCevis sia> [ELSE


< operatorebi>] END.

aq CASE, OF, ELSE, END – darezervebuli sityvebia.


(amorCeva, dan, winaaRmdeg SemTxvevaSi, dasasruli).
< amorCevis gasaRebi> is monacemia, romlis mixedviTac
amorCeva xdeba;
<amorCevis sia> _ arCevanis CamonaTvalia;
<operatorebi> _ turbo paskalis nebismieri
operatoria.
amorCevis operatori Semdegnairad muSaobs: dasawyisSi
gamoiTvleba <amorCevis gasaRebis> mniSvneloba. Semdeg
amorCevis siaSi moiZebneba iseTi, romelic Seesabameba
amorCevis gasaRebis mniSvnelobas. napovni operatori
Sesruldeba da amorCevis operatori amTavrebs muSaobas.
Tu amorCevis siaSi ar iqneba is mudmiva, romelic Seesabameba

34
amorCevis gasaRebis mniSvnelobas, maSin marTva gadaecema
ELSE-s Semdgom operators.
ELSE < operatori> SeiZleba gamotovebul iqnes, maSin
mocemul siaSi saWiro mudmivas aryofnis SemTxvevaSi
araviTari moqmedeba ar sruldeba da amorCevis operatori
ubralod amTavrebs muSaobas. amorCevis siis operatorebSi
SeiZleba monawileobdes ara erTi aramed ramodenime
amorCevis mudmiva, romlebic erTmaneTisagan mZimiTaa
gamoyofili. mag. Semdegi programa y an Y simbolos Setanisas
ekranze gamoitans sityvas `diax~, xolo N an n Setanisas
sityvas `ara~.

mag.:

Var
ch : char;
begin
readln(ch);
case ch of
‘n’,’N’: Writeln(‘ara’’);
‘y’, ‘Y’: Writeln(‘diax’);
end;
end.

TiToeul Setanil simbolos programa amoicnobs, raTa


gamoimuSaos Sesabamisi sapasuxo reaqcia. amorCevis
operatori programists saSualebas aZlevs Seadaros
Setanili monacemebi winaswar gansazRvrul SemTxvevaTa
simravles da moaxdinos Sesabamisi moqmedeba.

35
ganvixiloT programa amorCevis operatoris gamoyenebiT:

Program CaseDemo;

var
UserIn : Char;

begin
Writeln (‘SeitaneT erTi simbolo da daaWireT Enter-
s’);
Readln (UserIn);
Case UserIn of
‘a’ : Writeln (‘es weriTi a simboloa’);
‘z’, ‘Z’ : Writeln (‘es weriTi an beWdviTi z simboloa’)
else
Writeln (‘es simbolo gansxvavebulia a, z, Z - sagan’);
end;
Writeln (‘programis dasrulebisaTvis daaWireT Enter-
s’);

Readln;
end.

ganvixiloT magaliTi, romelic mikrokalkulatoris


muSaobis imitacias warmoadgens. SeitanT or ricxvs da
operaciis niSans. xorcieldeba Sesabamisi operacia da
Sedegi ekranze gamodis. Tu klaviaturidan Setanili
simbolo gansxvavebulia +, _, /, * simboloebisagan, programa
daasrulebs muSaobas.

36
Program calc;

Var
Operacion : char;
X, Y, Z : Real;
stop : boolean;

begin
stop := false;
repeat
Writeln;
Write (‘X, Y=’);
Readln(X, Y);
Write(‘operacia’);
Readln(Operacion);
Case Operacion of
‘+’ : Z := X + Y;
‘-’ : Z := X - Y;
‘*’ : Z := X *Y;
‘/’ : Z := X / Y;
else
stop := true;
end;
if not stop then
Writeln (‘Z=’, Z);
until stop; end.

37
programa Setanili mimdinare TariRis mixedviT gamoitans
momdevno dRis TariRs(ricxvs, Tves da wels);

Program callendar;

var
month, day, year, nom : integer;

begin

Writeln(‘nom, day, year’);


Readln(nom, day, year);
Case nom of
1 : month:= 1;
2 : month:= 2;
3 : month:= 3;
4 : month:= 4;
5 : month:= 5;
6 : month:= 6;
7 : month:= 7;
8 : month:= 8;
9 : month:= 9;
10 : month:= 10;
11 : month:= 11;
12 : month:= 12;
end;
Case nom of
1, 3, 5, 7, 8, 10 : if day = 31 then begin
day := 1; month := succ (month);
end
else
day := day + 1;

38
4, 6, 9, 11 : if day = 30 then begin
day := 1; month:= succ(month);
end
else
day := day + 1;
12 : if day = 31 then begin day := 1; month := 1;
year := year + 1; end
else
day := day + 1;
2 : if (day = 28) and (year mod 4 < > 0) or (dd = 29) then
begin
day := 1; month := succ(month); end
else
day := day + 1; end;

Writeln (month);
Writeln (day);
Writeln (year);
Readln;
end.

Wde da gadasvlis operatori

Cvens mier ganxiluli operatorebi sakmarisia nebismieri


sirTulis programis dasawerad. am TvalsazrisiT gadasvlis
operatoris gamoyeneba zedmetad iTvleba. amasTan,
Tanamedrove struqturuli programirebis teqnologia
dafuZnebulia GOTO - s gareSe programirebaze. iTvleba,
rom GOTO –s gamoyeneba arTulebs programis gaazrebas
da CaxlarTuls xdis mas. Tumca, zogjer GOTO – s

39
gamoyenebam SeiZleba gaamartivos programa.
gadasvlis operators aqvs Semdegi saxe:

GOTO – <Wde>

aq GOTO – darezervebuli sityvaa (gadadi [Wdeze]).


Wde turbo paskalSi nebismieri identifikatoria, romelic
programis romelime operators aniWebs saxels da
mimarTvads xdis mas.
turbo paskalSi dasaSvebia Wdis saxiT gamoyenebul
iqnes mTeli ricxvi niSnis gareSe. Wde ganTavsebulia
mosaniSni operatoris win da misgan gamoiyofa ` : ~ - iT.
sanam programaSi gamoCndeba Wde, igi unda iqnes aRwerili.
Wdis aRwera Sedgeba darezervebuli sityvisagan LABEL
(Wde), romelsac Wdis sia mosdevs .

LABEL
Loop, Lb1, Lb2;

begin
………
goto Lb1;
………
Loop : ………
………
Lb1 : Lb2 : …….
………
goto Lb2;
………

40
goto operatoris moqmedeba mdgomareobs daniSnul
operatorze marTvis gadacemaSi. Wdis gamoyenebisas
aucilebelia gaviTvaliswinoT Semdegi wesebi :
• Wde aucileblad unda aRiweros aRweris nawilSi
da aucileblad monawileobdes operatorebis nawilSi.
• Wde, romelic aRwerilia proceduraSi an funqciaSi,
lokalizebulia mxolod maTTvis.

masivis ti pi.

masivis ti pi miekuTvneba rTuli ti pis monacemebs. rTuli


ti pis monacemebi gansxvavdeba martivisagan imiT, rom isini
Seicaven 1-ze met komponents. masivi erTnairi ti pis
monacemebis mowesrigebuli nakrebia. masivis aRwera xdeba
misi komponentebis ti pisa da indeqsis CvenebiT. masivis
aRweris zogadi saxea:

ARRAY [T1] of T2

sadac T1 indeqsia, T2 monacemebis tipi. ganvixiloT masivis


aRweris ramodenime magaliTi.

TYPE COLOR = (RED, BLUE, BLACK) ;


MAS1 = ARRAY[-5..15] OF REAL;
MAS2 = ARRAY[1..10,1..10] OF INTEGER;
AMS3 = ARRAY[‘A’..’C’] OF ARRAY[1..5] OF BOOLEAN;
MAS4 = ARRAY[BOOLEAN] OF CHAR;
VAR A : MAS1; B : MAS2; C : MAS3; D : MAS4;

41
E : ARRAY[COLOR] OF REAL;

A masivi aris namdvili ti pi, romlis komponentebis


indeqsebia 5-dan 15-mde. B masivi mTeli ricxvebisagan
Sedgenili kvadratuli matricaa, romelic Sesdgeba 10
striqonisa da 10 svetisagan. C masivi aRwerilia, rogorc
logikuri sidideebis matrica, romelsac aqvs sami striqoni
A, B, C da xuTi sveti. misi elementi, romelic dgas
meore striqonSi da pirvel svetSi aRiniSneba:
C[‘B’,1]
D masivi S simboloebis veqtoria, romelic ori
komponentisagan Sedgeba .
E masivi warmoadgens sam elementian veqtors, e.i. Seicavs
sam obieqts, romelic aRwerilia CamoTvliTi ti piT
COLOR. misi komponentebi gamoiyurebian Semdegnairad:
E[RED], E[BLUE]; E[BLACK].
masivis elementebis Setana da gamotana SeiZleba mxolod
TiToeuli elementis saxiT, ganvixiloT masivis Setana-
gamotanis ramdenime magaliTi:
PROGRAM ….;
MAS1 = ARRAY [1..3, 1..2] OF REAL;
MAS2 = ARRAY[1..6] OF REAL;
var
XS : MAS2;
XF : MAS1; I, J : Integer;
(*fragmenti 1*);

begin
Readln; Write(‘XS=> ‘);
For I:=1 to 6 do Read(XS[I]);

42
(*fragmenti 2*)

Readln; Write(‘XF=>’);
For I := 1 to 3 do
for J := 1 to 2 do Read (XF[I, J]);

fragmenti 1 axorcielebs eqvs elementian namdvili tipis


masivis Setanas, xolo meores Seaqvs namdvili tipis matrica,
romelic Sedgeba sami striqonisa da ori svetisagan, Setana
xorcieldeba ori CarTuli ciklis operatoris meSveobiT,
xolo Sesabamisi masivebis gamotanas aqvs Semdegi saxe:

(*fragmenti 1*)

FFor I:=1 to 6 do Write (XS[I] : 4);

(fragmenti 2*)

For I:=1 to 3 do
begin
For J:=1 to 2 do Write (XF[I, J] : 6 : 2);
Writeln;
end.

ganvixiloT magaliTi, romelic Seajamebs aT elementian


mTeli ti pis masivis wevrebs.
const
N = 10;
var

43
A : Array[1..N] of Integer;
I, S : Integer;
begin
Writeln (‘masivi’);
For I:=1 to N do Readln (A[I]);
S := 0;
For I := 1 to N do S := S + A[I];
Writeln (‘S = ’, S);
end.
ganvixiloT programa, romelic Sekrebs MM matricis
TiToeuli striqonis dadebiT elementebs da miRebuli
jamisagan aagebs VV veqtors.

type MAT1 = Array [0..5, 0..9] of Integer;


VEK1 = Array[0..5] of Integer;
var MM : MAT1; VV : VEK1; S, I, J : Integer;
………………………………….

For I = 0 to 5 do
begin
S := 0;
For J := 0 to 9 do
If MM[I, J] > 0 then S := S + MM[I, J];
VV[I]:=5;
end.

programa iTvlis aT elementiani mTeli ti pis masivSi


luwi elementebis raodenobas.

44
Program ……….;
const
N = 10;
var
K , I : Integer;
M : Array[1..N] of Integer;
begin
K := 0;
Write (‘masivi=>’);
For I := 1 to N do readln (M[I]);
For I := 1 to N do
If M[I] mod 2 = 0 then
K:=K+1;
Writeln (‘luwi elementebis raodenoba=’, K);
end.
programa iTvlis aTelementian masivSi kentindeqsiani
wevrebis jams:
Program ……..;
const
N=10;
var
M : Array[1..N] of Integer;
I, S : Integer;
begin

45
Writeln (‘masivi=>’);
For I:=1 to N do readln (M[I]);
S := 0; I := 1;
Repeat
S := S + M[I];
I := I+2;
Until I>N; Writeln(‘S=’, S) ;
end.

simravle

simravle erTnairi ti pis obieqtebis nakrebia, romlebic


raRac saxiT arian erTmaneTTan dakavSirebulni. obieqtebs
Soris kavSiris xasiaTi gaTvaliswinebulia programistis
mier da ar kontroldeba turbo paskalis garemoTi.
elementebis raodenoba simravleSi SeiZleba icvlebodes
0-255-is farglebSi. simravle Tu ar Seicavs elements,
hqvia carieli [ ].
ori simravle eqvivalenturia, Tu maTi yvela elementi
erTnairia. maTi mimdevroba SeiZleba iyos nebismieri. Tu
erTi simravlis yvela elementi Sedis meoreSi, amboben, rom
pirveli simravle CarTulia meoreSi.

ganxilul magaliTSi mocemulia simravle :

type
digitchar = set of ‘0’..’9’ ;
digit = set of 0..9;

46
var
S1, S2, S3 : digitchar;
S4, S5, S6 : digit;
…………………..
S1 := [‘1’,’2’,’3’];
S2 := [’3’,’2’,’1’];
S3 := [‘2’,’3’];
S4 := [0..3, 6];
S5 := [4, 5 ];
S6 := [3..9];
am magaliTSi simravle S1 eqvivalenturia S2-sa, S3
CarTulia S2 –Si, magram misi eqvivalenturi ar aris.
simravlis aRweras aqvs Semdegi saxe:
<ti pis saxeli> = set of < bazuri ti pi>
<ti pis saxeli> - identifikatoria.
set, of darezervebuli sityvebia (simravle, dan).
<baz. ti pi> - simravlis elementebis bazuri ti pia,
romlis saxiT SeiZleba gamoyenebul iqnas nebismieri ti pi,
garda Word, Integer, Longint.

simravlis elementebi erTmaneTisagan gamoiyofa mZimeebiT


da Caismeba kvadratul frCxilebSi.

simravleebisaTvis gansazRvrulia Semdegi operaciebi:


* simravleTa gadakveTa, Sedegi Seicavs mocemul
simravleTa saerTo elements.
magaliTad S4 * S6 Seicavs [3, 6]-s.

+ simravleTa gaerTianebaa. Sedegi Seicavs pirveli


simravlis yvela elements mimatebuls meore simravlis

47
gansxvavebul elementebs.
S4 + S5 Seicavs [0, 1, 2, 3, 4, 5, 6,];

- simravleTa sxvaoba, Sedegi Seicavs pirveli simravlis


im elementebs, romlebic ar Sedian meore simravleSi.
S6-S5 Seicavs [3, 6, 7, 8, 9];

= simravleTa Semowmeba eqvivalenturobaze, Sedegia TRUE,


Tu simravleebi eqvivalenturia.

< > araeqvivalenturobaze Semowmeba. Sedegia TRUE, Tu


simravleebi araeqvivalenturia.

<= simravleTa Sedareba. Sedegia TRUE, Tu meore


simravle CarTulia pirvelSi.

>= simravleTa Sedareba, Sedegia TRUE, Tu meore simravle


CarTulia pirvelSi.

in Semowmeba kuTvnilebaze. aq pirveli elementia


gamosaxuleba, meore ki - igive ti pis simravle. Sedegia
TRUE, Tu gamosaxulebis mniSvneloba Sedis simravleSi.

3 in S6 - TRUE
2 * 2 in S1 - FALSE.

48
programa ekranidan Setanil ricxvs Seamowmebs martivia
Tu ara da gamoscems Sesabamis Setyobinebas:

Program SetOfDemo;

const
n = 201;

Type
mn = set of 2..n;

var
m, pm : mn;
q, i, k, p : integer;

begin
m := [2..n]; pm := [ ];
p := 2;
Repeat
While not (p in m) do p := p + 1;
pm := pm + [p];
k := p;
Repeat m := m - [k]; k := k + p; Until k > n;
Until m = [ ];
Writeln;
Repeat
Writeln(‘q’); Readln(q);
If q in pm then Writeln(q, ‘martivia’)
else
Writeln (q, ‘ar aris martivi’);
UUntil q > 201;
Readln;
end.
49
striqonis ti pi

STRING (striqoni) ti pi farTod gamoiyeneba turbo


paskalSi teqstebis dasamuSaveblad. is emsgavseba
erTganzomilebiani masivis simboloebs ARRAY[0..N] OF
CHAR. magram am ukanasknelisagan gansxvavebiT, striqonSi
simboloebis raodenoba SeiZleba 0-dan N-mde icvlebodes,
sadac N striqonSi elementTa maqsimaluri raodenobaa.
N-is mniSvneloba ganisazRvreba STRING[N] ti pis
gamocxadebiT da SeiZleba Seicavdes 255 simbolos. turbo
paskali saSualebas gvaZlevs ar mivuTiToT N, am SemTxvevaSi
striqonis sigrZe CaiTvleba maqsimalurad SesaZlebeli,
anu N = 255.
striqoni simboloebis mimdevrobaa. striqonis nebismier
elements SeiZleba mivmarToT zustad iseve, rogorc
erTganzomilebiani masivis elementebs, romelic aRwerilia
Semdegnairad:

ARRAY [0..N] of CHAR;

mag.:
var
st : String;
begin
……………………….

If st[5] = ’A’ then………..


……….
end.

striqonebze SeiZleba ganxorcieldes SeWidebis operacia

50
ST := ’A’+’B’;
ST := ST + ’C’; {ST Seicavs ‘ABC’}

Tu miRebuli striqonis sigrZe dasaSvebs aRemateba,


maSin zedmeti simboloebi ukuigdeba. ganvixiloT magaliTi,
romelic dabeWdavs mxolod erT simbolos.
var
st : String[1];
begin
st := ’123’;
Writeln(st);
end.

danarCeni moqmedebebi striqonebsa da simboloebze


xorcieldeba qvemoT moyvanili procedurebisa da
funqciebis meSveobiT.

CONCAT (S1, S2, …….,Sn) –STRING ti pis funqciaa,


iZleva striqons, romelic miRebulia S1, S2, …., Sn
striqonebis SeerTebiT.
Tu ST1 = a ; ST2 = b ; STk = z ;
CONCAT(ST1, ST2,…..,STk) = ab….z;

COPY (ST, INDEX, COUNT) – STRING ti pis funqciaa,


romelic ST striqonidan, INDEX nomridan dawyebul COUNT
raodenobis simbolos gaukeTebs kopirebas,

COPY (‘Branka’, 3, 4) -> ‘anka’


COPY (‘Branka’, 5, 3) -> ‘ka’

51
COPY (‘Branka’, 2,1) -> ‘r’

DELETE(ST, INDEX, COUNT) procedura ST


striqonidan waSlis COUNT raodenobis simbolos,
dawyebuli INDEX nomridan.
ganvixiloT magaliTi, davuSvaT dasawyisSi trg-s aqvs
mniSvneloba ‘janek’
DELETE (trg, 4, 2) -> ‘jan’
DELETE (trg, 6, 1) -> ‘janek’
DELETE (trg, 5, 3) -> ‘jane’

INSERT (SUBST, ST, INDEX) – procedura SUBST


qvestriqons Casvams ST striqonSi, INDEX nomridan
dawyebuli.
INSERT(‘an’, trg, 2) -> ‘janb’
trg = ’jb’

LENGTH (ST) - mTeli ti pis funqciaa, romelic


gvaZlevs ST striqonis sigrZes.
LENGTH (‘jb’) ->2

STR (VAL, VAR) - proceduras mTeli an namdvili tipis


ricxvi gadahyavs simboloebis striqonSi.
VAL ariTmetikuli gamosaxulebaa,
VAR - striqonuli cvladis saxelia.

STR (45, strvar) ->’45’


STR (-250, strvar) -> ‘-250’

VAL (ST, X, CODE) - proceduraa, romelsac striqoni


ST gadahyavs mTel an namdvil ricxvSi. Tu gadayvanam

52
Caiara warmatebiT, CODE Seicavs nuls, xolo Tu gadayvanam
warmatebiT ar Caiara, maSin CODE Seicavs ST striqonis
im poziciis nomers, sadac napovni iqneba SecdomiTi simbolo,
carieli adgili striqonSi ar unda iyos.

POS (SUBST, ST) – mTeli ti pis funqciaa, romelic ST


striqonSi moZebnis SUBST qvestriqonis pirvel Sesvlas
da iZleva poziciis nomers, romlidanac igi iwyeba. Tu
qvestriqoni ar iqneba napovni gvaZlevs nuls.

POS (‘23’, ’123123’) -> 2


POS (‘21’,’123123’) -> 0
POS (‘c’, ’abcabc’) -> 3

UPCASE(CH) – CHAR ti pis funqciaa, romelsac CH


simboluri gamosaxuleba gadahyavs beWdviT laTinur
simboloebSi.
ganvixiloT magaliTi, romelSic gamoyenebulia ramdenime
procedura da funqcia :

var
x : Real ;
y : Integer ;
st, st1 : String ;
begin
st := concat (‘12’,’345’); {st striqoni Seicavs 12345}
st1 := copy (st, 3, Length(st)-2); {st Seicavs 345}
Insert(‘-‘, st1, 2); {st1 Seicavs 3-45}
Delete (st, pos(‘2’, st, 3)); {st striqoni Seicavs 15}
Str (p1 : 6 : 2, st); {st striqoni Seicavs 3-

53
14}
Val (‘3,1415’, x, y); {y Seicavs 2, x darCa ucvleli}
end.
=, < >, >, <, >=, <= damokidebulebis operaciebi sruldeba
or striqonze. Sedareba xdeba simboloebis mixedviT.
qvemoT ganxiluli operaciebi mogvcems TRUE
mniSvnelobas:

‘’’’<’.’
‘A’ > ’1’
‘Turbo’ < ‘Turbo Pascal’

ganvixiloT magaliTi, romelsac simboluri gamosaxuleba


gadahyavs beWdviT laTinur simboloebSi.

Program ………;
var
k, ch : String; I : Integer;
begin
Readln (ch);
for I := 1 to length(ch) do begin
k[I] := Upcase(ch[I]); Write(k[I]);
end;
Readln;
end.

54
programa aerTianebs or striqons da beWdavs
ukumimdevrobiT, iTvlis gaerTianebuli striqonis sigrZes
da gamoaqvs ekranze:

Program StringDemo;

var
St1, St2 : String[15];
St : String;
I, K : Integer;

begin
Writeln (‘St1, St2’);
Readln (St1, St2);
St := Concat (St1,’ ‘, St2);
K := Length (St);
For I := K Downto 1 Do
Write(St[I]);
Writeln(‘gaerTianebuli striqonis sigrZea ’, K);
Readln;
end.

ganxilul programaSi St1, St2 striqonebis maqsimaluri


sigrZea 15 simbolo, rac niSnavs, rom Tu Setanili
striqonebis sigrZe aRemateba aRniSnuls, maSin zedmeti
simboloebi daikargeba. St striqonis sigrZe ar aris
gamocxadebuli, amitom igulisxmeba, rom misi sigrZea 255.

55
obieqturi paskali.
(Object Pascal)

Canawerebi

Canaweris (RECORD) ti ps aqvs gansxvavebuli


monacemebis struqtura. masivis msgavsad Canaweri gamoiyeneba
urTierTdamokidebuli informaciis jgufis Sesanaxad, magram
masivisagan gansxvavebiT Canaweris elementebi ar aris
aucilebeli iyos erTnairi ti pis. Canawerebi gamoiyeneba
ZiriTadad iseTi obieqtebis Sesaxeb informaciis Sesanaxad,
rogoricaa adamianebi an adgilebi. CanawerSi SeiZleba
movaTavsoT gvarebi, misamarTebi, telefonis nomrebi, wona.
informaciis mTel jgufs SeiZleba mivceT erTi saxeli,
iseve rogorc masivSi.
ganvixiloT Canaweris ti pis martivi magaliTi.

Program MyRecordDemo ;
uses
forms ;
type
PersonalRecordType=Record
Name : String[30];
PhoneNumber : String[13];
Age : Integer;
Sex : Char;
end; {PersonalRecordType}
var
Person : PersonalRecordType;
begin
Person.Name := ‘Dan Osier’;
Person.PhoneNumber := ‘(916)555-1212’;
Person.Age :=32;
56
Person.Sex := ‘M’;
Writeln(‘The Person’ ‘ s name is ‘, Person.Name);
Writeln (‘The Person’ ’s Phone number is ‘, Person.PhoneNumber);
Writeln(‘The Person’ ’ s age is ‘, Person.Age);
Writeln(‘The Person’ ’ s sex is ‘, Person.Sex);
Readln; {fanjara rom darCes gaxsnili, sanam ar
davaWerT Enter Rilaks}
end. {MyRecordDemo}

programa iwyeba RECORD ti pis gamocxadebiT.


monacemTa struqturis es ti pi Sesdgeba ramdenime
nawilisagan. pirveli striqoni PersonalRecordType =Record
ambobs, rom gamocxadebis Semdegi striqonebi Seicavs
Canaweris velebs. SemdgomSi CamoTvlilia velebi (maTi
ti pebi). aq gvaqvs velebi: Name (gvari, saxeli) String ti pis,
romlis sigrZea 30 simbolo, PhoneNumber (telefonis
nomeri) String ti pis, romlis sigrZea 13 simbolo, Age (asaki)
Integer-is ti pis da Sex (sqesi) Shar ti pis (M an F).
Canaweris gamocxadeba mTavrdeba end operatoriT.
es gamocxadeba mxolod gansazRvravs Canaweris tips. roca
gamocxaddeba Person cvladi, rogorc PersonalRecordType,
mxolod maSin gamoiyofa mexsiereba mocemuli ti pisaTvis.
ris Semdegac xdeba monacemebis Setana.
TiToeuli velis Sesatanad jer miTiTebulia Canaweri,
Semdeg ki Canaweris veli. magaliTad gvari da saxelis
Setana xdeba Semdegnairad: Person.Name:=’Dan Osier’. is
uCvenebs Delph-s Canaweris romel velTan gvinda mimarTva.
gamotanis operatorSi naCvenebia veli, romelic gvinda
daibeWdos. Tu gamotanis operators mivcemT Semdeg saxes
Writeln(Person), is ver amoicnobs, Tu romeli veli dabeWdos.
gamoviyenoT masivi, romelic Sedgeba Canawerebisagan.
magaliTad Tu masivs gamovacxadebT, rogorc Array[1..3] of
PersonalRecordType, es niSnavs, rom es masivi Sedgeba sami

57
Canawerisagan. TiToeuli es Canaweri Seicavs informacias
pirovnebis Sesaxeb, rogoricaa gvari, telefonis nomeri
da ase Semdeg.
ganvixiloT Canaweris ti pis martivi magaliTi.

Program MyRecordDemo ;
uses
forms ;
type
PersonalRecordType=Record
Name : String[30];
PhoneNumber : String[13];
Age : Integer;
Sex : Char
end; {PersonalRecordType}
MyArrayType=array [1..3] of PersonRecordType;
var
PersonArray : MyArrayType;
begin
PersonArray[1].Name := ‘Dan Osier’;
PersonArray[1].PhoneNumber := ‘(916)555-1212’;
PersonArray[1].Age :=32;
PersonArray[1].Sex := ‘M’;

PersonArray[2].Name := ‘Susie Smith’;


PersonArray[2].PhoneNumber := ‘(916)555-9999’;
PersonArray[2].Age :=38;
PersonArray[2].Sex := ‘F’;

PersonArray[3].Name := ‘Pat’;
PersonArray[3].PhoneNumber := ‘(916)555-7766’;
PersonArray[3].Age :=30;
PersonArray[3].Sex := ‘M’;

58
Writeln(‘pirveli TanamSromlis saxeli‘, PersonArray[1].Name);
Writeln (‘telefonis nomeri ‘, PersonArray[1].PhoneNumber);
Writeln(‘asaki‘, PersonArray[1].Age);
Writeln(‘sqesi ‘, PersonArray[1].Sex);

Writeln(‘meore TanamSromlis saxeli ‘, PersonArray[2].Name);


Writeln (‘telefonis nomeri ‘, PersonArray[2].PhoneNumber);
Writeln(‘asaki‘, PersonArray[2].Age);
Writeln(‘sqesi ‘, PersonArray[2].Sex);

Writeln(‘mesame TanamSromlis saxeli ‘, PersonArray[3].Name);


Writeln (‘telefonis nomeri ‘, PersonArray[3].PhoneNumber);
Writeln(‘asaki‘, PersonArray[3].Age);
Writeln(‘sqesi ‘, PersonArray[3].Sex);

Readln; {fanjara rom darCes gaxsnili, sanam ar davaWerT


Enter Rilaks}
end. {MyArrayRecordDemo}

ganxilul magaliTSi PersonArray cvladi warmoadgens


Canaweris ti pis masivs. am saxiT operatori
PersonArray[3].Name := ’Pat’, miuTiTebs, rom PersonArray
cvladSi mesame elementis Name vels mieniWos ‘Pat’
mniSvneloba.
masivis ti pis Canaweris gamoyeneba mouxerxebelia, rodesac
Sesatani gvaqvs didi moculobis informacia, magaliTad
informacia TanamSromlebis Sesaxeb.

ganvixiloT Canaweris ti pis kidev erTi magaliTi:

Program MyRecord2demo ;
uses

59
Forms;
type
AddressType=record
Street : String [50];
City : String [20];
State : string [2];
ZipCode : String [10]
end; {addressType}

PersonType = record
LastName : String[20];
FirstName : String [10];
EmployeeNumber : Integer;
HomeAddress : AddressType;
WorkAddress : AddressType;
end; {PersonType}

var
Employee : PersonType;
begin
Employee.LastName := ‘Osier’;
Employee.FirstName := ‘don’;
Employee.EmployeeNumber := 16253;

Employee.HomeAddress.Street := ‘1313 Your St.’;


Employee. HomeAddress.City := ‘MyTown’;
Employee. HomeAddress.State := ‘Ca’;
Employee. HomeAddress.ZipCode := ‘95630-0011’;

Employee.WorkAddress.Street := ’14 Big Business Road.’;


Employee.WorkAddress.City := ‘NoOzone’;
Employee.WorkAddress.State := ‘CA’;
Employee.WorkAddress.ZipCode := ‘95636-2211’;

60
Writeln (Employee.LastName);
Writeln(Employee.FirstName);
Writeln(Employee. EmployeeNumber);

Writeln (Employee.HomeAddress.Street);
Writeln (Employee.HomeAddress.City);
Writeln (Employee.HomeAddress.State);
Writeln (Employee.HomeAddress.ZipCode);

Writeln (Employee.WorkAddress.Street);
Writeln (Employee.WorkAddress.City);
Writeln (Employee.WorkAddress.State);
Writeln (Employee.WorkAddress.ZipCode);

Readln; {fanjara rom darCes gaxsnili, sanam ar davaWerT


Enter Rilaks}
end. {MyRecord2Demo}

Canaweri PersonType Secavs or cvlads: es aris


HomeAddress da WorkAddress, orive isini AAddressType
ti pisani arian. cvladze mimarTvisaTvis saWiroa mieTiTos:
cvladis saxeli (Employee), wertili, velis saxeli
(HomeAddress), wertili, da radganac HomeAddress aris
aseve Canaweri, mieTiTeba misi veli Street. gamotanis
drosac mieTiTeba analogiuri mimdevrobiT:
Employee.HomeAddress.Street
imisaTvis, rom es Canaweri iyos ufro kompaqturi, gamoiyeneba
With operatori. aRniSnuli operatoris gamoyenebiT
programa miiRebs Semdeg saxes:

61
Program MyRecord3demo ;
uses
Forms;
type
AddressType=record
Street : String [50];
City : String [20];
State : string [2];
ZipCode : String [10]
end; {addressType}

PersonType = record
LastName : String[20];
FirstName : String [10];
EmployeeNumber : Integer;
HomeAddress : AddressType;
WorkAddress : AddressType;
end; {PersonType}

var
Employee : PersonType;
begin
With Employee do
begin {With operatoris dasawyisi}
LastName := ‘Osier’;
FirstName := ‘don’;
EmployeeNumber := 16253;
end; {With Employee-s dasasruli}

With Employee.HomeAddress do
begin {with operatoris dasawyisi}
Street := ‘1313 Your St.’;
City := ‘MyTown’;

62
State := ‘Ca’;
ZipCode := ‘95630-0011’;
end; {with Emloyee.HomeAddress dasasruli}

With Employee.WorkAddress do
begin { with dasawyisi}
Street := ’14 Big Business Road.’;
City := ‘NoOzone’;
State := ‘CA’;
ZipCode := ‘95636-2211’;
end; {with Employee.WorkAddress dasasruli}

With Employee do
begin {with dasawyisi}
Writeln(LastName);
Writeln(FirstName);
Writeln(EmployeeNumber);
end; {with Employee dasasruli}

With Employee.HomeAddress do
begin {with dasawyisi}

Writeln (Street);
Writeln (City);
Writeln (State);
Writeln (ZipCode);
end; {with Employee.HomeAddress dasasruli}

With Employee.WorkAddress do
begin {with dasawyisi}
Writeln (Street);
Writeln (City);
Writeln (State);

63
Writeln (ZipCode);
end; {with Employee.WorkAddress dasasruli}

Readln; {fanjara rom darCes gaxsnili, sanam ar davaWerT


Enter Rilaks}

end. {MyRecord3Demo}

ti pizebuli mudmiva.

ti pizebuli mudmiva umjobesia warmovadginoT, rogorc


cvladi mocemuli sawyisi mniSvnelobiT. SegviZlia
ganvsazRvroT tipizebuli mudmiva da mivceT mas mniSvneloba
erT operatorSi. magaliTad:
ConstMax : Integer=88;
Name : String[10]=’Dan’;
Digit : Set of ‘0’..’9’;

ganvixiloT programa, romelSic gamoyenebulia ti pizebuli


mudmiva:

Program TypedConstantDemo;
uses
Forms;

const
MyName : String = ‘Dan Osier’;
begin
Writeln(‘Cemi saxelia’, MyName);
MyName := ‘Jim Fisher’;
Writeln(‘Cemi axali saxelia’, MyName);
Readln;
end.

64
es programa iwyeba MyName ti pizebuli mudmivas
gamocxadebiT, romelic String ti pisaa da misi sawyisi
mniSvnelobaa ‘Dan Osier’. dasawyisSi daibeWdeba MyName
-is mniSvneloba, imis dasadastureblad, rom ti pizebuli
mudmivasaTvis SesaZlebelia sawyisi mniSvnelobis miniWeba.
Semdgom MyName – mniSvneloba icvleba ‘Jim Fisher’ – ze
da is ibeWdeba. es niSnavs, rom ti pizebuli mudmivas
mniSvneloba SeiZleba ASeicvalos programis Sesrulebis
procesSi.

CamoTvliTi ti pi.

CamoTvliTi ti pi gamoiyeneba programis kodebis


wakiTxvis gasaumjobeseblad. davuSvaT, vwerT SuqniSnis
marTvis programas da gvinda aRvweroT wiTeli, yviTeli
da mwvane feri. TiToeul fers SegviZlia mivaniWoT Tavisi
nomeri. davuSvaT: 1 – wiTeli; 2 – yviTeli; 3 – mwvane.
viciT, rom 3 aRniSnavs mwvanes, magram sxvisTvis es iqneba
gaugebari. gamosavali aris CamoTvliTi ti pis gamoyeneba.
CamoTvliTi ti pis elementebis raodenoba ar unda
aRematebodes 255-s.
ganvixiloT programa CamoTvliTi ti pis gamoyenebiT.

Program MyEnumeratedDemo ;

uses forms ;

type
StopLightColors = (Red, Yellow, Green) ;

var
MyLight : StopLightColors;

65
begin

MyLight := Red;
Writeln(‘Cemi mimdinare feria-’, Integer(MyLight));
MyLight := Green;
Writeln(‘axali feria’, Integer(MyLight));
Readln;end.

ganxilul programaSi gvaqvs CamoTvliTi ti pi


StopLightColors , romelsac aqvs sami mniSvneloba: Red,
Yellow, Green.

variantis ti pi.

variantis ti ps 16 baitiani struqtura aqvs , romelic


inaxavs ara marto mniSvnelobas, aramed misi ti pis Sesaxeb
informaciasac.
ganvixiloT programa variantis ti pis gamoyenebiT:

Program MyVariantDemo ;

uses
Forms ;

var
MyInput : Variant ;

begin
MyInput := 3.5555;
Writeln (MyInput);

MyInput := ‘ gamarjobaT, me mqvia Dan’;

66
Writeln (MyInput);

MyInput := 4;
Writeln (MyInput);
Readln;
end.

am martiv programaSi gamoyenebulia MyInput cvladi,


romelic variantis ti pisaa. Tavidan mas vaniWebT
3.5555(namdvili ti pi) ricxviT mniSvnelobas. romelic
gamogvaqvs ekranze. Semdeg MyInput cvladSi ganTavsdeba
striqoni: ‘gamarjobaT, me mqvia Dan’. es Semadgenloba kvlav
gamova ekranze. es miuTiTebs, rom MyInput – ma SeiZleba
Seinaxos striqonic. bolos MyInput cvlads eniWeba
mniSvneloba 4(mTeli ricxvi), es Semadgenlobac gamodis
ekranze.
variantis ti pis fasi mis moqnilobaSia. masSi SeiZleba
moTavsdes TiTqmis yvela ti pi. Tumca obieqturi paskali
mkacrad ti pizebuli enaa, magram variantis ti pi
gamonaklisis saSualebas iZleva.

ganStoeba

Object Pascal-is erT-erTi Tviseba aris programis


ganStoeba. es aris saWiroebis SemTxvevaSi programis sxva
nawilze gadasvlis SesaZlebloba. es SeiZleba
ganxorcieldes sxvadasxva gziT :

 Goto
 Break
 Continue
 Exit

67
 Halt
 RunError

Goto

es operatori saSualebas iZleva gadavideT programis


nebismier striqonze.
ganvixiloT magaliTi :

Program GotoDemo ;
Uses
Forms ;
var
Ansver : String ;
Label ThePlace ;
begin
ThePlace : Writeln (‘ gamarjobaT !’) ;
Writeln (‘gnebavT gavimeoroT kidev ?’) ;
Readln (Answer) ;
if (Answer = ‘y’) or (Ansver = ‘Y’) Then
Goto ThePlace ;
Writeln (‘programis dasrulebisaTvis daaWireT enter-s”) ;
Readln ;
end.

programa acxadebs Wdes ThePlace saxeliT. Wde


gamocxaddeba sxva monacemebis aRweris Semdeg (rogoricaa
Var, Type da a.S.)
Sesruldeba “gamarjobaT~ sityvis gamotana, Semdeg gamodis
SekiTxva “gindaT Tu ara gaimeoroT ?~, Tu pasuxi aris
“y~(yes) an “Y~ , maSin Sesruldeba ThePlace operatori.
winaaRmdeg SemTxvevaSi Sesruldeba bolo operatorebi
Writeln da Readln. Goto operators Zalian iSviaTad iyeneben,

68
radgan arsebobs sxva xerxebi am operatoris Sesacvlelad.

Break.

davuSvaT moqmedeba xdeba ciklis operatorSi da


Seiqmna ciklidan gamosvlis aucilebloba. amis
SesaZleblobas iZleva Break operatori.

Program BreakDemo ;

uses
Forms ;

var
I : Char ;
begin
I : =‘ ‘ ;
While TRUE Do
Write ( ‘muSaobis damTavrebisaTvis SeitaneT q an Q’) ;
Readln (I) ;
If (I=’q’) or (I=’Q’) Then
Break ;
end ;
{ Break brZanebis Sesrulebas gadmovyavarT aq}
Writeln (‘daaWireT enter-s programis dasrulebisaTvis’) ;
Readln ; {enter-is daWeramde rom fanjara Ria iyos} ;
end. {BreakDemo}

pirobis Tanaxmad cikli usasrulod unda gagrZeldes,


radgan Sesamowmebeli piroba yovelTvis WeSmaritia.
aqedan gamosavali aris Break operatori. pirobis
operatori amowmebs daWerili iyo Tu ara “q~ an “Q~,

69
Tu iyo daWerili, maSin sruldeba Break

Continue

SeiZleba programaSi gvqondes situacia, rodesac


gvinda garkveul adgilas Sewydes moqmedeba da gadavides
programis sxva adgilas. am dros gamoiyeneba Continue
operatori.
ProgramContinueDemo ;
uses
Forms ;
var
I : Char ;
Count : Integer ;
begin
I :=’ ‘ ;
For Count :=1 to 100 Do
begin
Write (‘Seitane simbolo :’) ;
Readln (I) ;
Writeln (‘damTvleli Count tolia : ‘, Count) ;
If (I=’q’) or (I=’Q’) Then
Continue ;
Writeln (‘es Sesruldeba mxolod maSin Tu
SevitaneT ‘q’ an ‘Q’) ;
end ;
Writeln (‘d a a W i r e T enter-s p r o g r a m i s
dasrulebisaTvis’) ;
Readln ;
end.

es programa cikls Seasrulbs 10-jer. ciklis SigniT


Cven gvaqvs moTxovna simbolos Setanaze da Setanili

70
simbolo moTavsdeba I cvladSi. Tu davaWerT “q~ an
“Q~ Rilaks, amuSavdeba Continue operatori da daabrunebs
marTvas For ciklze, romelic For ciklSi Count cvlads
daumatebs erT erTeuls da gaagrZelebs Semdeg iteracias.

Exit
Exit operatori gamoiyeneba programis mimdinare
blokidan gamosasvlelad. Tu es bloki aris ZiriTadi
programa, maSin Exit operatori wyvets mis muSaobas, Tu
mimdinare blokia CarTuli, maSin Exit operatori gadascems
marTvas gare blokis operators, romelic im operatoris
momdevnoa, romelzc iyo gadacemuli marTva am CarTul
blokSi. Tu mimdinare bloki procedura an funqciaa, maSin
gamoZaxebuli blokis Sesruleba Sewydeba da marTva
gadaecema misi gamoZaxebis operatoris momdevno operators

Program Exitdemo;
uses
Forms ;
var
I : Char ;
begin
Repeat
Write (‘S e i t a n e T s i m b o l o Q m u S a o b i s
damTavrebisaTvis) ;
Readln (I)
If I=’Q’ then
Exit ;
Until FALSE ;
Writeln (‘es operatori arasodes ar sruldeba’) ;
end.

es programa qmnis usasrulo cikls, romelic mTavrdeba

71
Until False operatoriT. ciklis damTavrebisaTvis unda
SevitanoT “Q~ simbolo, am SemTxvevaSi amoqmeddeba Exit
operatori.

Halt

Halt operatori programis Sesrulebis Sewyvetis


saSualebas iZleva. es operatori SeiZleba gamoviyenoT
Zalian aucileblobis SemTxvevaSi.

Program HaltDemo ;
uses
Forms ;
var
I : Char ;
begin
Repeat
Write (‘dasrulebisaTvis daaWireT Q – s’) ;
Readln (I) ;
If I=’Q’ then
Halt ;
Until FALSE ;
Writeln (‘es operatori arasodes ar Sesruldeba’) ;
end.

RunError

programis nebismier adgilas Cven SegviZlia


SevasruloT brZaneba RunError, mTeli ti pis parametriT.
es Sewyvets programis muSaobas da gamoitans ricxvs
rogorc Secdomis nomers, romelic iwvevs Sewyvetas.

72
Program RunErrorDemo ;
uses
Forms ;
var
I : Char ;
begin
repeat
Write ( ‘dasrulebisaTvis SeitaneT Q simbolo’) ;
Readln (I) ;
If I=’Q’ then
RunError (2400 ;
Until False ;
Writeln (‘es operatori arasodes ar Sesruldeba’) ;
end.

roca momxmarebeli Seitans Q simbolos, programa


gamoscems 240-e nomer Secdomas.

failis ti pi

ganxiluli monacemebis ti pebisaTvis damaxasiaTebelia,


is rom maTTvis garkveulia komponentTa raodenoba. es
saSualebas iZleva, jer kidev programis Sesrulebamde,
aRweris mixedviT gamoiyos manqanis mier mexsierebis saWiro
moculoba monacemebis mniSvnelobis Sesanaxad. magram
arsebobs amocanebis garkveuli klasi da garkveuli situacia,
rodesac komponentebis raodenoba winaswar SeuZlebelia
ganisazRvros, gairkveva mxolod amocanis amoxsnis procesSi
anu programis Sesrulebisas, amisaTvis SemoRebul iqna
specialuri ti pi, romelic warmoadgens erTi da imave
ti pis elementebis nebismier mimdevreobas, Tanac am
mimdevrobis sigrZe winaswar ganusazRvrelia da igi

73
konkretdeba mxolod programis Sesrulebis procesSi. es
ti pi aris – failis ti pi. pirobiTad faili SeiZleba
warmovidginoT rogorc lenta, romelsac aqvs dasawyisi,
xolo dasasruli ar aris dafiqsirebuli. failis elementebi
am lentze Caiwereba mimdevrobiT, erTmaneTis gverdiT.
F {F1, F2, F3 ………………..}

sadac F failis saxelia, F1, F2, F3 - misi


elementebi. faili gvagonebs magnitur lentas, romlis
dasawyisi Sevsebulia melodiis CanawerebiT, xolo bolo
jerjerobiT Tavisufalia. imis analogiurad, rom axali
melodiis Canawerebi SeiZleba moTavsdes magnitofonis
lentis boloSi, aseve failis axali elementebi SeiZleba
Caiweros mxolod mis boloSi.
failuri cvladi paskalSi, es aris failuri ti pis
nebismieri cvladi. paskalSi aris failebis sami klasi:
teqsturi, ti pizebuli da arati pizebuli faili, amitomac
faili, moicema (aRiwereba) Semdegi sami saxiT:

Type
<saxeli> = FILE OF <ti pi>; (1)
<saxeli> = TEXT; (2)
<saxeli> = FILE; (3)

<saxeli> - fai.lis saxelia;


FILE, OF, TEXT – koduri sityvebia (faili, dan,teqsti).
<ti pi> - nebismieri ti pia failis ti pis garda.
(1)- saxiT aRwerilia ti pizebuli faili;
(2)- teqsturi;
(3)-arati pizebuli faili;
nebismieri faili warmoadgens elementebis wrfiv
mimdevrobas, TiToeuls aqvs Tavisi ti pi, failis TiToeul
elements Tavisi nomeri. pirveli elementi iTvleba nulovan

74
elementad.
rogorc vxedavT, faili informaciis erTobliobaa,
romelic SeiZleba damaxsovrebul da aRdgenil iqnes
diskidan. failebSi SeiZleba Seinaxos programis teqsti,
dokumenti, Sesasruleblad momzadebuli programebi da
a.S.
TiToeul fails aqvs saxeli, romelic Sesdgeba ori
nawilisagan: saxeli da gafarToeba. saxeli Sedgeba 1-dan
8-simbolosagan, gafarToeba iwyeba wertilidan da Sedgeba
1 - dan 3 – simbolosagan. magaliTad:
command.com
paper.chi
autoexec.bat

Tumca gafarToeba araaucilebelia, magram igi aRwers


failis Sinaarss, amitom misi gamoyeneba sakmaod
moxerxebulia, bevri programa TviTon adgens failis
gafarToebas.
Cveulebriv, failebze mimarTva xorcieldeba
mimdevrobiT, anu roca elementi waikiTxeba an Caiwereba
failis mimdinare pozicia gadaadgildeba failis rigiT
momdevno elementisaken. Tumca ti pizebuli da
arati pizebuli failebisaTvis SeiZleba organizebul iqnas
pirdapiri mimarTva.

procedurebi da funqciebi failebTan


muSaobisaTvis

failuri cvladi, gamoyenebamde unda daukavSirdes gare


fails AASSIGNN proceduris gamoZaxebiT. gare failad
iTvleba diskze dasaxelebuli faili, magram igi SeiZleba
warmoadgendes mowyobilobasac, magaliTad: klaviaturas,
displeis, printers. gare failSi inaxeba failSi Cawerili

75
informacia anu isini warmoadgenen failidan wakiTxuli
informaciis wyaroebs.
roca kavSiri gare failTan damyarebulia, Setana-
gamotanis operaciebisaTvis mis mosamzadeblad failuri
cvladi unda gaixsnas. arsebuli faili SeiZleba gaixsnas
RESET proceduris meSveobiT, xolo axali faili SeiZleba
Seiqmnas da gaixsnas REWRITE proceduris meSveobiT.
teqsturi failebi, romlebic gaxsnili arian RESET
proceduriT, misawvdomia mxolod wasakiTxad, xolo
teqsturi failebi, romlebic gaxsnilni arian REWRITE
proceduriT, misawvdomia mxolod Casawerad, ti pizirebuli
da ara ti pizirebuli failebisaTvis dasaSvebia rogorc
wakiTxva, aseve Cawera miuxedavad imisa, isini gaxsnili
arian RESET Tu REWRITE procedurebiT.
rogorc adre avRniSneT, failze mimarTva xorcieldeba
mimdevrobiT, anu roca elementi waikiTxeba stanadartuli
procedura READ - iT an Caiwereba standartuli
procedura WRITE - iT, failis mimdinare pozicia
gadaadgildeba failis Semdeg elementze. Tumca tipizebul
da arati pizebul failebze SeiZleba organizebuli iqnas
pirdapiri mimarTva SEEK standartuli proceduris
meSveobiT, romelic failis mimdinare pozicias
gadaaadgilebs mocemul elementze.
failSi mimdinare poziciisa da mimdinare zomis
gansazRvrisaTvis SeiZleba gamoyenebul iqnas standartuli
funqciebi: FILEPOS da FILESIZE.
rodesac programa daasrulebs failis damuSavebas, is
unda daixuros CLOSE standartuli proceduriT . failis
sruli daxurvis Semdeg failuri cvladi SeiZleba
daukavSirdes sxva gare fails.
moviyvanoT im procedurebisa da funqciebis sruli sia,
romlebic gamoiyeneba yvela failisaTvis:

76
procedura Assign - failuri cvlads acnobebs gare
failis saxels;

procedura ChDir - cvlis mimdinare katalogs

procedura Close - daxuravs gaxsnil fails;

funqcia Eof (End_of_File) - fails aZlevs dasrulebul


mdgomareobas;

procedura Erase - Slis gare fails;

procedura GetDir - gvaZlevs mimdinare katalogs mocemul


diskze;

procedura MkDir - qmnis qvekatalogs;

procedura Rename - gare failis saxelis gadarqmeva;

procedura Reset - xnis arsebul fails;

procedura Rewrite - qmnis da xsnis axal fails;

procedura RmDir - Slis cariel qvekatalogs.

77
teqsturi faili
procedurebi da funqciebi teqsturi failebis
damuSavebisaTvis

avRniSnoT rom turbo paskalSi teqsturi tipis faili


(Text) gansxvavdeba simboluri ti pis failisagan.
teqsturi failis gaxsnisas gare faili
interpretirdeba gansakuTrebuli saxiT; iTvleba, rom is
warmoadgens simboloebis mimdevrobas, romlebic
dajgufebulia striqonebSi, sadac TiToeuli striqoni
mTavrdeba striqonis dasasrulis simboloTi (End_of_Line),
igi warmoadgens axal striqonze gadasvlis simbolos.
teqsturi failisaTvis arsebobs wakiTxvisa da
Caweris (Read da Write) operaciis specialuri saxe
romelic saSualebas iZleva waikiTxos da Caiweros
mniSvnelobebi, romelTa ti pi gansxvavebulia simboluri
ti pisagan. aseTi mniSvneloba avtomaturad gadaiyvaneba
simbolur warmodgenaSi da piriqiT.
mag: Read (f , i), sadac i aris mTeli ti pis cvladi,
kiTxulobs cifrebis mimdevrobas, akeTebs am mimdevrobis
aTobiT ricxvebad interpretirebas da inaxavs f -Si.
rogorc adre aRvniSneT aris teqsturi ti pis ori
standartuli cvladi: INPUT da OUTPUT. INPUT
misawvdomia mxolod failis wasakiTxad. igi dakavSirebulia
operaciuli sistemis Setanis standartul failTan (es
klaviaturaa.). xolo standartuli failuri cvladi
OUTPUT misawvdomia mxolod Casaweri failisaTvis, igi
dakavSirebulia operaciuli sistemis gamotanis standartul
failTan (es aris displei.). programis Sesrulebis win
faili INPUT da OUTPUT avtomaturad ixsneba, ise
TiTqos yofiliyos Sesrulebuli Semdegi operatorebi:

78
Assign ( Input, “); Reset ( Input );
Assign (Output,”) ; Rewrite ( Output );
analogiurad, programis muSaobis dasrulebisas es
failebi avtomaturad ixureba.
sia, romelic moyvanilia mocemul nawilSi, zogierTi
standartuli procedurebisaTvis ar moiTxovs parametris
saxiT failuri cvladis cxadad Cvenebas. Tu es parametri
gamotovebulia, maSin igulisxmeba Input an Output, imis
mixedviT procedura an funqcia orientirebulia Setanaze
Tu gamotanaze.
mag: Read(X) Seesabameba Read ( Input, X)
Write(X) Seesabameba Write(Output, X)
Tu qvemoT moyvanili romelime proceduris an funqciis
gamoZaxebisas iZleviT fails, maSin es faili unda
daukavSirdes gare fails Assign proceduris meSveobiT
da gaixsnas Reset, Rewrite an Append procedurebiT.
Tu gamotanaze orientirebuli proceduris an
funqciisaTvis uCvenebT fails, romelic gaxsnili iyo Reset
proceduriT, gamova Setyobineba Secdomaze. analogiuri
Secdoma iqneba, Setanaze orientirebuli proceduris an
funqciisaTvis davasaxeloT faili, romelic gaxsnilia
Rewrite an Append procedurebiT.
procedura Append - xsnis arsebul fails dasamateblad;
procedura Eoln - fails aZlevs striqonis dasasrulis
mdgomareobas (End_of_Line);
procedura Fluch - asufTavebs gamomavali failis
bufers;
procedura Read - teqsturi failidan waikiTxavs erT
an met mniSvnelobas da mianiWebs erT an met cvlads;
procedura Readln - asrulebs igive moqmedebas, rasac
Read, Semdeg akeTebs gamotovebas failis Semdegi striqonis
dawyebamde.
funqcia SeekEof - fails aZlevs failis dasasrulis

79
funqcia SeekEoln - fails aZlevs striqonis dasasrulis
mdgomareobas;

procedura SetTextBuf - teqsturi failisaTvis niSnavs


Setana gamotanis bufers;
procedura Write - teqstur failSi Cawers erT an met
mniSvnelobas;
procedura Writeln - asrulebs igive funqcias, rasac
Write, Semdeg fails amatebs striqonis dasasrulis niSans
(end_of_line).

programaSi Seqmnilia ori faili F1 da F2, aqedan


erTSi Setanilia ricxvebi 2-dan 5-mde, meoreSi ki
Sesabamisad maTi faqtorialebi, programa kiTxulobs
monacemebs failebidan da gamoaqvs ekranze:

Program FileDemo;

var
X, Y : Integer;
F1, F2 : File Of Integer;

begin
Assign(F1, ‘Cifr’);
Assign (F2, ‘Fact’);
Rewrite (F1);
Rewrite (F2);
X := 1; Y := 1;
Repeat
X := X + 1;
Y := Y * X;
Write (F1, X); Write (F2, Y);

80
Until X > 5;
Close(F1); Close(F2);
Reset (F1); Reset (F2);
Repeat
Read (F1, X); Read (F2, Y);
Writeln(‘ricxvi=’, X, ‘ ‘, ‘faqtoriali=’, Y);
Until Eof (F1);
Close (F1); Close (F2);
Readln;
end.

programa teqstur failSi iTvlis simboloebis


raodenobas:
Program TextFileDemo;
Var
F : Text;
S : String;
sum : Longint;
begin
Writeln(‘Seitane failis saxeli’);
Readln (S);
Assign (F, S);
Reset (F);
sum := 0;
Repeat
Readln (F, S);
sum := sum + Length (S);
Until Eof (F);
Close (F);
Writeln (‘sum=’, sum);
Readln; end.

81
mdgomareobas (End_of_File);

ti pizebuli da arati pizebuli failebi.


procedurebi da funqciebi ti pizebuli da
arati pizebuli failebis damuSavebisaTvis.

arati pizebuli failebi warmoadgenen dabali donis


Setana - gamotanis arxebs, romlebic ZiriTadad gamoiyeneba
diskze arsebul nebismier failze pirdapiri mimarTvisaTvis.
(failis ti pisa da stuqturis miuxedavad). nebismieri
arati pizebuli faili aRiwereba sityviT File, atributebis
gareSe.
mag., var
datefile : file;
arati pizebuli failebisaTvis Reset da Rewrite
procedurebSi dasaSvebia damatebiTi parametris Cveneba, es
SeiZleba iyos Canaweris sigrZe. Tu igi ar aris naCvenebi
igulisxmeba 128 baiti.
Canaweris misaRebi (mizanSewonili) sigrZea 1,
ramdenadac es erTaderTi mniSvnelobaa, romelic saSualebas
iZleva zustad gamovsaxoT nebismieri failis zoma. (roca
Canaweris sigrZea 1, maSin failebi ver iqneba arasruli
Canawerebi anu Canaweri naklebi sigrZiT).
arati pizebuli failebisaTvis dasaSvebia gamoyenebul
iqnes nebismieri standartuli procedura, romelic
gamoiyeneba ti pizebul failebSi, garda Read da Write
procedurebisa. amaT nacvlad aq gamoiyeneba Sesabamisad
procedurebi:
BlockRead da Blockwrite, romelic monacemebis maRali
siswrafiT gadacemis saSualebas iZleva;
procedura BlockRead - failidan kiTxulobs erT an
met Canawers;
procedura BlockWrite - cvladidan failSi Cawers

82
erT an met Canawers;
teqsturi failis garda, nebismieri tipis failuri
cvladisaTvis dasaSvebia Semdegi procedurebisa da
fuqciebis gamoyeneba:
FilePos - gvaZlevs failis mimdinare pozicias;
FileSize - gvaZlevs failis mimdinare zomas;
Seek - iZlva failze pirdapiri mimarTvis saSualebas;
Truncate - CamoaWris fails mocemul poziciamde.

procedurebi.

ganvixiloT Wadrakis dafis gamosaxulebis beWdvis programa.


Program ChekerPrint ;
uses
Forms ;
begin
Writeln (‘ | | ‘) ;
Writeln (‘ ——`) ;
Writeln (‘ | | ‘) ;
Writeln (‘——`) ;
Writeln (‘ | | ‘) ;
Writeln (’daaWireT enter – s programis dasrulebisaTvis’);
Readln; end.
rogorc vxedav erTi da igive brZanebis ganmeoreba gviwevs
ramodenimejer. vnaxoT am dros ra rols iTamaSebs
procedura.
Program checkerPrint ;
uses
Forms ;
{yvela gamocxadeba const, var, type ganTavsdeba aq}
Procedure DoVerticals ;
begin

83
Writeln (‘ | | | | |‘) ;
end ;
Procedure DoHorizontals;
begin
Writeln (‘————‘) ;
end ;

begin
DoVerticals ;
DoHorizontals ;
DoVerticals ;
DoHorizontals ;
Writeln (‘daaWireT enter – s programis dasrulebisaTvis’) ;
readln ; {enter – is daWeramde Ria rom iyos fanjara} ;
end.
programaSi Seqmnilia ori procedura, erTi
horizontaluri xazebis dasabeWdad, meore ki –
vertikaluri xazebis dasabeWdad.
proceduris Sesaqmnelad unda davweroT proceduris
saTauri, romelic Sedgeba Procedure sityvisagan da misi
unikaluri saxelisagan, Cvens SemTxvevaSi es aris DoVerticals,
DoHorizontals. procedura aris mini programa da igive
formati aqvs, rac Cveulebriv programas. saTauris Semdeg
SeiZleba gvqondes const, var da a.S. amis Semdeg modis
Sesasrulebeli nawili begin…end. proceduris gamoZaxeba
xdeba ZiriTadi programidan misi unikaluri saxelis
mixedviT. roca proceduris Sesruleba damTavrdeba, marTva
gadaecema proceduris gamoZaxebis Semdgom proceduras.
imisaTvis rom procedura iyos ufro moqnili,
proceduras unda gadaeces damatebiTi monacemebi. es
xorcieldeba proceduraze parametrebis gadacemiT.

84
DoHorizontals procedura For…Do ciklis
gamoyenebiT :
Procedure DoHorizontals (HowManyTimes : Integer) ;
var
Count : Integer ;
begin
for Count := 1 to HowManyTimes do
Writeln (‘—————‘) ;
Writeln(‘ programis dasrulebisaTvis daaWireT enter
Rilaks‘);
Readln; end .
es procedura Seicavs HowManyTimes cvlads. kods
(HowManyTimes : Integer) hqvia formaluri parametrebis
sia. es aris monacemTa sia, romelic gadaecema proceduras
yoveli gamoZaxebisas, ti pis CvenebiT. Cvens SemTxvevaSi
cvladi Integer-is ti pisaa, romelic gansazRvravs Tu
ramdenjer unda Sesruldes Writeln operatori. DoHorizontals
proceduras aqvs mTeli ti pis cvladi – HowManyTimes,
romelic gamoiyeneba proceduris SigniT. mocemul
SemTxvevaSi proceduras DoHorizontals ver gamoviZaxebT
mxolod saxeliT, aqve unda vaCvenoT faqtiuri parametrebi.
formaluri da faqtiuri parametrebi erTnairi ti pis
unda iyos.

Program ParamDemo ;
uses
Forms ;
var
Number : Integer ;
Procedure DoHorizontals (HowManyTimes : Integer) ;
var
Count : Integer ;
begin

85
for Count := 1 to HowManyTimes do
Writeln(‘————‘) ;
end ; {DoHorizontals proceduris dasasruli} ;
begin
Writeln (‘ramdeni horizontaluri xazis dabeWdva
gnebavT?’) ;
Readln (Number) ;
DoHorizontals (Number) ;
Writeln (‘ d a a W i r e T enter-s p r o g r a m i s
dasrulebisaTvis’) ;
Readln ;
end.

rodesac es programa DoHorizontals iZaxebs,


proceduras gadaecema Number cvladi. es cvladi faqtiuri
parametria. Number-is Semcveloba gadakopirdeba
DoHorizontals proceduraSi da moTavsdeba HowManyTimes
cvladSi. rodesac procedura daamTavrebs muSaobas,
HowManyTimes cvladSi monacemebi qreba, vinaidan es
lokaluri cvladebi nadgurdebian proceduridan
gamosvlisas.
Tu proceduraSi gamoyenebulia ramdenime parametri,
mniSvnelovania maTi mimdevrobis dacva.
ganvixiloT programa proceduraze ramdenime
parametris gadacemiT :
Program JunkDemo ;
uses
Forms ;
var
UsesNumber : Integer ;
UsersString : String ;
Procedure Junk (Number : Integer ; Stuff : String) ;
begin

86
Writeln (‘Number-is raodenoba udris’ , Number) ;
Writeln(‘String striqoni udris’, Stuff) ;
end ; {Procedure Junk} ;

begin
Write (‘SeitaneT Tqveni striqoni’) ;
Readln (UsersString);
Write (‘SeitaneT ricxvi’) ;
Readln (UsersNumber) ;
Junk (UsersNumber, UsersString) ;
Writeln ;
Readln ;
end.

es programa Junk proceduras gadascems or


arguments mimdevrobis dacviT. SeiZleba gadavceT ara
marto cvladi, aramed simboluri mudmivac. magaliTad
gamoZaxebas SeiZleba hqondes saxe : Junk (3,’Hello World‘).

funqciebi

funqcia proceduris msgavsia im TvalsazrisiT, rom


masSic saWiroa parametrebis gadacema. gansxvaveba imaSia,
rom funqcia abrunebs mxolod erT mniSvnelobas. funqcia
abrunebs am mniSvnelobas TviTon funqciis saxeliT.
ganvixiloT kvadratSi ayvanis funqciis magaliTi,
sadac Cans rogor xdeba funqciis gamoZaxeba

Program FunctionDemo ;
uses
Forms ;
var

87
UserInput : Integer ;
begin
Write(‘SeitaneT ricxvi, romlis kvadratSi ayvana
gsurT’) ;
Readln (UserInput) ;
Writeln (UserInput, ‘ kvadratSi tolia’, Sqr
(UserInput)) ;
Writeln (‘d a a W i r e T enter-s p r o g r a m i s
dasrulebisaTvis’) ;
Readln ;
end.

es programa Sqr-s iyenebs da gamoTvlis Sedegi


pirdapir Caiwereba beWdvis operatoris striqonSi.
procedura ase ver moiqceoda Semdegi ori mizezis gamo.
jer erTi ara gvaqvs cvladi proceduris Sedegis
SenaxvisaTvis, meore ver gamoviZaxebT proceduras sxva
proceduris gamoZaxebis operatoridan.

ganvixiloT funqciis sademonstracio magaliTi :

Program FunctionDemo ;
uses
Forms ;
Function Square (TheInput : Integer) : Integer ;
begin
Square := TheInput * TheInput ;
end ;
var
UserInput : Integer ;
begin
Write (‘ SeitaneT ricxvi, romlis kvadratSi ayvana

88
gsurT’) ;
Readln (UserInput) ;
Writeln (UserInput, ‘ kvadratSi tolia’, Square
(UserInput)) ;
end.

ganxilul magaliTSi funqcia asrulebs kvadratSi


axarisxebis operacias. funqcias hqvia Square , romelic
mTeli ti pisaa. ti pis Cveneba aucilebelia, radganac
funqcias eniWeba gamoTvlis mniSvneloba. funqcia
Seufasebeli instrumentia maTematikuri gamoTvlebis
Casatareblad, grafikis SesrulebisaTvis da a.S.

qveprogramebi .
standartuli qveprogramebi

standartuli qveprograma miekuTvneba im


qveprogramebs, romlebic misawvdomia maTi aSkara aRweris
gareSe. MmaT miekuTvneba qveprogramebi, romlebic asruleben
operaciebs striqonul sidideebze, Ooperatiuli
mexsierebis dinamiuri marTvis qveprogramebi da
qveprogramebi, romlebic axorcieleben Setana-gamotanis
operaciebs.
aseT qveprogramebs miekuTvneba ekranuli da
specialuri qveprogramebi, ariTmetikuli da skalaruli
funqciebi, asaxvis funqciebi da damatebiTi funqciebis
sakmaod didi jgufi.

Pprocedura DDelay
sintaqsi: Delay (Time)

Time –mTeli ti pis gamosaxulebaa.


Pprocedura Delay Sewyvets programis Sesrulebas

89
Time miliwamis ganmavlobaSi. Tu Time-s aqvs uaryofiTi
mniSvneloba, iTvleba, rom mas aqvs mniSvneloba_0.

Pprocedura: Randomize
sintaqsi: Randomize

procedura Randomize uparametroa. Ees


procedura SemTxveviTi ricxvebis generatorSi daayenebs
SemTxveviT dawyebiT mniSvnelobas.

ariTmetikuli funqciebi

Ffunqcia abs
sintaqsi: abs(num)

Num - real an integer-is ti pis gamosaxulebaa. Ees


funqcia iZleva Num-is absolutur mniSvnelobas. Sedegi
igive ti pisaa, rogorc argumenti.
Mmag. abs(-2)=2
abs(pi)=3.144926536

funqcia ArcTan
sintaqsi: ArcTan(Num)
Num - real an integer - is ti pisaa. Ffunqcia ArcTan
gvaZlevs kuTxis namdvil mniSvnelobas, romlis tangensi
aris Num.
Mmag. ArcTan(0)=0.0
ArcTan(pi)=0.7853981634

F funqcia Cos
sintaqsi: Cos( Num)
Num aris real an integer-is ti pis gamosaxuleba. Ffunqcia

90
Cos iZleva Num kuTxis kosinusis namdvil mniSvnelobas
Mmag. cos(0)=1.0
cos(pi)=-1.0

funqcia Exp
sintaqsi: Exp(Num)
Num - real an integer-is ti pis gamosaxulebaa. funqcia
Exp gvaZlevs Num- is eqsponentis namdvil mniSvnelobas:

Ffunqcia Frac
sintaqsi: Frac(Num)
Num aris real an integer-is ti pis gamosaxuleba.
Ffunqcia Frac gvaZlevs namdvil ricxvs, romelic warmoadgens
Num-is wilad nawils.
Mmag. Frac(3)=0.0
Frac(Pi)=0.1415926536

Ffunqcia Int
sintaqsi: Int(Num)
Num - real an integer-is tipis gamosaxulebaa. Ffunqcia
Int gvaZlevs namdvil ricxvs, romelic warmoadgens Num-is
mTel nawils.
Mmag. Int(2)=2.0
Int(Pi)=3.0

Ffunqcia Ln
sintaqsi: Ln(Num)
Num - real an integer-is tipis gamosaxulebaa. Ffunqcia
Ln gvaZlevs Num-dan naturaluri logariTmis
mniSvnelobas.
Mmag: Ln(1)=0.0
Ln(3)=1.0986122887
F

91
funqcia Sin
sintaqsi: Sin(Num)
Num - real an integer-is tipis gamosaxulebaa. Ffunqcia
Sin gvaZlevs Num argumentidan sinusis mniSvnelobas.
Mmag: Sin(0)=0.0
Sin(Pi/2)=1.0
F
funqcia Sqr
sintaqsi: Sqr(Num)
Num - real an integer-is tipis gamosaxulebaa. Ffunqcia
Sqr gvaZlevs Num-is kvadratSi ayvanis Sedegad miRebul
mniSvnelobas.
Mmag: Sqr(2)=4
Sqr(2.0)=4.0
F
funqcia Sqrt
sintaqsi: Sqrt(Num)
Num - real an integer-is tipis gamosaxulebaa. Ffunqcia
Sqrt gvaZlevs Num-dan kvadratuli fesvis mniSvnelobas.
Mmag. Sqrt(4)=2
Sqrt(4.0)=4.0

Ggardaqmnis funqciebi
F
funqcia Odd
sintaqsi: Odd(Num)
Num mTeli ti pis gamosaxulebaa. Ffunqcia Odd
gvaZlevs Boolean ti pis mniSvnelobas, Tu Num aris kenti
ricxvi, maSin funqciis mniSvneloba aris True, winaaRmdeg
SemTxvevaSi false.
Mmag: Odd(3)=true
Odd(4)=false

92
Ffunqcia Pred
sintaqsi: Pred(Num)
Num nebismieri martivi ti pis gamosaxulebaa.
Ffunqcia Pred gvaZlevs Num-is wina mniSvnelobas.
Mmag: Pred(‘b’)=’a’
Pred(-20)=-21

funqcia Succ
sintaqsi : Succ(Num)
Num nebismieri martivi ti pis gamosaxulebaa.
Ffunqcia Succ gvaZlevs Num-is momdevno mniSvnelobas.
Mmag: Succ(false)=true
Succ(0)=1
F
funqcia Chr
sintaqsi: Chr(Num)
Num mTeli ti pis gamosaxulebaa. Ffunqcia Chr
gvaZlevs Char tipis gamosaxulebas, romlis kodi mocemulia
Num gamosaxulebiT.
Mmag: Chr(65)=’A’
Chr(27)=^[

funqcia Ord
sintaqsi: Ord(Num)
Num nebismieri martivi ti pis gamosaxulebaa.
Ffunqcia Ord gvaZlevs Num sididis ricxviT mniSvnelobas.
Mmag: Ord(true)=1
Ord(-2)=-2

Ffunqcia Round
sintaqsi: Round(Num)
Num - real ti pis gamosaxulebaa.
Ffunqcia Round amrgvalebs Num-s uaxloes mTel

93
ricxvamde.
mag: Round(5.5)=6
Round(-1.5)=-2

funqcia Trunc
sintaqsi: Trunc(Num)
Num - real ti pis gamosaxulebaa.
Ffunqcia Trunc gvaZlevs Num sididis mTel nawils,
e.i amrgvalebs Num ricxvs, mTeli nawilis CamoSorebis
xarjze.
Mmag: Trunc(3.14)=3
Trunc(-2.9)=-2

sxva funqciebi

funqcia Include
sintaqsi: Include(m, i) - m-s gazrdis i erTeuliT.
mag. Include (m, 2) - eqvivalenturia m := m + 2
Canawerisa.

funqcia Exclude
saintaqsi: Exclude(m, i) - m-s Seamcirebs i erTeuliT.
M mag. Exclude(m, 2) - eqvivalenturia m := m - 2
Canawerisa.

grafikis safuZvlebi
teqsturi da grafikuli reJimebi

monitori SeiZleba muSaobdes 4 teqsturi reJimidan


an 3 grafikuli reJimidan erT_erTSi.
teqstur reJimSi monitoris ekrani dayofilia 25

94
striqonad, TiToeul striqonSi aris 40 an 80 pozicia. am
poziciebze SeiZleba ganaTdes ASCI I kodis simboloebi.
Ggrafikul reJimSi monitoris ekrani dayofilia
wertilebad. ekrani Sesdgeba 200 xazisagan. TiTo
xazSi SeiZleba iyos 320 an 640 wertili.
teqstur da grafikul reJimebSi aris feris Secvlis
saSualeba.
Fferebis konstantebi:
Const

Bleck =0; {Savi}


Blue =1; {lurji}
Green =2; {mwvane}
Cyan =3; {firuzisferi}
Red =4; {wiTeli}
Magenta =5; {Jolosferi}
Brown =6; {yavisferi}
LightGray =7; {Ria-nacrisferi}
DarkGray =8; {muqi nacrisferi}
LightBlue =9; {Ria cisferi}
LightGreen =10; {Ria mwvane}
LightCyan =11; {Ria firuzisferi}
LightRed =12; {Ria wiTeli}
Light Magenta =13; {Ria Jolosferi}
Yellow =14; {yviTeli}
White =15; {TeTri}
Blink =128; {cimcimi}
Fferebi warmodgenilia maTi nomrebiT 0-dan 15-is
CaTvliT, iolad, rom iyos identirebuli TiToeuli feri,
ferTa nacvlad SeiZleba gamoyenebul iqnas mocemuli
mudmivebi. Fferad teqstur reJimSi TiToeuli simbolos
feri amoirCeva 16 feridan, xolo fonis feri ki 8 feridan,
TiToeuli simbolos feri SeiZleba iyos cimcima.

95
procedurebi da funqciebi teqsturi
reJimisaTvis

teqstur reJimSi gasvlisaTvis saWiroa Sesruldes


procedura: TextMode
procedura TextMode

sintaqsi: TextMode (BW40)


TextMode(C40)
TextMode(BW80)
TextMode(C80)
TextMode
BW40, C40, BW80 da C80 mTeli tipis konstantebis
saxelebia, romelTa mniSvneloba Sesabamisad udris 0, 1, 2
da 3.
TextMode p r o c e d u r a BW40 p a r a m e t r i T
uzrunvelyofs Sav-TeTri teqsturi reJimis dayenebas,
romlis striqonis sigrZea 40 simbolo.
TextMode procedura C40 parametriT uzrunvelyofs
feradi teqsturi reJimis dayenebas, romlis striqonis
sigrZea 40 simbolo.
TextMode procedura BW80 parametriT
uzrunvelyofs Sav-TeTri teqsturi reJimis dayenebas,
romlis striqonis sigrZea 80 simbolo.
TextMode procedura C80 parametriT uzrunvelyofs
feradi teqsturi reJimis dayenebas, romlis striqonis
sigrZea 80 simbolo.
Pprocedura TextMode , uparametrod, aRadgens bolo
teqstur reJims.
teqsturi reJimis dayenebas mivyavarT ekranis
gasufTavebamde, anu ekranis sicarieliT Sevsebamde. Kkursori

96
gadaadgildeba ekranis zeda marcxena kuTxeSi.
Pprocedura ClrEol - asufTavebs yvela simbolos
dawyebuli kursoris poziciidan striqonis bolomde,
kursoris gadauadgileblad.
Pprocedura ClrScr-asufTavebs ekrans da moaTavsebs
kursors marcxena zeda kuTxeSi.
Pprocedura DelLine –waSlis striqons, romelzedac
imyofeba kursori da yvela danarCen striqonebs
gadaaadgilebs erTi striqoniT zemoT. Qqveda striqoni
sufTavdeba.
P p r o c e d u r a GotoXY a s r u l e b s k u r s o r i s
pozicionirebas, X-horizontaluri poziciaa, Y-vertikaluri
poziciaa.
Pprocedura InsLine Casvams cariel striqons
kursoris mdebareobis adgilas.
procedura TextBackground irCevs fonis fers.
procedura TextColor irCevs simbolos fers.
funqcia WhereX -kursoris mimdinare poziciisaTvis
(romelic ekuTvnis mimdinare fanjaras) iZleva X
koordinatas. X warmoadgens horizontalur
pozicias.Ffunqcia WhereY - kursoris mimdinare
poziciisaTvis (romelic ekuTvnis mimdinare fanjaras),
iZleva Y koordinatas. Y warmoadgens vertikalur
pozicias.Pprocedura Window ekranze gansazRvravs teqstur
fanjaras.

fanjris gansazRvra teqstur reJimSi

moduli crt uzrunvelyofs fanjris gamoyenebis


ubralo, magram sakmaod mZlavr formas. Pprocedura Window
saSualebas iZleva ganvsazRvroT ekranis romel adgilas
aris fanjara. Aam fanjaraSi Cawera igivea, rogorc mTel

97
ekranze. Ee.i. ekranad igulisxmeba mocemuli fanjara. Aam
dros ekranis sxva danarCeni nawili xeluxlebelia. sxva
sityvebiT rom vTqvaT, ekranis sxva nawilSi mimarTva ar
xdeba. Ffanjris SigniT SeiZleba davamatoT da wavSaloT
striqoni, am dros kursori brundeba marjvena kuTxeSi da
kursoriT bolo striqonamde miRwevisas teqsti
gadaadgildeba zemoT.
Eekranis yvela koordinata, imaT garda, romlebic
gamoiyenebian fanjris gansazRvrisaTvis, miekuTvnebian
mimdinare fanjaras ekranis koordinata (1, 1) Seesabameba
ekranis zeda marcxena kuTxes (dumiliT, fanjrad iTvleba
mTeli ekrani)

procedurebi da funqciebi grafikuli


reJimisaTvis

m o d u l i Graph 5 0 - z e m e t i g r a f i k u l i
programebidan, realizacias ukeTebs mTel biblioTekas,
dawyebuli maRali donis funqciebisa da procedurebis
gamoZaxebiT, rogoricaa mag:
SetViewPort, Bar3D, DrowPoly, d a m T a v r e b u l i
programebiT, romlebic orientirebulia bitebTan muSaobaze.
Mmag: rogoricaa GGetImage an PutImage. reJims aqvs sxvadasxva
Sefardeba, xazis ti pebi da sxvadasxva Sriftebi, romlebic
SeiZleba Seicvalos sididiT, orientirebul iqnas
horizontalurad da vertikalurad.
SeTanxmebiT ekranis zeda marcxena kuTxes aqvs
koordinata (0,0) marjvniv gadaadgilebisas X koordinata
imatebs, xolo Y imatebs qvemoT gadaadgilebiT.
moviyvanoT magaliTi, romelic uCvenebs Tu rogor
unda gadavideT grafikuli reJimidan teqsturSi da piriqiT:

98
1. Program GraphTest;
2. Uses
3. Graph;
4. Var
5. GraphDriver : Integer;
6. GraphMode : Integer;
7. ErrorCode : Integer;
8. begin
9. GraphDriver : = Detect; {grafikuli reJimis
amocnobis droSis dayeneba}
10. InitGraph (GraphDriver, GraphMode, ‘c:\Drivers’);
{grafikuli reJimis inicializacia anu
sawyisi pirobebis momzadeba}
11. ErrorCode: = GraphResult;
12. If ErrorCode < > grOK then { Secdomaa}
13. Begin
14. Writeln(‘grafikis Secdomaa:’,
GraphErrorMsg(ErrorCode);
15. Writeln (‘programam avariulad daasrula
muSaoba’);
16. Halt (1); {aCerebs programis Sesrulebas da marTvas
gadascems operaciul sistemas}
17. End;
18. OutText (‘grafikuli reJimi. daaWireT <Enter>-s’);
19. Readln;
20. Restore CrtMode;
21. Write (‘teqsturi reJimia. daaWireT <Enter>-s’);
22. Readln;
23. SetGraphMode (GraphMode); {grafikul reJimSi
gadasvla}
24. OutText (‘kvlav grafikuli reJimia. daaWireT
<Enter>-s’);
25. Readln;

99
26. CloseGraph; {grafikuli reJimis daxurva}
27. End. {GraphTest}

aRvniSnoT, rom procedura SetGraphMode-s gamoZaxeba


(23 striqonze), Semoitans yvela grafikul parametrs
(palitras, mimdinare maCvenebels, ZiriTad da fonur ferebs
da a. S.) da maT mianiWebs Sesabamis mniSvnelobebs.

procedura Arc xatavs rkals sawyisi kuTxidan


saboloo kuTxemde; wertili (X,Y) miRebulia rkalis
centrad. Caweris sintaqsi:

Arc (x,y: integer; sawyisi kuTxe, saboloo kuTxe, radiusi:


word);
x, y aris centris koordinatebi.
sawyis kuTxed miRebulia 0, xolo saboloo kuTxed
_ maqsimum 359.
mag: for i: = 1 to 5 do
arc (100, 100, 0, 89, i * 10);
xatavs 5 koncentrul rkals.

procedura circle xatavs wres, romlis centria


wertili (x, y) sintaqsi: circle (x, y, rad);
x, y centris koordinatebia, Rad ki wris radiusia.
mag: Circle (100, 100, 200);

procedura CloseGraph grafikul reJims xuravs.


procedura DetectGrafh amoicnobs aparaturas da gansazRvravs
romeli grafikuli draiveri da reJimi unda iqnas
gamoyenebuli.

procedura Ellipse xatavs elifss sawyisi kuTxidan


saboloo kuTxemde. (x, y) wertili centris koordinatebia.

100
sintaqsi:
Ellipse (x, y : integer; sawyisi kuTxe, saboloo kuTxe: Word;
radiusi X, radiusi Y : word);
(x, y) - elifsis centris koordinatebia.
radiusi X da radiusi Y-Hhorizontaluri da vertikaluri
RerZebia.

procedura DrawPoly xatavs mravalkuTxeds, mimdinare


xazis ti pisa da feris gamoyenebiT.
sintaqsi:
DrawPoly (koordinatebis raodenoba: Word; wveroebis
koordinatebi);
koordinatebis raodenoba _ aris mravalkuTxedis
wveroebis raodenoba.
wveros koordinatebi _ aris yvela wveros koordinata,
romlebic ganisazRvrebian X, Y parametrebiT.

procedura FillPoly - aferadebs mravalkuTxeds;


procedura FloodFill - Seaferadebs SezRudul adgilebs,
mimdinare feris gamoyenebiT.
sintaqsi:
Floodfile (x, y , sazRvrebi : Word);
x, y wertili aris gasaferadebeli ares Sida wertili.
~sazRvrebi~-gansazRvravs fers. Tu x, y aris Caketili
ares SigniT, maSin Seferaddeba Siga are, Tu wertili imyofeba
Caketili ares gareT, maSin Seferaddeba misi gare nawili.

funqcia GetBkGolor - gvaZlevs fonis feris mimdinare


mniSvnelobas.

funqcia GetColor - daabrunebs naxatis mimdinare fers.

funqcia GetGraphMode - abrunebs mimdinare grafikul

101
reJims.

funqcia GetMaxX - mimdinare grafikuli draiverisa


da reJimisaTvis gvaZlevs yvelaze marjvena svets.

funqcia GetPixel - gvaZlevs gamosaxvis elementis


mniSvnelobas (x, y) wertilSi.
sintaqsi:
GetPixel (x,y: integer); gvaZlevs x, y wertilSi gamosaxvis
elementis fers.

funqcia GetX - gvaZlevs mimdinare poziciis X


koordinatas.

funqcia GetY - gvaZlevs mimdinare poziciis Y


koordinats.

procedura Line - xatavs swor xazs (X1, Y1) wertilidan,


(X2, Y2), wertilamde.
proceduris Caweris sintaqsi:
Line (X1,Y1, X2,Y2 : integer);
X1, Y1 - sawyisi wertilis koordinatebia;
X2 , Y2 - saboloo wertilis koordinatebia;

procedura OutText - striqons agzavnis gamotanis


mowyobilobaze, dawyebuli mimdinare maCveneblidan.

procedura OutTextXY - striqons agzavnis gamotanis


mowyobilobaze.

procedura PieSlice - xatavs seqtors, (X,Y) aris centri,


seqtori ixateba sawyisi kuTxidan saboloo kuTxemde.

102
procedura PutPixel - agebs gamosaxvis elements
(wertils), x, y wertilSi.
sintaqsi:
PutPixel (X,Y : integer; feri : Word);
X, Y - wertils koordinatebia.
feri - wertilis feria.

p r o c e d u r a Rectangle - x a t a v s m a r T k u T x e d s
(sworkuTxeds) mimdinare ferisa da xazis tipis gamoyenebiT.
sintaqsi:
Rectangle (X1, Y1, X2, Y2 : integer);
X1, Y1 - zeda marcxena kuTxis koordinatebia;
X2, Y2 - qveda marjvena kuTxis koordinatebia;

procedura RestoreCrtMode - aRadgens ekranis sawyis


reJims, romelic dayenebuli iyo grafikis inicializaciamde.
aRadgens sawyis videoreJims, romelic Seiqmna InitGraph
proceduriT. es procedura SeiZleba gamoyenebul iqnes
procedura SetGraphMode - sTan erTad teqstur da
grafikul reJimebs Soris gadarTvisas.

procedura SetBkColor - palitris gamoyenebiT


daayenebs mimdinare fonis fers.
sintaqsi:
SetBkColor (feri: word); feri amoirCeva 0 - dan 15
diapazonSi.

procedura SetColor - palitris gamoyenebiT daayenebs


naxatis mimdinare fers.
sintaqsi:
SetColor (feri: word);

procedura SetGraphMode - sistemas gadarTavs

103
grafikul reJimSi da wmends ekrans.

procedura SetLineStyle - daayenebs xazis mimdinare ti ps


da mis sisqes.
sintaqsi:
SetLineStyle (striqonis ti pi: word; nimuSi: word; sisqe:
word);

xazis ti pebi:
Solidln = 0; {uwyveti xazi}
Dottedln = 1; {xazi wertilebisgan}
Centerln = 2; {xazi wertilisa da tiresagan}
Dashedln = 3; {punqtiris xazi}
VserDilhn = 4; {momxmareblis mier SerCeuli ti pi}
funqcia TextHeight - gvaZlevs striqonis simaRles.
sintaqsi: TextHeight ( teqsti-striqoni: string) gamoiyeneba
striqonebs Soris intervalis gansazRvrisaTvis.
funqcia: TextWidth gvaZlevs striqonis siganes gamosaxvis
elementebSi.
sintaqsi: TextWidth (teqsti-striqoni: string); es sasargebloa
gamoviyenoT striqonebs Soris intervalis gamoTvlisas.

xmovani signali

IBM PC - Si xmebis SezRuduli saSualebebia. isini


Semoifargleba gansazRvruli sixSiris xmebis miRebiT an
xmis gamoTiSviT.
procedura : Sound
sintaqsi : Sound (Num)

104
Num - mTeli ti pis gamosaxulebaa. Sound proceduriT
miiReba monotonuri xmis signali Num herci sixSiris.
procedura: NoSound
sintaqsi: NoSound

am proceduriT Sewydeba xma, romelic miRebulia Sound


proceduriT.

mag: program Note 400;


Begin
Sound (400);
Delay(2000);
NoSound;
end.

es programa gamoiZaxebs 400 herci sixSiris xmovan


signals, romelic grZeldeba 2 wamis ganmavlobaSi.
procedura Delay (miliwm : word) akeTebs dayovnebas
miliwamis ganmavlobaSi.

105
programas, turbo paskalis teqsturi reJimis gamoyenebiT,
gamoaqvs teqsti ekranis sxvadasxva adgilas, fonisa da
simboloebis feris SerCeviT.
U
Uses
crt;

begin
Clrscr;
Textcolor (Red);
Textbackground (Green);
Writeln (‘Izabela’);
GotoXY(5, 10);
Textcolor (Magenta);
Textbackground (Blue);
Writeln (‘Justina’);

GotoXY(10, 20);
Textcolor (Yellow);
Textbackground (red);
Writeln (‘Meison’);

Readln;
end.

106
programa teqstur reJimSi xsnis fanjaras:

Uses
Crt;

Var
K : Integer;

begin
Textbackground (Blue);
Window (5, 2, 35, 17);
Textcolor (Yellow);
For K := 1 To 100 Do
Write (‘Press....enter.....’);
Readln;
Clrscr;

Textbackground (Red);
Textcolor (White);
Window (40, 2, 70, 17);
For K := 1 To 100 Do
Write(‘Press...enter...’);
Readln;
end.

107
programa agebs naxazs grafikuli reJimis gamoyenebiT:

Program GraphDemo;

Uses
Crt, Graph;

Var
i, j, k, Graphdriver, GraphMode : Integer;
Xa, Ya : Word;

begin
Clrscr;
GraphDriver := detect;
InitGraph (GraphDriver, GraphMode, ‘’);
For i := 1 To GetmaxX Do For j := 1 To
GetmaxY Do
Putpixel (i, j, 5);
Setcolor (4);
SetlineStyle (SolidLn, 0, thickwidth);
For i := 1 To 200 Do
Circle(GetmaxX div 2, GetmaxY div 2, i);
Setcolor(10);
For i := 1 To 100 Do
Arc (GetmaxX div 2, GetmaxY div 2, 0, 90, i );
Rectangle (220, 230, 350, 360);
OuttextXY(465, 40, ‘aspect ratio’);
Getaspectratio(Xa, Ya);
Setbkcolor (11);
Setfillstyle (9, 11);
i := 0;
j := 0;

108
Repeat
Ellipse (i, j, 0, 360, 60, 40);
i := i + 20; j := j + 20 Until j = 300;
For k := 1 To 10 Do begin
Sound (100 * k +k * 200);
delay (500);
nosound; end;
Repeat until keypressed;
Closegraph;
end.

programa gamoscems sxvadasxva sixSiris musikalur


signals:

Program MusicDemo;
Var
I : Integer;

begin
For I := 1 To 10 Do begin
Sound (I * 200);
Delay (5000);
Nosound;
end;

For I := 10 Downto 1 Do begin


Sound (I * 200);
DDelay (5000);
Nosound;
end;
end.

109
DELPHI.

Delphi danarTis Seqmnis swraf saSualebas iZleva. igi


dafuZnebulia Object Pascal – ze. Delphi dammuSavebels aZlevs
moqnilobis saSualebas. misi kompilatorebi, romlebic
paskalis ojaxis enebidan aris warmoSvebuli, iTvlebian
erT-erT yvelaze swraf kompilatorebad. Borland - ma enas
daamata obieqtur-orientirebuli gafarToeba programirebis
saukeTeso stilis misaRebad.

moduli.

moduli (unit) udidesi gamogonebaa. moduli es aris


erTmaneTTan dakavSirebuli funqciebisa da procedurebis
jgufi.
ganvixiloT martivi moduli ;

unit SayStuff ;
begin
procedure SayHello ;
begin
Seiqmnas fanjara ;
davweroT fanjaraSi ~gamarjoba~;
gavanadguroT fanjara;
end ;

procedure SayBye ;
begin
Seiqmnas fanjara ;
davweroT fanjaraSi ~naxvamdis~;
gavanadguroT fanjara;
end ;

110
procedure SayNothing;
begin
Seiqmnas fanjara ;
davweroT fanjaraSi ~araferi~;
gavanadguroT fanjara;
end ;
end ; {moduli SayStuff}
erTaderTi rac gavakeTeT aris is rom sami
procedura movaTavseT erT jgufSi da davarqviT saerTo
saxeli – SayStyff. Tu Cven dagvWirdeba sxva proeqtSi
aRniSnuli procedurebis gamoyeneba, unda davweroT : Use
SayStyff .
modulis formati :

UUnit YourNameHere ;

interface
uses …

const…
type …
var …
procedure …
function …

implementation
uses …
Label …
const …
type …
var …
procedure …
function …

111
initialization {araaucilebeli ganyofileba}
begin
…..
end ;

finalization {araaucilebeli ganyofileba}


begin
….
end ;

end. {modulis dasasruli}

interface – s nawili aris pirveli, aq ganisazRvreba


cvladebi, mudmivebi. am nawilSi moTavsebulia procedurebisa
da funqciebis saTaurebi.

implementation ganyofilebaSi moTavsebulia is


cvladebi da mudmivebi, romlebsac gamoiyeneben am
ganyofilebis mxolos funqciebi da procedurebi.
implementation ganyofilebaSi iwereba im funqciebisa da
procedurebis teqstebi, romlebic gamocxadebul iyo
interface nawilSi.

initialization ganyofileba araaucilebelia, magram masSi


SeiZleba ganisazRvros cvladebis mniSvneloba. saqme imaSia,
rom interface nawils ara aqvs Sesrulebadi nawili da
cvladebs ar SegviZlia mivceT sawyisi mniSvnelobebi. aseT
saSualebas iZleva initialization ganyofileba. aq SeiZleba
gavukeToT inicializacia cvladebs Caneweris struqturas,
failur cvladebs da yvelafers romelTaTvisac saWiroa
sawyisi mniSvnelobebis miniWeba.
finalization ganyofilebas aqvs sawinaaRmdego

112
daniSnuleba. igi saSualebas iZleva daixuros failebi,
ganTavisufldes mexsiereba da Catardes sxva damasrulebeli
operaciebi. finalization ganyofileba sruldeba ukumimdevrobiT
initialization ganyofilebasTan damokidebulebaSi. magaliTad,
Tu inicializacia gaukeTda modulebs Semdegi mimdevrobiT :
X, Y, Z, maSin isini daixurebianN Semdegi mimdevrobiT : Z,
Y, X.
qvemoT moyvanilia moduli, romelic saWiroa Seiqmnas,
raTa Sesruldes ramdenime martivi maTematikuri funqcia.

Unit MatsStuff ;

Interface
Function AddTwoNumbers (One, Two : Integer) : Integer ;
Function SubtractTwoNumbers (One, Two : Integer) :
Integer ;
Function SubtractTwoNumbers (One Two, : Integer) :
Integer ;
Procedure PositiveKarma ;
implementation
Function AddTwoNumbers (One, Two : Integer) : Integer ;
begin
AddTwoNumbers := One + Two ;
end ;
Function SubtractTwoNumbers (One, Two : Integer) :
Integer ;
begin
SubtractTwoNumbers := One – Two ;
end ;
Function SubtractTwoNumbers (One, Two : Integer) :
Integer ;
begin
SubtractTwoNumbers := One – Two ;

113
end ;
procedure PositiveKarma ;
begin
Writeln (‘Tqven SegiZliaT amis gakeTeba,
maTematika ar aris rTuli’) ;
end ;
end. {MathStuff Unit}
interface nawilSi Cven ganvsazRvreT is funqciebi da
procedurebi, romlebic mocemuli modulis
momxmareblisaTvis aris misawvdomi. implementation nawilSi
Cven SevqmeniT is, rac gamovacxadeT interface nawilSi.
procedura PositiveKarma dawerilia maTTvis, visac ar uyvars
maTematika.
dawerili modulis gamoZaxebisaTvis, igi ubralod
unda CairTos ZiriTadi programis Uses winadadebaSi.
modulis gamoyeneba :
Program MathDemo ;

uses
MathStuff ;
var
A, B : Integer ;
begin
A := 1 ;
B := 2 ;
Writeln (‘A da B – s jami tolia’ AddTwoNumbers
(A,B)) ;
Writeln (‘ programis dasrulebisaTvis daaWireT
enter – s’) ;
Readln {enter – is daWeramde fanjara rom Ria
darCes} ;
end. {MathDemo}
es programa MathStuff modulis mxolod erT

114
funqcias oyenebs, es aris – AddTwoNumbers. aRniSnuli
modulis Cvens proeqtSi Casamateblad saWiroa Sesruldes
Semdegi brZaneba : View -> Project Manager da vaWerT Add
Rilaks.

forma

delfis nebismieri danarTis safuZveli aris forma.


es aris iseTive fanjara, rogorsac vxedavT Windows – Si.
formaze unda ganTavsdes yvela komponentebi. forma SeiZleba
iyos sxvadasxva ti pis. ZiriTadad igi ori ti pisaa:
modaluri da aramodaluri. modaluri formis fanjara
aisaxeba danarTis yvela fanjris zemoT. saWiroa davxuroT
es fanjara imisaTvis, rom mivmarToT danarCen fanjrebs.
aramodaluri fanjara sxva fanjrebis zemoT ar rCeba da
amdenad, momxmarebels xels ar uSlis raTa gadaerTos
sxva fanjrebze.

formebisa da komponentebis Tvisebebi.

Tviseba es aris obieqtis atributi. adamians,


magaliTad aqvs atributebi, rogoricaa : simaRle, wona, Tvalis
feri da a.S. formas SeiZleba hqondes : simaRle, sigane,
fonis feri da a.S.

Delph-is martivi danarTi.

SevqmnaT delfis martivi danarTi. amisaTvis


SevasruloT Semdegi moqmedebebi:

1. gavuSvaT delfi ;
2. davinaxavT cariel formas, romelic

115
dasaTaurebulia FORM1 – iT , Tu es ar
Sesrulda, avirCioT meniuSi : File -> New
Application ;
3. avirCioT komponentebis palitraze (romelic
ganTavsebulia ekranis zeda marjvena kuTxeSi)
Standart gverdi;
4. davawkapunoT Button Rilakis niSanze ;
5. davawkapunoT formis SuaSi, am adgilas gaCndeba
Rilaki ;
6. orjer davawkapunoT am Rilakze ; gamoCndeba
programuli fanjara, sadac kursori
ganTavsebulia begin da end striqonebs
Soris ;
7. davweroT striqoni :
Canvas.TextOut (20, 20, ‘ programireba delfSi
Zalian martivia’) ;
8. Cven SevqmeniT Cveni pirveli danarTi,
kompilaciisa da SesrulebisaTvis vaWerT F9
Rilaks an avirCioT meniuSi : Run -> Run.

Sesrulebis Semdeg ekranze gamoCndeba fanjara (forma),


sadac Cans Cvens mier ganTavsebuli Rilaki. davaWiroT am
Rilaks da ekranze gamoCndeba is teqsti, romelic Cven
davwereT Canvas.TextOut – Si. davxuroT fanjara, risTvisac
fanjris zeda marjvena kuTxeSi davaWiroT X Rilaks,
SekiTxvaze `gsurT Tu ara proeqtis Senaxva~ vupasuxoT
`No~, rac niSnavs, rom proeqti ar SevinaxoT..

Delph-is CatvirTvisas ekrani miiRebs Semdeg saxes:

116
formas aqvs igive Tvisebebi, rogorc Windows – is
yvela fanjaras. igi Semdegnairad gamoiyureba :

117
programis Sesrulebaze gaSvebis Semdeg danarTi Semdeg
saxes miiRebs:

Button1-ze dawkapunebis Semdeg danarTi Semdegnairad


gamoiyureba:

118
komponentebis palitra

komponentebis palitra - es aris vizualuri komponen-


tebi, romlebic ganlagebulia CanarTebis saxiT:
Standard (standartuli)
Additional (damatebiTi)
Win32 (Windows 32bitiani)
Data Access (monacemebze mimarTva)
Data Control (monacemTa marTva)
Win 3.1 (Windows 3.X)
Dialogs (dialogebi)
System (sistemuri)
Qreport (angariSebis swrafi momzadeba)
ActiveX (aqtiuri elementebi ActiveX)
Samples (nimuSebi)

kodis redaqtoris fanjara.

kodis redaqtoris fanjara aris srulfasovani


programuli redaqtori. fanjris saTaurad gamodis
mimdinare failis saxeli, fanjaras SeiZleba hqondes
CanarTebi, Sua nawilSi ganTavsebulia programis teqsti,
fanjris qveda nawilSi aris sami saintereso elementi:
marcxniv ganTavsebulia striqonisa da svetis indikatori,
SuaSi – modifikaciis indikatori, Tu proeqtis Senaxvis
Semdeg gavakeTeT cvlileba, indikatorze gamoCndeba Modified
sityva. mesamea – Casmis reJimis indikatori (Insert) , romelic
uCvenebs Setanili simbolo win Caematos Tu ara.

119
obieqtebis inspeqtori.

obieqtebis inspeqtori Sesdgeba Tvisebebis gverdisa


da xdomilobebis gverdisagan.
davawkapunoT cariel formaze da davakvirdeT mis
atributebs. Tu Tvisebebis marjvniv plus niSania, niSnavs,
rom am Tvisebis SigniT igulisxmeba qveTvisebebis simravle.

120
magaliTad Tu movniSneT forma, obieqtebis inspeqtorSi
davinaxavT Font Tvisebas da plus niSans mis Semdeg. Tu
orjer davawkapunebT Font (Srifti) Tvisebaze, maSin gaixsneba
iseTi Tvisebebis cxrili rogoricaa Color (feri), Height
(simaRle), Name (saxeli) da a. S. aseTi formati xilvadi,
martivi da efeqturia obieqtis atributebis Secvlisas.

121
xdomilobebis gverdi.

xdomilobebis gverdi obieqtebis inspeqtorze meore


CanarTia. masze naCvenebia yvela xdomiloba, romelzec
reagirebs arCeuli obieqti. magaliTad, Tu Cvens programaSi
saWiroa Sesruldes romelime operacia fanjris daxurvisas,
am mizniT SeiZleba gamoyenebul iqnes OnClose xdomiloba.

122
Delphi - s menius struqtura.

ganvixiloT Delphi - s menius struqtura.

meniu File

es meniu gamoiyeneba proeqtis Seqmnis, Senaxvis,


gamoZaxebis, beWdvisa da mTeli rigi sxva operaciebisaTvis.

New

axali obieqtis Seqmna. am brZanebis arCevis Semdeg


gamodis dialoguri fanjara, romelic arCevanis saSualebas
iZleva .

New Application

axali proeqtis Seqmna. igi gulisxmobs kodis


redaqtoris axali fanjris Seqmnas axali Unit1.PAS failiT,
axali Form1 formiT da obieqtebis inspeqtoris axali
fanjriT.

New Form

axali formis Seqmna.

New Data Module

123
axali modulis Seqmna.

Open

obieqtis gaxsna. es SeiZleba iyos romelime modulis


kodi an mTeli proeqti.

ReOpen

es ganyofileba Seicavs bolo dros gamoZaxebul


failebis an proeqtebis sias.

Save

mimdinare modulis Senaxva diskze.

Save As

mimdinare modulis Senaxva axali saxeliT.

Save Project As

mimdinare proeqtis axali saxeliT Senaxva.

Save All

menius am punqtis arCeva Seinaxavs yvelafers, rac


mocemul momentSi gaxsnilia – proeqti da sxva failebi.

Close

daxuravs mimdinare kodis moduls an masTan


dakavSirebul formas. Tu igi Senaxuli ar aris, gvTavazobs

124
Senaxvas.

Use Unit
am punqtis arCeva mimdinare modulis kodSi Casvams
Uses operators im modulisaTvis, romelic gvinda
gamoviyenoT.

Add To Project

menius am punqtis arCeva proeqtSi daumatebs arsebul


moduls da masTan dakavSirebul formas.

Remove From Project

menius am punqtis arCeva saSualebas iZleva waiSalos


proeqtidan arsebuli moduli da masTan dakavSirebuli
forma.

Print

menius am punqtis arCeviT SegviZlia davbeWdoT


proeqtis arCeuli elementi.

Exit

gasvla Delphi-dan.

redaqtirebis meniu Edit

UnDelete/Undo

Tu obieqti wavSaleT UnDelete mas aRadgens, xolo

125
Tu bolo moqmedeba gavakeTeT kodis an komponentis damateba,
es punqti Undo-d gadaiqceva da gaauqmebs bolo damatebas.

Redo

es aris Undo-s Sebrunebuli moqmedeba.

Cut

es brZaneba amoWris moniSnul elements da moaTavsebs


Clipboard buferSi.

Copy

es brZaneba akopirebs moniSnul elements da


moaTavsebs Clipboard buferSi.

Paste

es bZaneba Clipboard - is Semadgenlobas Casvams mimdinare


formaSi an teqstSi.

Delete

waSlis formaze an teqstSi moniSnul elements.

Select All

gamoyofs (moniSnavs) yvela elements formaze an


modulSi.

Align to Grid

126
formaze ganTavsebul komponentebs gaasworebs badis
kuTxeebSi.

Bring To Front

gamoyofil komponentebs ganaTavsebs yvela danarCenze


maRla.

Send To Back

gamoyofil komponentebs ganaTavsebs yvela danarCenis


qvemoT.

Align

menius am punqtis rCevisas gamodis Alignment


(gasworeba) dialoguri fanjara. am fanjris opciebi
saSualebas iZlevian formaze komponentebi gavasworoT
horizontis an vertikalis mixedviT.

Size

komponentis an komponentTa jgufis zomebis Secvla.

Scale

roca formaze ganTavsebuli komponentebi an Zalian


didi zomisaa an Zalian mcire, maSin masStabirebis brZanebis
gamoyenebiT SegviZlia proporciulad SevcvaloT formaze
ganTavsebuli komponentebis masStabi.

Tab Order

127
brZanebas gamoaqvs fanjara, sadac CamoTvlilia
formaze ganTavsebuli komponentebis sia. SegviZlia
SevcvaloT maTi mimdevroba, risTvisac movniSnoT igi da
davaWiroT Rilaks ‚zemoT~ an ‚qvemoT~.

Creation Order

es brZaneba marTavs im mimdevrobas, romliTac iqmneba


aravizualuri komponentebi.

Lock Controls

Tu winaswar gamoviyenebT aRniSnul brZanebas, formaze


yvela elementi dafiqsirdeba Tavis adgilas. Cven SegviZlia
uSiSrad davawkapunoT elementze Tvisebis Sesacvlelad,
elementi ar daiZvreba adgilidan.

Zebnis meniu Search

Find

awarmoebs teqstSi simboloebis mimdevrobis Zebnas.

Find in Files

awarmoebs Zebnas yvela gaxsnil failSi.

Replace

teqstis erTi fragmentis meoreTi Secvla.

128
Search Again

es brZaneba imeorebs bolo Zebnas.

Incremental Search

avirCioT menius es punqti, Semdeg ki davbeWdoT


romelime sityva. Delphi i povis teqstSi Cvens mier
akrefili simboloebis mimdevrobas.

Go to Line Number

striqonis Setanil nomerze gadaadgileba.

Find Error

menius am punqtis daxmarebiT SegviZlia vi povoT


teqstSi bolo Secdomis adgili.

Browse Symbol

programis warmatebiT kompilaciis Semdeg SegviZlia


vnaxoT masSi gamoyenebuli nebismieri simbolo.

daTvalierebis meniu View

Project Manager

es brZaneba gaaaqtiurebs proeqtis dispetCeris


fanjaras.

Project Source

129
am brZanebas kodis redaqtoris fanjaraSi Seaqvs
proeqtis sawyisi faili.

Object Inspector

es brZaneba gaaaqtiurebs obieqtebis inspeqtors.

Alignment Palette

es brZaneba gaaaqtiurebs gasworebis palitras -


Alignment Palette.

Browser

menius es punqti gaaaqtiurebs fanjaras, romelic


saSualebas iZleva davakvirdeT obieqtebis
memkvidreobiTobisa da urTierTkavSiris models.

Breakpoints

menius es punqti gaaaqtiurebs wyvetis wertilebis


siis dialogur fanjaras.

Ccall Stack

gviCvenebs mimdevrobas, romlis mixedviT gamoiZaxeba


funqciebi da procedurebi Cvens danarTSi.

Watches

menius am punqtis daxmarebiT programis gawyobis


procesSi SegviZlia davakvirdeT cvladebis simravles an

130
gamosaxulebebs, romlebis Seicaven am cvladebs. aqve SeiZleba
ganisazRvros Tu rogori formatiT unda gamoisaxos
Sedegebi.

Threads

gviCvenebs kodis mimdinare sias, romelic mocemul


momentSi sruldeba.

Modules

gviCvenebs modulebis siis dialogur fanjaras,


romelic Seicavs proeqtSi gamoyenebul yvela moduls.

Component List

gviCvenebs komponentebis sias. Tu gvinda romelime


komponentis damateba vaWerT Add to Form da es komponenti
moTavsdeba Cvens formaze.

Window List

menius aRniSnuli punqti gamoitans yvela gaxsnili


fanjris sias, saidanac SeiZleba amovarCioT sasurveli.

Toggle Form/Unit

es brZaneba akeTebs gadarTvas formasa da moduls


Soris.

Units

gamoiZaxebs fanjaras, romelic gviCvenebs Cveni

131
proeqtis yvela modulis sias. SegviZlia avirCioT
sasurveli.

Forms

es brZaneba formebTan muSaobs zustad ise, rogorc


wina muSaobs modulebTan.

New Edit Window

menius am punqtis arCeva gaxsnis redaqtirebis axal


fanjaras, ise rom ar Seexeba winas. Cveni fanjris
redaqtirebis mimdinare moduli gamoCndeba axal fanjaraSic.
ramdenime redaqtirebis fanjris erTdroulad arseboba
ekranze saSualebas iZleva erTdroulad vnaxoT ori
modulis kodi.

SpeedBar

es brZaneba gamoaCens swraf Rilakebs, Tu isini


aqamde ar Candnen.

Component Palette

es brZaneba gamoaCens komponentebis palitras, Tu


isini aqamde ar Candnen.

proeqtis meniu Project.

Add To Project

132
menius am punqtis arCeva saSualebas iZleva proeqtSi
davamatoT arsebuli moduli da masTan dakavSirebuli
forma. roca Cven vamatebT proeqtSi moduls, Delphi
avtomaturad daamatebs proeqtis failSi Sesabamis
operators Uses. mocemuli menius punqts igive funqcia
aqvs, rogorc File -> Add To Project brZanebas.

Remove To Project

menius am punqtis arCeva saSualebas iZleva


proeqtidan amovagdoT arsebuli moduli da masTan
dakavSirebuli forma. roca amovagdebT proeqtSi moduls,
Delphi avtomaturad amoagdebs proeqtis failSi Sesabamis
Uses operators . mocemuli menius punqts igive funqcia
aqvs, rogorc File -> Remove From Project brZanebas.

Add To Repository

menius es punqti mimdinare formas daamatebs


obieqtebis sacavSi – Object Repository. es iZleva misi
xelmeored gamoyenebis saSualebas.

Compile

es brZaneba axorcielebs Cveni proeqtis yvela im


failis kompilacias, romlebic Seicvalnen programis bolo
gaSvebis momentidan.

Build All

133
es programa kompilacias ukeTebs yvela komponents,
formas, moduls imisagan damoukideblad Seicvalnen Tu
ara isini.

Syntax Check

menius es punqti saSualebas iZleva SevamowmoT


sintaqsuri Secdomebi.

Information

menius es punqti iZleva informacias kompilaciisa


da mexsierebis danaxarjebis Sesaxeb.

Options

menius es punqti gaaaqtiurebs opciebis fanjaras,


sadac SeiZleba davayenoT redaqtirebis, kompilaciisa da
sxva opciebi.

Sesrulebis meniu Run.

Run

Delphi-s danarTs gauSvebs Sesrulebaze. Tu aqamde


ar iyo Sesrulebuli kompilacia, Sesrulebaze gaSvebis
win Sesruldeba kompilacia.

Parameters

menius es punqti gamoiZaxebs dialogur fanjaras


Run, romelic im parametrebis micemis saSualebas iZleva,
romelic saWiroa danarTis gaSvebisaTvis.

134
Step Over

es brZaneba danarTis nabij-nabij Sesrulebis


saSualebas iZleva. TiToeuli operatoris mixedviT, amasTan
procedura an funqcia sruldeba ise, Tundac igi iyos
programis erTi operatori. es moxerxebulia maSin, rodesac
gvainteresebs Cveni programis moqmedeba, magram ar gvinda
CavxedoT SigniT TiToeul procedurasa da funqcias.

Trace Info

es brZanebac danarTis nabij-nabij Sesrulebis


saSualebas iZleva, Tanac nebismieri procedura da funqciac
sruldeba nabij-nabij.

Trace to Next Source Line

es brZaneba saSualebas iZleva davinaxoT Semdeg


romeli brZaneba Sesruldeba.

Run To Cursor

es brZaneba saSualebas iZleva Sesruldes Cveni


danarTi kursoris adgilamde. aq SeiZleba gamoviyenoT
Watch fanjara, im cvladis SefasebisaTvis, romlis
mniSvnelobaSic eWvi gvepareba.

Show Execution Point

SevasruloT es brZaneba, Tu davxureT redaqtirebis


fanjara da vimyofebiT programis nabij-nabij amoxsnis
procesSi. es dagvabrunebs redaqtirebis fanjaraSi, amasTan

135
kursori ganTavsebuli iqneba im operatorze, romelic
SemdgomSi Sesruldeba .

Program Pause

es brZaneba danarTis SesrulebaSi gamoiwvevs pauzas


da Cven SegviZlia mSvidad vimuSaoT Watch fanjarasTan.

Program Reset

es brZaneba Sewyvets danarTis Sesrulebas da


amotvirTavs mas mexsierebidan.

obieqtur-orientirebuli daproeqteba

obieqti aris arseba, romelsac aqvs mdgomareoba, anu


mas aqvs zogierTi mniSvneloba. obieqtis qceva ganisazRvreba
im moqmedebebiT, romlebic maTze moqmedeben. TiToeuli
obieqti aris obieqtTa klasis egzemplari .obieqtur-
orientirebuli daproeqtebis mizani mdgomareobs imaSi,
rom sistemis TiToeuli moduli realuri samyaros
obieqts an obieqtebis klass warmoadgens. sistemis
damuSaveba obieqtur-orientirebuli midgomiT mdgomareobs
SemdegSi:
1. obieqtis da maTi atributebis identifikacia;
2. identifikacia im moqmedebebisa, romlebic moqmedeben
TiToeuli obieqtis mdgomareobaze;
3. TiToeuli obieqtis xilvadobis gansazRvra sxva
obieqtebTan SedarebiT;
4. TiToeuli obieqtis interfeisis gansazRvra;
5. TiToeuli obieqtis realizacia.

136
obieqtebi

obieqtebi SeiZleba iyos Zalian didi da Sesdgebodes


mcire obieqtebisagan. interfeisSi Canan, Tu rogor
ukavSirdebian obieqtebi erTmaneTs. zustad unda
ganisazRvros mocemul obieqtTan sxva obieqtebi rogor
damokidebulebaSia.

klasebi

Delphi-Si aris darezervebuli sityva class, romelic


obieqtis aRweris saSualebas iZleva. rodesac Delphi-Si
vqmniT axal proeqts da vuyurebT Unit1-Si gamocxadebebs,
es aris ZiriTadi formis klasis gamocxadeba.
ganvixiloT klasis gamocxadebis magaliTi:

Type
TForm1 = class(TForm)
public
{gamocxadebis gaxsna}
proteqted
{daculi gamocxadeba}
private
{daxuruli gamocxadeba}
end;

modulis interface nawilSi mivuTiTebT ti pis saxels


(TForm1) da Semdeg bazur klass, saidanac igi warmoiSveba.
yvela obieqti unda iyos warmoSvebuli TObject-sagan an
erT-erTi misi STamomavlobisagan.
public nawilSi aris gamocxadeba, romelic misawvdomia

137
`gare samyarosaTvis~. private nawilSi gamocxadebulia
cvladebi, procedurebi, funqciebi, romelic gamoyenebulia,
mxolod klasis SigniT. protected nawili aris wina ori
ganxilulis saukeTeso Tvisebebis Serwyma. masSi
gamocxadebuli komponentebi misawvdomia mxolod
gamocxadebuli ti pis STamomavlobisaTvis.
SevqmnaT monacemebis sakuTari obieqti, sabanko baraTis
PIN kodis Sesanaxad. igi ase gamoiyureba:
Secret = class (TObject)
private
FThe_PIN : Integer;
end;
es kodi qmnis ara marto klass Secret saxeliT, aramed
daxurul FThe_PIN cvlads PIN mniSvnelobis Sesanaxad.

memkvidreobiToba

obieqtur-orientirebuli enis erT-erT Tvisebad


iTvleba memkvidreobiToba. igi saSualebas iZleva
warmoSvebul klasebs hqondes maTi mSoblebis klasebTan
mimarTvis saSualeba. es saSualebas iZleva aviRoT klasi,
romelSic aris yvela saWiro elementi da davumatoT mas
saWiroebis mixedviT axali obieqtebi.

Delphi – is danarTi.

erTi SexedviT TiTqos Cans, rom martivi programa


Sedgeba mxolod proeqtis failisa da programuli
modulisagan. sinamdvileSi aq aris kidev ramdenime faili.
Delphi – proeqti Sedgeba formebisagan, modulebisagan
proeqtis parametrebisagan, resursebisagan da a.S. bevri am
failTagani danarTis Seqmnisas, avtomaturad iqmnebian.
danarTis daproeqtebisas, Delphi qmnis Semdeg failebs:

138
proeqtis faili (.dpr) es faili gamoiyeneba
formebisa da modulebis Sesaxeb informaciis Sesanaxad.
modulis faili (.pas) es faili gamoiyeneba kodis
Sesanaxad. zogierTi moduli dakavSirebulia formasTan,
zogierTSi inaxeba mxolod funqciebi da procedurebi.
formis faili (.dfm) es aris faili, romelSic
inaxeba informacia Cveni formebis Sesaxeb. TiToeuli formis
fails Seesabameba modulis faili (.pas) . magaliTad
myform.pas failisaTvis arsebobs masTan dakavSirebuli
faili myform.dfm.
proeqtis parametrebis faili (.dfo) - am failSi
inaxeba proeqtis parametrebis dayeneba.
paketebis Sesaxeb informaciis faili (.drf) -
es binaruli faili Delphi – Si gamoiyeneba paketebTan
muSaobisas.
resursebis faili (.res) - es binaruli faili
Seicavs proeqtis mier gamoyenebul piktogramas. es faili
ar unda Seiqmnas da Seicvalos momxmareblis mier, radganac
Delphi mudmivad ukeTebs modificirebas am fails.
sarezervo aslebis faili (.~dp, .~df,.~pa) - es
aris proeqtis failebis, formebisa da modulebisaTvis
sarezervo aslebis faili.

failebis Semdegi jgufi iqmneba kompilatoris mier:

Sesrulebadi faili (.exe) - es Cveni danarTis


gamSvebi failia.

modulis obieqturi faili (.dcu) - es (.pas)


modulis kompilaciaze gaSvebuli failia.

Windows-is sxva failebi,romlebic gamoiyenebian Delphi


-Si:
139
sacnobaro faili (.hlp) - es daxmarebis anu sacnobaro
failia, romelic Delphi – Si gamoiyeneba.
grafikuli failebi (.wmf, .bmp, .ico) - es failebi
gamoiyenebian danarTSi lamazi interfeisis Sesaqmnelad.

proeqtis faili (.dpr)-Seicavs Object Pascal-ze daweril


kods da aris Cveni danarTis ZiriTadi nawili romliTac
iwyeba Cveni programis Sesruleba. danarTis damuSavebis
procesSi es faili Seiqmneba da modificirdeba avtomaturad.
saxeli, romelsac varqmevT proeqtis fails, xdeba gamSvebi
failis saxelic. qvemoT moyvanilia magaliTi imisa, Tu
rogor gamoiyureba faili, Tu axali proeqtis dawyebisas
Cven masSi ar SevcvaleT failisa da formis saxeli.

program Project1;
uses
Forms,
Unit1 in ‘UNIT1.PAS’ {Form 1};

{SR*.RES}

begin
Application.CreateForm(TForm, Form1);
Application.Run(Form1);
end.

moduli

arsebobs sami ti pis moduli: modulebis faili,


romlebic dakavSirebulia formebTan; programuli
modulebis failebi, romlebic gamoiyeneba procedurebisa

140
da failebis Sesanaxad; programuli modulebis failebi,
romlebic gamoiyeneba komponentebis asagebad.
moduli es aris programuli kodebis faili, .pas
gafarToebiT.
ganvixiloT moduli, romelic Delphi-Si iqmneba
dumiliT :

unit Unit1 ;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs ;

type
TForm1 = class(TForm)
procedure FormCreate (Sender: Tobject);
private
{private declarations – daxuruli gamocxadeba}
public
{public declarations – Ria gamocxadeba}
end;
var
Form1: TForm1;

implementation

{$R*.DFM}

procedure TForm1.FormCreate (Sender: TObject);


begin

141
end;
end.

axali proeqtis Seqmnisas es moduli iqmneba


avtomaturad. ganvixiloT modulis Semadgeneli calkeuli
nawilebi:
modulis saxeli – es saxeli iwereba unit sityvis
Semdeg;
inetrface – interfeisi - gamoiyeneba cvladebis
procedurebis da a.S. gamosacxadeblad;
uses - acnobebs kompilators romeli funqciebisa da
procedurebis romeli biblioTekebi gamoiyeneba Cvens failSi.
Tu vwerT sakuTar moduls da unda gamoviyenoT am modulSi
Semavali funqciebi, es moduli unda CairTos uses
operatorSi.
type – gamoiyeneba monacemTa ti pebis gamosacxadeblad.
private – daxuruli - am nawilSi gamocxadeba
misawvdomia modulis SigniT, magram miuwvdomelia modulis
gareT.
public – Ria - am nawilSi gamocxadeba Cans modulis
gareTac.
implementation – Seicavs rogorc funqciebsa da
procedurebs xdomilobebis damuSavebisaTvis, aseve Cvens
sakuTar procedurebsa da funqciebs.
{$R*.DFM} - miabavs formas Tavis .dfm fails. am
striqonis waSlam programaSi SeiZleba Seqmnas problemebi.

proeqtis magaliTi

SevqmnaT mcire zomis proeqti. pirvel rigSi SevqmnaT


proeqtis failebi :
1. failebis Sesanaxad Delphi katalogSi SevqmnaT

142
qvekatalogi. magaliTad : c:\program
files\borland\delphi 3.0\mysource.
2. SevqmnaT qvekatalogi, romelSic SevinaxavT Cvens
p r o e q t s , d a v a r q v a T Formtalk (c:\program
files\borland\delphi 3.0\mysource\formtalk)
3. gavuSvaT Delphi avirCioT brZaneba File| New,
avirCioT Application piktograma, New Items
dialogur fanjaraSi.
4. avirCioT brZaneba File|New Form, proeqtze meore
formis dasamateblad.
5. SevucvaloT Form1 formas da mis komponentebs
zogierTi Tviseba. obieqtebis inspeqtoris (Objec
Inspector) gamoyenebiT Cvens formas SevucvaloT
caption (saTauri) Tviseba da davarqvaT ‘Semavali
forma~, xolo formis name (formis saxeli)
Tvisebas davarqvaT `InputForm~ (formebisa da
komponentebis saxelebi iwereba laTinuri asoebiT,
radgan isini arian identifikatorebi.
6. obieqtebis inspeqtoris gamoyenebiT meore formas
SevucvaloT saTauri da davarqvaT `gamomavali
forma~, xolo name TvisebaSi avkrifoT
`OutputForm~. programis Sesrulebisas es forma
gamomaval monacemebs miiRebs `InputForm~- dan.
monacemebis gadagzavna moxdeba maTi Setanisa da
`gadagzavna~ Rilakis daWeris Semdeg.
7. SevinaxoT unit1.pas modulis faili, magram fails
SevucvaloT saxeli SemdegiT:
c:\program files\borland\delphi 3.0\mysource\formtalk\input.pas
Semdeg unda SevinaxoT unit2.pas SevcvaloT misi saxeli
da davarqvaT output.pas
proeqtis failis Sesanaxad gamoviyenoT brZaneba File|
Save Project As , gamosul fanjaraSi avirCioT katalogi
da saxeli proeqtis failis Sesanaxad. proeqtis

143
fails davarqvaT project1.dpr, misi misamarTi diskze
iqneba:
c:\programfiles\borland\delphi\mysource\formtalk\formtalk.dpr

exla avagoT formebi Semdegi procedurebis gamoyenebiT:


1. TiToeul formas davamatoT Edit redaqtirebis
fanjara, da Semaval formaze davsvaT Button Rilaki,
Semdeg orive redaqtirebis fanjaraSi obieqtebis
inspeqtoris gamoyenebiT text Tvisebidan wavSaloT
teqsti.
2. Semavali formis redaqtirebis fanjaras mivaniWoT
saxeli InText, xolo gamomavali formis
redaqtirebis fanjaras mivaniWoT saxeli OutText.
Semavali formis Rilaks mivceT saTauri (caption)
`gadagzavna~, xolo saxeli (name) SendText.
3. e k r a n z e f o r m i s v i z u a l u r i g a m o s a x v i s
garantiisaTvis, obieqtebis inspeqtoris gamoyenebiT,
yvela axlad damatebuli formisaTvis visible Tviseba
SevcvaloT True – Ti.
4. Rilakis kods davamatoT striqoni. SendText
Rilakze orjer davawkapunoT da davamatoT Semdegi
striqoni:
OutputForm.OutText.Text:=InputForm.InText.Text;

Tu yvelaferi zustad iyo Sesrulebuli, programas


gavukeToT testireba, Semdegi mimdevrobiT:
1. avirCioT Run brZaneba, an davaWiroT F9 Rilaks.
dialogur fanjaraSi gamova Semdegi Setyobineba:
forma ‘InputForm’ gadaegzavneba ‘OutputForm’-s, romelic
gamocxadebulia OutputForm-Si. igi ar aris USES siaSi.
gnebavT daamatoT siaSi?
2. davaWiroT yes Rilaks.
3. avirCioT brZaneba File| Save All.

144
4. isev gavuSvaT programa Sesrulebaze F9-iT. Cveni
formebi gamoCndeba ekranze.
5. gavukeToT programas testireba, SevitanoT teqsti
Semaval formaSi da davaWiroT `gadagzavna~ Rilaks.
Cveni Setanili teqsti gamoCndeba gamomavali
formis fanjaraSi.

vnaxoT rogor gamoiyureba Cveni programa. proeqtis


failis Sinaarsis sanaxavad gamoviyenoT brZaneba : View|
Project Source.

program Formtalk ;

uses
Forms,
Input in ‘Input.pas’ {InputForm},
Output in ‘Output.pas’ {OutputForm};

{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TInputForm, InputForm);
Application.CreateForm(TOutputForm, OutputForm);
application.Run;
end.
uses operatori Seicavs Forms moduls da Input, Output
modulebs, romlebic Seicaven Cvens mier Seqmnili formebis
kodebs.
pirveli begin operatoris Semdeg vxedavT meTodebis
operatorebs: Application.Initialize da Application.createForm. es
meTodebi asruleben Cveni formebis Seqmnisa da gaSvebisaTvis
aucilebel operaciebs. meTodi Seicavs kodis fragments.
damasrulebeli operatori aris Application.Run. igi gauSvebs

145
Cvens danarTs da Seasrulebs Cvens formebTan dakavSirebul
kods. formis damatebis an amogdebisas Delphi avtomaturad
akeTebs proeqtis sawyisi kodis modificirebas.
vnaxoT Semavali formis modulis kodi, risTvisac
Semaval formaze orjer davawkapunoT.
Input formis moduli :
unit Input ;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, dialogs,
StdCtrls ;
type
TInputForm = class(TForm)
SendText: TButton;
InText: Tedit;
procedure SendTextClick(Sender: Tobject);
private
{private declarations}
public
{public declarations}
end;

var
InputForm: TInputForm;

implementation

uses output;

{$R *.DFM}

146
procedure TInputForm.SendTextClick(Sender: TObject);
begin
OutputForm.OutText.Text := InputForm.InText.Text;
end;

end.

Output formis moduli:

unit Output ;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms,
dialogs,
StdCtrls ;
type
TOutputForm = class(TForm)
OutText: TEdit;
InText: TEdit;
private
{private declarations}
public
{public declarations}
end;

var
OutputForm: TOutputForm;

147
implementation

{$R *.DFM}

end.

`gadagzavna~ Rilakis daWerisas sruldeba Semdegi


operatori:
OutputForm.OutText.Text := InputForm.InText.Text;

redaqtoris gamoyeneba

ganvixiloT martivi programa, romelic redaqtoris


gamoyenebis demonstrirebis saSualebas iZleva. es aris
martivi danarTi, romelSic momxmarebels Seaqvs ori ricxvi,
aWers Rilaks, programa gamoiTvlis jams da gamoitans
Sedegs. aq gamoyenebuli forma Sesdgeba erTi Rilakisagan,
ori redaqtirebis fanjrisa da oTxi Wdisagan.
gavuSvaT Delphi , gamova forma romelic iqmneba Delphi-
is gaSvebisas avtomaturad. SevudgeT danarTis Seqmnas,
romelsac davarqmevT Addition .
1. Delphi-is instrumentebis striqonze avirCioT
gverdi Standart CanarTiT (es gverdi iqneba mimdinare,
Tu muSaobis dawyebisas Cven sxva gverdi ar
agvirCevia.)
2. Standart gverdze avirCioT Button (Rilaki), Semdeg
ki davawkapunoT formaze, am moqmedebis Sedegad
formaze daemateba Rilaki, romlis zomebi da
mdebareoba SeiZleba SevcvaloT. es Rilaki
movaTavsoT formis qveda nawilSi.
3. Rilakze warweris gasakeTeblad, movniSnoT igi,
risTvisac davawkapunoT Rilakze, Semdeg ki

148
obieqtebis inspeqtoris fanjaraSi Caption Tvisebas
mivceT mniSvneloba `Sekreba~.
4. igive teqnikis gamoyenebiT formaze ganvaTavsoT
ori Wde (Label) da ori redaqtirebis fanjara
(Edit). Wdis piktogramaze gamosaxulia ~A’’
simbolo. ganvaTavsoT es obieqtebi vertikalurad
Semdegi mimdevrobiT: Label1, Edit1, Label2, Edit2.

5. obieqtebis inspeqtoris gamoyenebiT, rogorc


RilakisaTvis gavakeTeT, SevucvaloT Caption Tviseba
Wdeebsac. Label1 SevcvaloT `mniSvneloba 1~ -
iT, xolo Label2 ki - `mniSvneloba 2~ - iT, aseve
SegviZlia SevcvaloT Caption Tviseba formisaTvis.
6. Edit1 da Edit2 oboeqtebisaTvis Text Tvisebas
mniSvnelobis saxiT mivaniWoT carieli striqoni,
risTvisac obieqtebis inspeqtoris meSveobiT masze
dumiliT micemuli mniSvneloba amovSaloT.
7. Edit2 redaqtirebis fanjris qvemoT movaTavsoT

149
kidev ori Wde, esenia Label1 da Label2 , romlebic
ganTavsebulia erTmaneTis gverdiT. Label3 Wdis
Caption Tvisebas mivaniWoT `jami~ mniSvneloba,
xolo Label4 Wdis Caption Tvisebas wavuSaloT
dumiliT micemuli mniSvneloba..
8. gamoviZaxoT kodis redaqtori, risTvisac Rilakze
orjer davawkapunoT.
9. Button1-saTvis CavsvaT saWiro kodi. gavakeToT
kodis redaqtireba ise, rom miviRoT Semdegi teqsti:

Procedure TForm1.Button1Click (Sender: TObject);


var
Value1, Value2, Total : integer;
begin
Value1 := StrToInt (Edit1.Text);
Value2 := StrToInt (Edit2.Text);
Total := Value1 + Value2;
Label4.Caption := IntToStr (Total);
end;
10. failis Sesanaxad avirCioT File | Save As. SevinaxoT
programuli moduli ADDFORM.PAS failSi,
xolo proeqtis faili ADD.DPR failSi.
11. danarTis gasaSvebad vaWerT F9 Rilaks.
Tu yvelaferi swori aRmoCnda forma gaielvebs
ekranze, Cven SegviZlia SevitanoT redaqtirebis fanjaraSi
ricxvi, davaWiroT `Sekreba~ Rilaks da Label4 Wdis
fanjaraSi miviRoT jami.
Cveni danarTis sruli kodi gamoiyureba Semdegnairad:

unit addform;

interface

150
uses

Windows, Messages, SysUtils, Classes, Graphics, Controls,


Forms, Dialogs, StdCtrls;

type
TForm1 = class (TForm)
Button1 : TButton;
Edit1 : TEdit;
Edit2 : TEdit;
Label1 : TLabel;
Label2 : TLabel;
Label3 : TLabel;
Label4 : TLabel;
procedure ButtonClick (Sender : TObject);
private
{ private declarations}
public
{ public declarations}
end;

var
Form1 : TForm1;

implementation;

{$r * . DFM}

procedure TForm1.Button1Click (Sender : TObject);


var
Value1, Value2, Total : integer;
begin
Value1 := StrToInt (Edit1.Text);

151
Value2 := StrToInt (Edit2.Text);
Label4.Caption := IntToStr (Value1 + Value2);
end;

end.

redaqtirebis fanjaraSi Setanili teqsturi striqoni


gardaiqmneba ricxviT mniSvnelobad StrToInt funqciis
gamoyenebiT. es funqcia ricxviT mniSvnelobebs inaxavs Value1
da Value2 cvladebSi, Seajamebs am ricxvebs da miRebul
mniSvnelobas gadaiyvans striqonul formatSi. miRebuli
mniSvneloba warweris saxiT moTavsdeba Label4 WdeSi.

programis gamarTvis damatebiTi brZanebebi.

Delphi-s menius Run ganyofileba Seicavs zogierT


programis SesrulebisaTvis saWiro damatebiT brZanebas.
Run - F9 programis kompilacia da Sesruleba; gawyobis
reJimSi muSaobisas programis Sesruleba gaagrZelos
mocemuli wertilidan.
Step Over – F8 brZaneba axorcielebs programis
striqonebis nabij-nabij Sesrulebas. funqciaSi an
proceduraSi Sesvla ar xdeba.
Trace Into – F7 axorcielebs programis nabij-nabij
Sesrulebas, gamoZaxebul funqciaSi da proceduraSi
SesvliT.
Trace to Next Source Line - [Shift-F7] momdevno
Sesasrulebel striqonze gadasvla.
Run to Cursor – F4 brZaneba axorcielebs programis
Sesrulebas kursoris adgilamde.
Show Execution Point brZaneba kursors moaTavsebs
momdevno Sesasrulebel operatorze.

152
komponentebis Tvisebebi

Delphi-is yvela komponents aqvs Tavisi Tviseba. isini


saSualebas iZlevian SevcvaloT formisa da komponentebis
zomebi da sxva Tvisebebi. formebis Tvisebebze mimarTva
SeiZleba obieqtebis inspeqtoris meSveobiT. obieqtebis
inspeqtors aqvs ori CanarTi: Properties (Tvisebebi) da
Events (xdomilobebi).
ganvixiloT Cvens mier gamoyenebuli komponentis
Tvisebebi, es komponentia Button (Rilaki). gavxsnaT axali
proeqti, davsvaT Rilaki. davuSvaT am RilakisaTvis gvinda
davayenoT ramodenime Tviseba, magaliTad Height (simaRle),
misi dayeneba xdeba ricxviTi mniSvnelobis akrefviT, Cursor
Tvisebis arCeva xorcieldeba Camoxsnadi menius saSualebiT,
saidanac SeiZleba sasurveli Tvisebis arCeva. iseTi Tviseba
rogoricaa Default (dumiliT) gvTavazobs True-False
mniSvnelobebis arCevans. Caption (warwera) Tvisebis saxiT
warmodgenilia teqsti, romelic unda aikrifos saWiroebis
mixedviT. aris egreTwodebuli CarTuli Tviseba, romlis
winac dasmulia + niSani, magaliTad +Font. masze orjer
dawkapunebiT igi gaixsneba da gamoCndeba CarTuli Tvisebebi.
aq SeiZleba gvqondes ramdenime CarTva.
ganvixiloT Button komponentis Tvisebebis sia:
Cancel
Caption
Cursor
Default
DragCursor
DragMode
Enabled
+Font
Color

153
Height
Name
Pitch
Size
+Style
fsBold
fsItalic
fsUnderline
fsStrikeOut
Height
HeipContext
Hint
Left
ModalResult
Name
ParentFont
ParentChowHint
PopupMenu
ShowHint
TabOrder
TabStop
Tag
Top
Visible
Width
zogierTi Tviseba damokidebulia sxva Tvisebaze.
magaliTad Hint (miTiTeba). es miTiTeba gamodis maSin, rodesac
kursori miuaxlovdeba komponents. es imuSavebs mxolod
maSin, Tu ShowHint TvisebaSi arCeulia True mniSvneloba.
Tu TvisebaSi ParentShowHint (gamoviyenoT mSoblis ShowHint)
arCeulia True mniSvneloba, miTiTeba gamova mxolod mSobel
formaze, xolo Tu misi mniSvnelobaa False es miTiTeba
gavrceldeba Svili formebisaTvisac. aseve Tu ParentFont

154
(gamoviyenoT mSoblis Srifti) TvisebaSi dayenebulia True,
komponenti miiRebs informacias Sriftis Sesaxeb mSobeli
formisagan.

xdomilobebi.

RilakisaTvis SeiZleba avirCioT saWiro xdomiloba,


romelic ganTavsebulia obieqtebis inspeqtorze.
xdomilobis SeqmnisaTvis orjer davawkapunoT xdomilobis
velze, gamosul fanjaraSi SevitanoT xdomilobis kodi.

meTodebi.

meTodi iZleva komponentis marTvis saSualebas.


magaliTad Tu saWiroa, rom Rilaki gaxdes uxilavi, unda
aikrifos kodi Button1.Hide. ganvixiloT Button
komponentisaTvis misawvdomi meTodebis sia:
BeginDrag
BringToFront
CanFocus
ClientToScreen
Create
Destroy
Dragging
EndDrag
Focused
Free
GetTextBuf
GetTextLen
Hide
Refresh
Repaint
ScaleBy

155
ScreenToClient
ScrollBy
SendToBack
SetBounds
SetFocus
SetTextBuf
Show
Update
meTodis Sesaxeb informaciis misaRebad saWiroa
davawkapunoT komponenteze da davaWiroT F1 Rilakze.
miviRebT cnobebs aRniSnuli komponentis Sesaxeb. avirCioT
Methods da gamoCndeba mocemuli komponentisaTvis misawvdomi
sia. erT-erTis arCeva iZleva imis ganmartebas Tu rogor
muSaobs igi da rogor visargebloT am meTodiT.

gverdi Standard (standartuli)

komponenti MainMenu ( mTavari meniu) saSualebas


iZleva formaze Seiqmnas mTavari menius zoli da Camoxsnadi
meniu. es aravizualuri komponentia.
komponenti PopupMenu (mcocavi meniu), mcocavi
menius Seqmnis saSualebas iZleva. es meniu gamova Tagvvis
marjvena Rilakis daWerisas. es aravizualuri komponentia.
komponenti formaze teqstis ganTavsebis saSua-
lebas iZleva. komponenti vizualuria.
komponenti Edit (redaqtirebis fanjara) gamoi-
yeneba momxmareblis mier erTstriqoniani teqstis Sesatanad.
komponenti vizualuria.

156
Memo komponenti (redaqtirebis mravalstri-
qoniani fanjara), gamoiyeneba mravalstriqoniani teqstis
Sesatanad. komponenti vizualuria.
komponenti Button (brZanebis Rilaki), gamoiyeneba
Rilakis Sesaqmnelad, romliTac momxmarebeli danarTisaTvis
irCevs brZanebas. komponenti vizualuria.
CheckBox komponenti (sakontrolo indikatori
droSiT) momxmarebels programis opciis amorCevis an
gamorTvis saSualebas aZlevs. komponenti vizualuria.
RadioButton komponenti (radioRilaki) momxmarebels
aZlevs alternativebis nakrebs, saidanac amoirCeva erTi.
komponenti vizualuria.

ListBox komponenti (siis fanjara), momxmarebels


siidan amorCevis saSualebas aZlevs.
ComboBox komponenti (redaqtirebadi sia)
aerTianebs ListBox-isa da Edit-is funqciebs. momxmarebels
SeuZlia airCios teqsti siidan an Seitanos teqsti siaSi.
komponenti vizualuria.
Scrollbar komponenti (gadaxvevis xazi). komponenti
vizualuria.

GroupBox komponenti (jgufuri fanjara).


aerTianebs urTierTdakavSirebul marTvis organoebis jgufs,
magaliTad, rogoricaa RadioButton an CheckBox da sxva.
komponenti vizualuria.K

157
RadioGroup komponenti (radioRilakebis jgufi)
warmoadgens GroupBox-is fanjarasradioRilakebis nakrebiT.
emsaxureba radioRilakebis jgufis Seqmnas. komponenti
vizualuria.

Panel komponenti (paneli), gamoiyeneba mdgomareobis


zolis, instrumentebis panelis, instrumentebis palitris
Sesaqmnelad. komponenti vizualuria.

teqsturi failis demonstrirebis magaliTi.

SevqmnaT programa, romelic akeTebs teqsturi failis


demonstrirebas.

formaze ganvaTavsoT Semdegi elementebi: Label1, Edit1,


158
Label2, Edit2. formis qveda nawilSi ganvaTavsoT sami Rilaki:
Button1, Button2, Button3, Rilakebs davarqvaT saxelebi:
`Senaxva~, `CatvirTva~, `daxurva~.

Rilaks `Senaxva~ davamatoT kodi:

procedure TForm1.Button1Click (Sender: TObject);


var
OutFile : TextFile;
fname, OutString : string;
begin
{cvlads davarqvaT failis saxeli}
fname:= `JUNKFILE.TXT`;
{ganvsazRvroT failis saxeli da ti pi, rogorc
OutFile}
AssignFile(OutFile,fname);
{Seiqmnas da gaixsnas axali faili, gansazRvruli
rogorc OutFile}
Rewrite(OutFile);
{aviRoT teqsti CawerisaTvis gavsazRvrul
redaqtirebis fanjridan}
OutString:=Edit1.Text;
{CavweroT teqsti OutString striqonidan failSi}
Writeln(OutFile,OutString);
{ganvaaxloT da davxuroT faili}
CloseFile(OutFile);
end;

Rilaks `CatvirTva~ davamatoT kodi.

procedure TForm1.Button2Click (Sender: TObject);


var
InFile : TextFile;

159
fname, InString : string;
begin
{cvlads mivceT teqsturi failis saxeli}
fname := ‘JUNKFILE.TXT’;
{ganvsazRvroT teqsturi faili, rogorc InFile}
AssignFile (InFile, fname);
{gavxsnaT InFile faili}
Reset (InFile);
{wavikiTxoT teqstis striqoni}
Readln (InFile, InString);
{wakiTxuli striqoni movaTavsoT Read Text
fanjaraSi}
Edit2.Text := InString;
{davxuroT faili}
CloseFile (InFile);
end;

Rilaks `daxurva~ davamatoT kodi.

procedure TForm1.Button3Click(Sender: TObject);


begin
Application.Terminate;
end;

programis sruli teqsti gamoiyureba Semdegnairad:

unit Textform;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs,

160
StdCtrls;

type
TForm1 = class(TForm)
Edit1 : TEdit;
Label1 : TLabel;
Label2 : TLabel;
Edit2 : TEdit;
Button1 : TButton;
Button2 : TButton;
Button3 : TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);


var
OutFile : TextFile;
fname, OutString : string;
begin
fname:= ‘JUNKFILE.TXT’;

161
AssignFile(OutFile,fname);
Rewrite(OutFile);
OutString:=Edit1.Text;
Writeln(OutFile,OutString);
CloseFile(OutFile);
end;

procedure TForm1.Button2Click(Sender: TObject);


var
InFile : TextFile;
fname, InString : string;
begin
fname := ‘JUNKFILE.TXT’;
AssignFile (InFile, fname);
Reset (InFile);
Readln (InFile, InString);
Edit2.Text := InString;
CloseFile (InFile);
end;

procedure TForm1.Button3Click(Sender: TObject);


begin
Application.Terminate;
end;

end.

ti pizebuli faili

ti pizebuli failis demonstrirebisaTvis SevqmnaT


axali proeqti. SevinaxoT moduli, rogorc ADDR.PAS
xolo proeqti rogorc ADDRESS.DPR . jer SevqmnaT
Canaweris struqtura. Implementation nawilSi {$R*DFM}

162
qvemoT movaTavsoT Semdegi kodi:

type
Address = record
Lastname : String[20];
Firstname : String[20];
Phone : String[15];
StreetAddress : String[50];
City : String[40];
State : String[2];
ZipCode : String[10];
end;

aq gamoyenebulia mxolod striqonuli ti pi, magram Cven


SegveZlo gamogveyenebina monacemTa sxva tipebic, rogoricaa
mTeli, namdvili da a.S. zemoT aRniSnuli kodis Semdeg
movaTavsoT Semdegi:
var
AddresFile : File of Address;
AddressData : Address;

AddresFfile es aris Address ti pis failuri cvladi.


AddressData es aris Address ti pis cvladi.
ganvixiloT procedurebi da funqciebi, romlebic
gamoiyenebian ti pizebul failebTan muSaobisas.

AssignFile

sintaqsi: procedure AssignFile(var F, String);


daniSnuleba: failur cvlads aniWebs failis saxels.

Reset

163
sintaqsi: procedure Reset (var F: File; [RecSize: Word] );
daniSnuleba: gamoiyeneba arsebuli failis
gasaxsnelad. im failisa, romlis saxeli mieniWa failur
cvlads AssignFile – is daxmarebiT.

Rewrite

sintaqsi: Procedure Rewrite (var F[: File; RecSize:


Word ]);
daniSnuleba: gamoiyeneba im failis Sesaqmnelad da
gasaxsnelad, romlis saxeli mieniWa failur cvlads
AssignFile-s daxmarebiT.

Seek

sintaqsi: Procedure Seek (var F, N: Longint);


daniSnuleba: gamoiyeneba failuri maCveneblis
gaxsnili failis gansazRvrul Canawerze gadasaadgileblad.

Read

sintaqsi: Procedure Read (F; V1 [, V2, . . . , Vn] );


daniSnuleba: gamoiyeneba failidan Canaweris
wasakiTxad.

Write

sintaqsi: Procedure Write (F; V1 [, V2, . . . , Vn] );


daniSnuleba: gamoiyeneba failSi monacemis Casawerad.

Eof

sintaqsi: Procedure Eof (var F): Boolean;

164
daniSnuleba: gamoiyeneba failis dasasrulis
aRniSvnisaTvis.

CloseFile

sintaqsi: Procedure CloseFile (var F);


daniSnuleba: gamoiyeneba Caweris damTavrebisa da
failis daxurvisaTvis.

proeqtis magaliTi.

mivubrundeT Cvens programas. AddressData : Address;


striqonis Semdeg CavweroT:

Fname : String;
RecSize, CurRec : Longint;

exla davamatoT formaze Svidi redaqtirebis fanjara,


Svidi Wde, oTxi Rilaki da erTi BitBtn Rilaki.

165
ganvixiloT kodi da gamoviyenoT igi Sesabamis marTvis
elementebze dasamateblad.
`misamarTebisa da telefonebis~ wignis danarTis
amonabeWdi:

Unit Addr;

interface

166
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons;

type
TForm1 = class (TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Previous: TButton;
Next: TButton;
Save: TButton;
New: TButton;
Close: TBitBtn;
procedure FormCreate (Sender : TObject);
procedure NewClick (Sender: TObject);
procedure previousClick(Sender : TObject);
procedure NextClick (Sender: TObject);
procedure SaveClick (Sender: TObject);
procedure CloseClick (Sender: TObject);
private

167
{private declarations}
procedure LoadRecord;
procedure SaveRecord;
procedure ShowRecord;
procedure ClearData;
public
{public declarations}
end;

var
Form1: TForm1;

implementation
{$R*.DFM}
type
Address = record
Lastname: String[20];
Firstname: String[20];
Phone: String[15];
StreetAddress: String[50];
City : String[40];
State : String[2];
ZipCode : String[10];
end;

Var
AddressFile : File of Address;
AddressData : Address;
Fname : String;
RecSize, CurRec : Longint;

procedure TForm1.LoadRecord;
begin

168
{Canaweris CatvirTva}
Read(AddressFile, AddressData);
{Canaweris gamosaxva ekranze}
ShowRecord;
end;

procedure TForm1.SaveRecord;
begin
{Canaweris kopireba ekranidan}
AddressData.Lastname := Edit1.Text;
AddressData.Firstname := Edit2.Text;
AddressData.Phone := Edit3.Text;
AddressData.StreetAddress := Edit4.Text;
AddressData.City := Edit5.Text;
AddressData.State := Edit6.Text;
AddressData.ZipCode := Edit7.Text;
{movaTavsoT Canaweri failSi}
Write (AddressFile, AddressData);
end;

procedure TForm1.ClearData;
begin
{redaqtirebis fanjrebis gasufTaveba}
Edit1.Text := ‘ ‘;
Edit2.Text := ‘ ‘;
Edit3.Text := ‘ ‘;
Edit4.Text := ‘ ‘;
Edit5.Text := ‘ ‘;
Edit6.Text := ‘ ‘;
Edit7.Text := ‘ ‘;
end;

procedure TForm1.FormCreate (Sender: TObject);

169
begin
{redaqtirebis fanjrebis gasufTaveba}
ClearData;
{Clear Current Record Counter}
CurRec := 0;
{davayenoT failis saxeli}
Fname := ‘ADDRESS.DAT’;
{davniSnoT failuri cvladi};
AssignFile (AddressFile, Fname);
{miviRoT Canaweris zoma}
RecSize := SizeOf (AddressData);
{Tu faili arsebobs, igi CavtvirToT}
If FileExists (Fname) then
Begin
Reset (AddressFile);
If not Eof (AddressFile) then
begin
Read (AddressFile, AddressData);
ShowRecord;
end;
end

{winaaRmdeg SemTxvevaSi SevqmnaT igi}


else
begin
ClearData;
Rewrite (AddressFile);
end;
end;

procedure TForm1.NewClick (Sender: TObject);


begin
repeat

170
CurRec := CurRec + 1;
Seek (AddressFile, CurRec);
until Eof (AddressFile);
{gavasufTaoT redaqtirebis fanjara}
ClearData;
{SevqmnaT axali Canaweri}
SaveRecord;
{failis maCvenebeli gadavaadgiloT mimdinare
Canawerze}
Seek (AddressFile, CurRec);
end;

procedure TForm1.PreviousClick (Sender: TObject);


begin
If CuRec-1 < 0 then
begin
{Tu mivediT failis dasawyisTan, gadavideT pirvel
CanawerTan da gamovceT Setyobineba}
CurRec := 0;
Seek (AddressFile, CurRec);
ShowMessage (‘es failis dasawyisia’)
end
{winaaRmdeg SemTxvevaSi davbrundeT erTi CanaweriT
ukan da da gamovsaxoT ekranze}
else
begin
CurRec := CurRec – 1;
Seek (AddressFile, CurRec);
Read (AddressFile, AddressData);
Seek (AddressFile, CurRec);
ShowRecord;
end;
end;

171
procedure TForm1.NextClick (Sender: TObject);
begin
{gadavadgildeT Semdeg Canawerze}
CurRec := CurRec + 1;
Seek (AddressFile, CurRec);
{Tu ar aris failis dasasruli, wavikiTxoT da
gamovsaxoT Canaweri}
If not Eof (AddressFile) then
begin
Read (AddressFile, AddressData);
Seek (AddressFile, CurRec);
ShowRecord;
end
{Tu miRweulia failis dasasruli, davubrundeT bolo
Canawers da gamovceT Setyobineba)
else
begin
CurRec := CurRec – 1;
Seek (AddressFile, CurRec);
ShowMessage (‘es failis dasasrulia’);
end;
end;

procedure TForm1. ShowRecord;


begin
{gadavakopiroT faili redaqtirebisaTvis}
Form1.Edit1.Text := AddressData.Lastname;
Form1.Edit2.Text := AddressData.Firstname;
Form1.Edit3.Text := AddressData.Phone;
Form1.Edit4.Text := AddressData.StreetAddress;
Form1.Edit5.Text := AddressData.City;
Form1.Edit6.Text := AddressData.State;

172
Form1.Edit7.Text := AddressData.ZipCode;
end;

procedure TForm1.SaveClick (Sender: Tobject);


begin
{SevinaxoT Canaweri}
SaveRecord;
{gamovsaxoT Canaweri redaqtirebis fanjaraSi}
ShowRecord;
end;

procedure Tform1.CloseClick (Sender: TObject);


begin
{SevinaxoT mimdinare Canaweri}
SaveRecord;
{davxuroT faili}
CloseFile (AddressFile);
{gamosvla danarTidan}
Application.Terminate;
end;

end.

es programa qmnis ADDRESS.DAT fails, momxmarebli-


sagan iRebs monacemebs da inaxavs am failSi Canaweris
formiT. `axali~ Rilakis kodi asufTavebs Semavali
monacemebis vels da axali Canaweris Setanis saSualebas
iZleva. `Senaxva~ Rilaki Cawers am monacemebs ADDRESS.DAT
failSi. `wina~ da `momdevno~ Rilakebi wina da momdevno
Canawerze gadaadgilebis saSualebas iZleva. `daxurva~
Rilaki danarTidan gamosvlis saSualebas iZleva.

173
exla SegviZlia danarTis testireba gavakeToT.
SevitanoT monacemebi da davaWiroT `Senaxva~ Rilaks, Semdegi
Canaweris Sesatanad vaWerT `axali~ Rilaks, redaqtirebis
fanjrebi gasufTavdeba da momzaddeba axali Canaweris
Sesatanad. danarTis momdevno gaSvebisas danarTi TiTon
i povis ADDRESS.DAT fails da gamoitans mis pirvel
Canawers ekranze.

SevqmnaT forma `standartuli~ gverdis Rilakebis


gamoyenebiT:

174
unit gilakebi;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
ComboBox1: TComboBox;
Button1: TButton;
MainMenu1: TMainMenu;
N1: TMenuItem;
File1: TMenuItem;
procedure RadioGroup1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure File1Click(Sender: TObject);
private
{ Private declarations }

175
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.RadioGroup1Click(Sender: TObject);


begin
if radiogroup1.itemindex=0 then form1.Color:=clsilver;
if radiogroup1.itemindex=1 then form1.Color:=clblue;
if radiogroup1.itemindex=2 then form1.Color:=clyellow;
if radiogroup1.itemindex=3 then form1.Color:=clred;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);


begin
if checkbox1.state=cbchecked then form1.Font.Style:=[fsitalic]
else
form1.Font.Style := [];
end;

procedure TForm1.CheckBox2Click(Sender: TObject);


begin
if checkbox2.state=cbchecked then
form1.Font.Style := [fsbold] else

176
form1.Font.Style:=[];
end;

procedure TForm1.Button1Click(Sender: TObject);


begin
memo1.Clear;
end;

procedure TForm1.RadioButton1Click(Sender: TObject);


begin
if radiobutton1.Checked then
memo1.Color := clwhite;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);


begin
if radiobutton2.Checked then
memo1.Color := claqua;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);


begin
if combobox1.ItemIndex=0 then
memo1.Font.Name:='arial';
if combobox1.ItemIndex=1 then
memo1.Font.Name:='Litnusx';
if combobox1.ItemIndex=2 then
memo1.Font.Name:='Litmtavrps';
end;

177
procedure TForm1.File1Click(Sender: TObject);
begin
application.Terminate;
end;

end.

menius Sesadgenad formaze davsvaT Main Menu Rilaki,


masze orjer davawkapunoT, gamosul formaze
moniSnuli Rilakis Caption TvisebaSi CavweroT File,
Tu gvinda, rom misi pirveli simbolo iyos xazgasmuli,
CavweroT &File, movniSnoT Semdegi Rilaki da Caption-
Si CavweroT &Help. meniu File-s brZanebebis Sesadgenad
davawkapunoT masze da gamosuli Rilakis Caption-Si
CavweroT Exit da a.S.
forma miiRebs Semdeg saxes:

178
grafikuli elementebi

magaliTSi gamoyenebulia piqselebis Tviseba, sinusoidis


asagebad. formaze aris erTaderTi Rilaki, masze daWerisas
daixazeba sinusoida.

179
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls;

type

TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

const
pi=3.14159;

180
var
X : real;
Y : real;
PX : longint;
PY : longint;
HalfHeight : Longint;

begin
HalfHeight := form1.Height div 2;
for PX := 0 to form1.Width do

begin
X := PX*(2*PI/Form1.Width);
Y := sin(X);
PY := trunc(0.7 * Y * Halfheight) + HalfHeight;
Canvas.Pixels[PX,PY] := 0;
end;

end;
end.

181
wrfeebis daxazva.

erTi wertilidan meoreSi wrfeebis gasavlebad


gamoiyeneba LineTo meTodi, romelic moiTxovs mxolod
saboloo wertilis koordinatas Cvenebas da daivleba
xazi mimdinare wertilidan naCveneb poziciamde.

182
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

const
Pi=3.14159;

183
var
X : real;
Y : real;
PX : Longint;
PY : Longint;
Offset : Longint;
HalfHeight : Longint;

begin
HalfHeight := Form1.Height div 2;
for Offset := -10 To 10 do
begin
PX := 0;
While PX < Form1.Width do
BEGIN
X := PX * (2 * PI/Form1.Width);
Y := SIN(X);
PY := Trunc(0.7 * Y * HalfHeight) + HalfHeight
+(Offset*10);
IF (PX = 0) Then
canvas.LineTo(PX, PY);
PY := trunc(0.7 * Y * HalfHeight) + HalfHeight +
((Offset-1) * 10);
canvas.LineTo(PX,PY);
PX := PX + 15;
end;
end;

184
martivi animacia Mode Tvisebis gamoyenebiT.

programa, dasawyisSi kalmis pmCopy da feris clRed


reJimis gamoyenebiT xatavs wiTeli feris fanjaras, Semdeg
ki gadaaadgilebs samkuTxeds fanjris gavliT, risTvisac
iyenebs kalmis pmNotXor reJims. es saWiroa imisaTvis,
rom TiToeul poziciaSi orjer daixatos samkuTxedi.
pirvelad samkuTxedi daixazeba, xolo meored waiSleba.

185
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1 : TButton;
procedure Button1Click(Sender : TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender : TObject);


var
count : integer;
pause : real;

begin

186
form1.Canvas.Pen.Mode := pmcopy;
form1.Canvas.Pen.Color := clRed;
form1.Canvas.PolyLine([point(50,10),
point(100, 10),
point(100, 200),
point(50, 200),
point(50, 10)]);
form1.Canvas.Pen.Color := clBlue;
form1.Canvas.Pen.Mode := pmNotXor;
For count := 0 to (form1.Width div 5) do
begin

Form1.Canvas.Polyline([point(Count * 5, 100),
point(Count * 5 + 10, 100),
point(Count * 5 + 5, 110),
point(Count * 5, 100)]);
Pause := Time;
while (Time-Pause) < 1e-12 do;
Form1.Canvas.Polyline([point(Count * 5, 100),
point(Count * 5 + 10, 100),
point(Count * 5 + 5, 110),
point(Count * 5, 100)]);

end;
end;

end.

187
ganvixiloT magaliTi.
danarTi, romelic `probelebs~ gardaqmnis
` mZimeebad~.
unit Sp2cma;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, dialogs, Menus, StdCtrls;

Type
TForm1 = Class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
OpenDialog1: TOpenDialog;
Edit1: TEdit;
Label1: Tlabel;
procedure Butto2Click (Sender: Tobject);
procedure Butto1Click (Sender: Tobject);
procedure Butto3Click (Sender: Tobject);
private
{private declarations}
public
{public declarations}
end;

var
Form1: TForm1;

implementation

188
var

Fname: String;
{SR * DFM}

procedure TForm1.Button2Click(Sender: TObject);

var
InFile: File;
FBuffer : Array [0..1023] of Byte;
FPointer : Longint;
ButesRead : Integer;
X: Integer;

begin

AssignFile(InFile,Fname); Reset(InFile,1);
While Not Eof (InFile) do begin
FPointer := FilePos(InFile);
BlockRead (InFile, FBuffer, SizeOf(FBuffer), BytesRead);
For x:=0 to BytesRead-1 do begin
If FBuffer[x]=32 then Fbuffer[x] := 44;

end;

Seek(InFile, FPointer);
BlockWrite(InFile, FBuffer, BytesRead);
end;

CloseFile(InFile);
ShowMessage( ‘procesi dasrulebulia!’);

end;
189
procedure TForm1.Button1Click(Sender: TObject);
begin

OpenDialog1.FileName:=’*.*’;
if OpenDialog1.Execute then
Fname:= OpenDialog1.FileName;
Edit1.Text:=Fname;
Edit1.Visible:=True;
Label1.Visible:=True;
end;

procedure TForm1.Button3Click(Sender: TObject);

begin
Application.Terminate;
end;
end.

190
sarCevi

Turbo Pascal
Sesavali ............................................................................................................................... 3
funqcionaluri Rilakebi ......................................................................................... 4
pirveli programa .......................................................................................................... 4
monacemTa ti pebi ............................................................................................................ 9
monacemTa ti pebis gardaqmna da maTze moqmedebebi ................................... 12
Sedgenili da carieli operatori ................................................................... 15
pirobis operatori ...................................................................................................... 21
FOR – TO cikli ............................................................................................................ 26
WHILE – DO cikli ..................................................................................................... 29
REPEAT – UNTIL cikli ............................................................................................. 31
amorCevis operatori ................................................................................................. 34
Wde da gadasvlis operatori .............................................................................. 39
masivis ti pi .................................................................................................................... 41
simravlis ti pi ............................................................................................................ 46
striqonuli ti pi ....................................................................................................... 50

Object Pascal
Canawerebi .......................................................................................................................... 56
ti pizebuli mudmiva .................................................................................................. 64
CamoTvliTi ti pi ......................................................................................................... 65
variantis ti pi ............................................................................................................. 66

191
ganStoeba......................................................................................................67
Goto...................................................................................68
Break..............................................................................69
Continue..........................................................................70
Exit..................................................................................71
Halt..................................................................................72
RunError..........................................................................72
failis ti pi..............................................................................................73
procedurebi da funqciebi failebTan muSaobisaTvis.......75
procedurebi da funqciebi teqsturi failebisaTvis78
procedurebi da funqciebi ti pizebuli da arati pize-
buli failebis damuSavebisaTvis....................................................82
procedurebi..............................................................................................83
funqciebi......................................................................................................87
standartuli qveprogramebi...........................................................89
ariTmetikuli funqciebi...................................................................90
gardaqmnis funqciebi............................................................................92
sxva funqciebi..........................................................................................94
teqsturi da grafikuli reJimebi.............................................96
Delphi
moduli........................................................................................................110
formebi........................................................................................................115
formebisa da komponentebis Tvisebebi ..............................115
Delphi-is martivi danari.................................................................115
kodis redaqtoris fanjara.........................................................119
obieqtebis inspeqtori....................................................................120
Delphi-is menius struqtura........................................................123
obieqtur-orientirebuli daproeqteba...............................136
Delphi-is danarTi..................................................................................138
proeqtis magaliTi.............................................................................142

192
redaqtoris gamoyenebis magaliTi..............................................148
programis marTvis damatebiTi brZanebebi...........................152
komponentebis Tvisebebi.....................................................................153
xdomilobebi...............................................................................................155
meTodebi.........................................................................................................155
komponentebis gverdi standartuli........................................156
teqsturi failis demonstrirebis magaliTi...................158
ti pizebuli faili................................................................................162
proeqtis magaliTi................................................................................165
grafikuli elementebi delfSi..................................................179

193
literatura

1. v. v. faronovi, TurboPascal, sawyisi kursi, saswavlo


saxelmZRvanelo, 1997w. moskovi.
2. d. ouzer, s. grobman, s, batson Delphi, moskovi, 2001
weli.
3. Booch G. Object-Oriented Design with Applications. Calif.,
1990.
4. Coad P., Yourdan E. Object-Oriented Analysis. Prentice-Hall,
1991
5. Jacobson I. Object Oriented Software Engineering. Addison
Wesley, 1992
6. g. surgulaZe daprogramebis meTodebi, Tbilisi 1997w.

194
195
196

You might also like