Вы находитесь на странице: 1из 498

. .

Turbo Pascal 7.0



' .
. .

!
" ""
2003

32.973-01
83
681.3.06

/-

. .
83 Turbo Pascal 7.0 / . . . .:
, 2003. 496 ., .
ISBN 966-7323-30-7
, " ". Turbo Pascal 7.0.
,
Pascal . , ,
.
,
.
Pascal .

32.973-01

Turbo Pascal 7.0


. .
05.09.2003. 70 100 1/16.
. . .
. . . 19. .-. . 22,10.
2000 . 100903
"", , 03142, . , . , 35, . 111
./.: (044) 452-82-22; e-mail: office@junior.com.ua; http://www.junior.com.ua

, :
, 368 20 2001 .
""
88018, . , . . , 2
, , ,
.
. .
, , , .

ISBN 966-7323-30-7

"", 2003

14

I. Turbo Pascal
1.
2.
3.
4.
5.
6.
7.

Turbo Pascal
, ,




15
17
28
36
44
49
55
61

II.
8.
9.
10.
11.
12.

...73
74
79
87
99
105

III.

117

13.
14.
15.
16.
17.
18.

118
132
138
162
167
187



Turbo Vision

IV.

19.
,
20.
'....
21.
. Turbo Pascal
. Turbo Pascal
.
. BIOS MS-DOS
. 8x86
. ASCII
. ,
3.

'. 205

206
218
232
260
263
269
272
312
328
331
480

14

I. Turbo Pascal

1. Turbo Pascal
Turbo Pascal


,

Turbo Pascal
Turbo Pascal








'.

Turbo Pascal


Open a File
2. , ,

Pascal








3.








:
4.



;



5.
if

if
case

..15

..'

15
17
17
18
18
19
19
20
.21
21
21
21
22
23
24
25
26
26
27
27
27
28
28
28
28
29
29
29
30
31
31
32
32
32
36
36
38
40
41
42
42
43
43
44
44
45
45
.....45
46
46
....49
49
49
50
51

Turbo Pascal 7.0 5


case
goto
case

6.

for
while
""
repeat

52
53
54

55

55
57
58
58
59_

7.


,
,

- -


external
forward

61

62
63
........63
64
67
67
67
68
:
69
70
70
71
71

II. .
8.

73
74
74

9.

79

10.
Pascal

87
88

75
76

with

79
79
79
81
83
83
84

11.

88
89
89
89
90
90
...90
91
92
92
93
97

99

100
101
101

12.

105
,

107
107
108
109
110

111
111
112
113

III.

117

13.

-
{$}
{$}
{$D>
{$}
{$F}
{$!}
{$
{$N}
{$}
{$>
{$Q>
{$R}
{$5}
.'
{$}
{$V}
{$}
'.
{$Y}
-
{$>
'...,.
{$0}
.
{$!}
{$
{$}

MS-DOS
Turbo Pascal



Condition

.....
Pass count
:

14.


,

Compile | Make Compile | Build
Compile | Primary file Compile | Clear primary file
15.
'.







118
..118
118
118
119
119
119
119
119
119
120
120
120
120
121
121
121
121
121
121
122
123
123
123
123
124
124
125
126
126
127
127
.'. 128
129
129
129
130
132
133
135
136
137
137
138
138
138
139
140
142
147
149
152
152
154
159'

:..

Turbo Pascal 7.0 7


16.
asm

asm
assembler
{$1}
'.
17.
Pascal
BIOS




*.


MS-DOS


18. Turbo Vision
, Turbo Vision




Turbo Vision
IV.
19.


:
""




20.


""
21.
, "
Turbo Vision
. Turbo Pascal




Turbo Pascal 3.5"
. Turbo Pascal
.
. BIOS MS-DOS
BIOS
MS-DOS
. 8x86
ASCII-
AAD ASCII-
ASCII-
;
AAS ASCII-

'.
,

162
162
162
164
165
166
167
168
170
170
170
171
173
176
177
180
180
181
183
184
187
187
189
192
193
196
198
205
206
206
206
207
209
210
212
213
218
218
223
227
232
232
245
260
260
260
260
261
262
263
269
272
272
292
312
312
312
312
312

ADC
ADD
i
AND ""
CALL
CBW
CLC CF
CLD DF
CMC CF

CMPS (CMPSB/CMPSW/CMPSD)
CWD
DEC
DIV
:
ESC
HLT
IDIV ()
IMUL ()
IN
,
INC
INT
INTO
IRET
J-
JA/JNBE ""/" "
JAE/JNB/JNC " "/" "/
JB/JNAE/JC ""/" "/
JBE/JNA " "/" "
JE/JZ ""/""
JG/JNLE ""/" "
JGE/JNL " "/" "
JL/JNGE ""/" "
JLE/JNG " "/" "
JNE/JNZ " " " "
JNO ,
JNP/JPO , /
JNS ,
JO
JP/JPE , /
JS

JCXZ =0
JMP
LAHF
LDS
:
LEA ()
LES
LOCK
LODS (LODSB/LODSW/LODSD) -
LOOP .
]
LOOPE/LOOPZ , ""/""
LOOPNE/LOOPNZ , " "/" "
MOV
MOVS (MOVSB/MOVSW/MOVSD)
MUL
:
NEG
NOP
NOT ""
OR ""
OUT ,
POP
POPA/POPAD
POPF/POPFD
PUSH

312
313
313
313
313
313
313
314
314
314
314
314
315
315
315
315
316
316
316
316
3-17
317
317
317
317
317
317
317
318
318
318
318
318
318
318
318
318
318
319
319
319
319
319
319
319
320
320
320
320
320
321
321
321
321
322
322
322
322
322
322
323
323

Turbo Pascal 7.0 9


PUSHA/PUSHAD
323
PUSHF/PUSHFD
323
RCL/RCR /
324
REP/REPE/REPZ/REPNE/REPNZ
324
RET/RETF/RETN
,
324
ROL/ROR /
324
SAHF
325
SAL/SAR /
325
SBB ()
325
SCAS (SCASB/SCASW/SCASD) .(, ) .. 325
SHL/SHR /
326
STC CF
326STD DF
326
STOS STOSB/STOSW/STOSD // 326
SUB
327
TEST
.
327
WAIT
327
XCHG
327
XLAT
...... 327
XOR ""
.'.... 327

. ASCII
. ,
System

Abs

Cos

Frac
Int
Pi
Sin
Sqr
Sqrt

Break
Continue
Exit
Halt
RunError
/

Eof
Eoln
FilePos
FileSize
lOResult
SeekEof
SeekEoln

Append
Assign
BlockRead
BlockWrite
Close
Flush
Read
Readln
Reset

328
331

,
.'

331
331
332
332
333
334
334
335
336
337
337
338
338
339
339
339
340
340
341
341
342
342
342
343
343
344
344
345
346
346
346
347
348
349
349
350
350
351
352

10

Rewrite
Seek
SetTextBuf
Truncate
Write
'.
Writeln

ChDir
Erase
GetDir
MkDir
Rename
RmDir

Addr
Assigned
CSeg
DSeg
Hi
Lo
MaxAvail
MemAvail
Ofs
Ptr
Seg
SizeOf
SPtr
SSeg
Swap

Dispose
FillChar...'.
FreeMem
'.
GetMem
New
Mark
Move
Release

Odd
Pred
Succ
UpCase

Dec
Inc

Concat

Length

,.

Delete
Insert

Chr
Ord

:
,
'.

'.
,

.'

.-.-

352
353
354
354
355
356
356
356
356
357
357
358
358
359
,
359
359
359
360
360
361
361
362
363
364
364
'..... 365
365
365
366
367
367
368
368
368
369
369
370
371
371
372
372
372
372
373
373
374
374
374
375
375
375
375
376
377
377
378
378
378
379
379
379
379

Turbo Pascal 7.0 11


Round
Trunc
.
Str
Val

High
Low
ParamCount
ParamStr
Random

Exclude
Include
Randomize
Crt

KeyPressed
ReadKey
WhereX
WhereY

AssignCrt
ClrEol
ClrScr
Delay
DelLine
GotoXY
HighVideo
InsLine
LowVideo
NormVideo
NoSound
Sound
TextBackGround
TextColor
TextMode
Window
Dos

DiskFree
DiskSize
DosExitCode
DosVersion
EnvCount
EnvStr
FExpand
FSearch
GetEnv

Exec
FindFirst
FindNext
FSplit
GetCBreak
GetDate
GetFAttr
GetFTime
GetlntVec
GetTime
GetVerify

..
..,.

...'

."
'

380
380
381
381
381
382
382
382
382
383
383
384
384
,-.... 384
385
386
386
386
386
387
387
388
388
388
389
389
390
391
391
392
392
392
393
393
394
394
395
395
396
397
397
397
398
398
399
399
400
401
401
402
402
402
402
403
404
405
405
406
407
408
408
409

12

Intr
Keep
MsDos
PackTime
SetCBreak..
SetDate
SetFAttr
SetFTime
SettntVec
SetTime
SetVerify
SwapVectors
UnpackTime
Graph

GetBkColor
GetColor
GetDriverName
GetGraphMode
GetMaxCotor
GetMaxMode
GetMaxX
GetMaxY
GetModeName
GetPaletteSize ...
GetPixel
GetX
GetY
GraphErrorMsg
GraphResult
ImageSize
InstallUserFont
TextHeight
TextWidth


Arc


Circle
DrawPoly
Ellipse
FillEllipse
FillPoly
...'.
FloodFill
Getlmage
Line
LineRel
LineTo
MoveRel
Move
OutText
OutTextXY
PieSlice
Putlmage
PutPixel
Rectangle
Sector

ClearViewPort
Close.Graph
DetectGraph

'.

,
:

409
410
411
411
412
413
413
414
414
414
415
415
416
416
417
417
417
418
418
419
419
420
420
420
421
421
...422
423
423
424
424
425
426
427
427
427
427
428
429
430
...431
432
433
434
,
434
435
436
436
437
438
439
439
440
441
442
443
444
444
445
445
446
446

Turbo Pascal 7.0 13


GetArcCoords
GetAspectRatio
GetDefaultPalette
GetFillPattern
GetFillSettings
GetLineSettings
GetModeRange
GetPalette
GetViewSettings
GraphDefaults
InitGraph
RestoreCRTMode
SetActivePage
SetAIIPalette
SetAspectRatio.
SetBkColor
SetColor
SetFHIPattern
SetFillStyle
SetGraphBufSize
SetGraphMode
SetLineStyle
SetPalette
SetRGBPalette
SetTextJustify
SetTextStyle
SetUserCharSize
SetViewPort
SetVisualPage
Strings

StrCat
StrComp
StrCopy
StrECopy
StrEnd
..
StrlComp
StrLCat
StrLCornp
,
StrLCopy
StrLen
StrLIComp
StrLower
StrMove
StrNew
StrPas
StrPCopy
StrPos
'
StrRScan
StrScan
StrUpper

StrDispose

447
447
448
449
449
450
451
.452
453
454
454
.454
455
455
456
457
458
,. 458
458
459
460
461
462
463
464
465
466
467
468
469
469
469
469
470
470
471
471
..472
472
473
474
474
475
475
476
476
477
477
478
478
..479
.479
479

'.

>.

3.


MS-DOS
-

480

480
488
489
489
489
490


, , Turbo Pascal 7.0.
Borland 1980- , Turbo Pascal 1997 ,
, -.
, 4 , " ^
".
Turbo Pascal 7.0, , Pascal.
, .

, Turbo Vision.
.
, , ,
.
, , , , ,
,
Pascal.
,
.
, , '
Pascal, Pascal,
" " ,
""
BIOS/DOS 8x86.
, . ,
.

TURBO PASCAL
i

, .
,
. (, , ..).

.
.
. .pas,
. tpu.
14.

.
Turbo Pascal ,
. , ( ).
BGI. ,
. .bgi . . chr .
BIN. Turbo Pascal.
: turbo. ^; turbo. tpl Turbo Pasca;

16

1.

tpc. exe Turbo Pascal (


).
13.

SOURCE. .pas
.
UNITS. , . tpu. . .
Turbo Pascal .
.
Turbo Pascal,
.
. , tpc.exe.
.
Turbo Pascal, : , , .
.
Turbo Pascal, .

Turbo Pascal
Turbo Pascal
Turbo Pascal turbo.exe.
Turbo Pascal, . 1.1.

-
File Edit Search Run

Compile

Debug

Tools

Options

Window


Help
I

_ 1
'

!
-1

'-

' ,;

'-

J
^

' ; '"

1
I PI Help F2 Save
L

_,.

-, ..:

-.

F3 Open

:.:

ftlt*F9

\:

Compile

;;

9 Hake flit* .t.n .". . j y_ijijh4Ji-dmm^

. 1.1. Turbo Pascal

Turbo Pascal ( turbo. exe)


Borland Pascal ( bp.exe), MS-DOS,
Windows. Turbo Pascal Borland Pascal.
Turbo Pascal MS-DOS.
Windows,
turbo. exe .
MS-DOS.
| | | MS-DOS.

18

1. Turbo Pascal

- , : Explorer, Windows
Commander, Norton Commander, Volkov Commander, Far ..
| . Turbo Pascal
Windows.
Turbo Pascal - , , keyrus. comv
- Turbo Pascal, turbo. exe MS-DOS
DOS- .
.


Turbo Pascal
: , , .


, <F10>.
-
<Alt> , . ,
File <Alt+F>. . ,
, .
File , , DOS Shell ( )
Exit ().
Edit , .
Search ,
.
Run. ( Run), . ,
Parameters,
.
Compile ,
.
Debug , .
Tools , ,
, Turbo Assembler.
Options ,
.
Window , .
Help , .

. , File | Save ,<2>.
.

19


, , , . Turbo Pascal
. Turbo Pascal ,
. .
, .


Turbo Pascal
Turbo Pascal
(. . 1.1).
. .
. , .
.
. [], , Help (. 1.2). , , , . 1.1.
. . :
, .
.
. .
: , -
; , ,
' ; ,
.
. . 1.1

.
1.1.


->
<->

<t>

<4>

<Ctrl+<->

<Ctrl+->>

<Ctrl+W>

<Ctrl+Z>
<Home>

20

1. Turbo Pascal

1.1

<End>


(
)
( )
()
()

<PgUp>
<PgDn>
<Ctrl+Home>

<Ctrl+End>
<Ctrl+PgUp>
<Ctrl+PgDn>

. Turbo Pascal .
,
.

Turbo Pascal
Turbo Pascal . , Debug | Watch, Watches, ( "" ). <F1>,
Help (. 1.2).
File

Edit

Search Bun

Corauile

Debu

Tools

NONflrffiffllJ.PHS

Help

Cations Window Hel



=3=tn=n

watch expressions

Fl Hel on help ftlt+Fl Preuious tonic

Shift+Fi Heln index

Esc

. 1.2. Turbo Pascal


, ,
. , . , (. . 1.1).
-

27

Turbo Pascal
, ,
(. . 1.9). , .



1. ProgOl.pas, File | Save
<F2>.
2. Options | Save, . ,
Turbo Pascal , .
3. Turbo Pascal, File | Exit
<Alt+X>.
4. Turbo Pascal . , Options | Save,
. , ProgOl.pas .

Open a File
,
File | Open <F3>.
Open a File (. 1.10).

. 1.10.
Files,
Name. , ,
Open <Enter>. , Turbo Pascal
. "" , .
File, , , Name Open a File.

____

,
,
.

, ,
, , , . .
( ), , .
Writeln, ProgOl .pas (. 1.1).
, , , , .

, ..

Pascal
Pascal.
1. ,
. , ,
.
2. .
3. 127 .
4. , . , NumberOfBooks , numberofbooks.

,
. , NumberOf Books , N.

,
. , -

29

,
.



const :
I =
, , begin.
( 2.1) ProgOl (. 1.1) (. 2.1).
2.1.
program ProgOl;
const
MyName = ' ';
MyBirthDate = '7 1974 '
MyBirthYear = 1974;
begin
Writeln(', !');
Writeln(' ', MyName);
WritelnCH ' , MyBirthDate) ;
end.
, !

7 1974
. 2.1. ProgOl .pas

Pascal , . .
:
True. "".
False. "".
Maxint. integer ( ), 32767.

, . ,
.
, - .


var

30

2. , ,

_ :
, begin
.
ProgOl (. 2.1)
( 2.2).
2.2.
program ProgOl;
const
MyName = ' ';
MyBirthDate = '7 1974 ' ;
MyBirthYear = 1974;
var
CurrentYear, MyAge: integer;
begin
Writeln(', ! ' ) ;
W r i t e l n ( ' ' , MyName);
W r i t e l n ( ' ', MyBirthDate);
CurrentYear := 2003;
MyAge := CurrentYear - MyBirthYear;
Writeln(' ' , MyAge, ' ' ) ;
end.


. :
:=
( =.)
, .
ProgOl (. 2.2) CurrentYear
, integer.
200300, ,
integer, -32768 32767. CurrentYear
' 2 0 0 3 ' , . ,
, , var.
,
. , real ( )
.
( ).


, ,
. .
, ProgOl MyName string MyBirthYear integer, .

31

Pascal .
. :
const : = ;
, ProgOl MyBirthYear :
MyBirthYear: integer = 1974;



. , "+" . . ,
ProgOl (. 2.2).
CurrentYear := 2003;
MyAge := CurrentYear - MyBirthYear;
, .

>;

,
(). . 2.1.
2.1. Pascal

+
*

div

mod

not

and
or

""
""

xor

""

<>

<

>

<=
>=

()

not

and

32

2. , ,

2.1

or

()

shl
shr

, (:=)
, .


.
, .
:
^
not ;
- ( ) ;
in - (^ );
@
( 11).
.


.

. 2.2.
2.2. Pascal

Not
*,

/,

div,

mod,

and,

shl,

+, -, or, xor
=, <>, <, >, <=, >=, in

shr

not, and, or xor,. a


.
, Pascal.
,


, (not, and, or xor) () True ("")
False (""). boolean, (=, >, <, >=, <=, )
.
not
.

33

, boolean True,
not A

False ( ).
. 2.3.
2.3. and, or

and

or

False
False
True
True

False
True

False
False
False
True

False
True
True
True

False
True
True
False

False
True

, . 2.3,
.
and ( "") ( True) , True.
or ( "") ( True) ,
True.

( "")
( True) ,
.
. Turbo Pascal
File | New, ,
BoolOp.pas. , 2.3, File | Open (<F3>).
BoolOp.pas 02.
2.3. BoolOp.pas
program BoolOp;

var
, : integer;
begin
Write ( ' : ');
'' "
Readln(A) ;
Write ( ' :' );
Readln () ;
WritelnCA = (', A = , ' ) ' ) ;
Writeln( 'A > ( ' , A > , ') ');
WritelnCA < (', A < , ' ) ' ) ;
Writeln('A >= (' , A >= B, ' ) ' ) ;
WritelnCA <= (' , A <= B, ' ) ' ) ;
Writeln,('A 0 (' , , ) ' ) ;

'

/''

end.

BoolOp Readln. Writeln Readln ,

34

2. , ,

, , . ,
, , .

,
<Enter>.
,
Readln, :
Write(' :');
Readln(,);
, ,
<Enter>, .
,
<Alt+F5>. - ,
. , 1, 2,
, . 2.2.
:1
: 2,
= (FALSE)
> (FALSE)
< (TRUE)
>= (FALSE)
<= (TRUE)
(TRUE)
. 2.2. .pas
, .pas , Turbo Pascal " File | New, . , ,
BoolOp2 .pas, , 2.4, File | Open (<F3>).
2.4. 2 . pas
program BoolOp2;
* fl
var
, , : integer;
begin
Writeln(' , , : ' ) ;
Readln(,,);

Write(' - ');
Writeln (( > ) and (A < );
Write(' - ');
Writeln(( = ) or ( = ));
Write(' - ');
Writeln < ) and ( ( > ) or ( = ) ) ) ;
Write(' - ' ) ;

35

2.4
Writeln(not ( ( = ) or (A = ) ) ) ;
end.
102
, 2, 1 3. . 2.3.

, ,
: <>, <> <Enter>.
. 2.3 , <Enter>.
,,:
2
1
3

- TRUE
- FALSE
- FALSE
- TRUE
. 2.3. BoolOp2 .pas

102.
. . , A and or
and, or. A and (
or ) , , and. , , .
. , not ( ( = )
or ( = ) ) =, or,
not.


" ". , ProgOl.pas (. 2.2) MyAge
integer. , . ,
, , . .
.
Pascal .
, . :
;
boolean;
;
;
char;
.
. :
;
;
;
.
;
;
;
, .
Turbo Pascal . , , .
. ,
, .
:
type _ = _;
, 2.


Pascal . 3.1.
3.1. Pascal


byte
0..255
shortint
-128..127
integer
-32768.. 32767


3.1

word
longint

37

0.. 65535
-21 47483648 . .21 47483647

byte shortint , integer word , longint .



.
0 9. 0 15, 10 15
F. .
, . 3.2.
3.2.

0
1
2
3
4
5
6
7
8
9

0000
0001
0010
0011
0100
0101
0110

0111
1000
1001
1010
1011
1100
1101
1110

1111

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Pascal . , $. . 3.3.
3.3.

1
1
1*16 = 1*1 = 1

10
2F

*1 6 =12*1 6 = 12*1
1

1*16 + 0*16 = 1*16 + 0


1

2*16 + F*16 = 2*16 + 15

12
16
47

38

3.

3.3

21

2*162 + *161+1*16 =
2*256 + 10*16 + 1*1 =
512 + 160 + 1

673

FFFF

F*163 + F*162 + F*161 + F*16 =


15*4096 + 15*256 + 15*16 + 15 =
61440 + 3840 + 240 + 15

65535

, , . , boolean.


Turbo Pascal File |
New, ,
IntTypes .pas. , 3.1, File | Open (<F3>).

3.1. IntTypes.pas
program IntTypes;
var
NumByte: byte;
NumShort: shortint;
Numlnt: integer;
NumWord: word;
NumLong: longint;
begin
NumLong := 100000;
NumWord := NumLong div 3;
Numlnt :== $FF + 1;
NumShort := NumLong mod 3;
NumByte : = Numlnt;
1
writeln('NumLong = ,NumLong);
writeln('NumWord = 1,NumWord);
writeln('Numlnt = ',Numlnt);
writeln('NumShort = ',NumShort)
writeln('NumByte = ',NumByte);
end.
, <Ctrl+F9>, , <Alt+F5>. , . 3.1.
IntTypes div mod. div . 100000 3
NumWord = 33333. 100000 3
(), mod,

39

NumShort. Numlnt FF . FF
255 (F*16! + F*16 = 15*16 + 15*1 = 240 + 15 = 255). 255 256,
NumByte. NumByte 256,
? , NumByte byte, 255. , . byte ,
. . 3.4.
NumLong = 100000
NumWord = 33333
Numlnt = 256
NumShort = 1
NumByte = 0
. 3.1. IntTypes. pas
3.4.
-

00000000
00000001

1*2

0
1

00000010

1*21 +0*2 = 2 + 0

0000001 1

1*2 + 1*2 = 2 + 1

00000100

1*2 + 0*2 + 0*2 = 4 + 0 + 0

11111110

1*27+1*26+1*25+1*24+1*23+1*22+1*2
1
+0*2= 128 + 64 + 32 + 16 + 8 + 4 +

254

11111111

2+0

1 *27+1 *26+1 *25+1 *24+ 1 *23+1 *22+1 *2 255


1+1*2= 128 + 64 + 32 + 16 + 8 + 4 +'
2+1

shortint , ( )
( "", ""). , , shortint 01111111 = 1*26 + 1*25 +
24+1*23+1*22+1*21 + 1*2 =64 + 32 + 16 + 8 + 4 + 2 + 1 = 127.
256 :
100000000 = 1*28.' , byte
256, , , , 0. ,
, ( ), .

40

3.


(<< . " " . 2).
Turbo Pascal File | New, ,
BitOp.pas. , 3.2,
File | Open (<F3>).
3.2. BitOp. pas
program BitOp;

var
A, B: byte;
begin

A := 11;
:= 6;

{00001011}
{00000110}

writeln ( ' A = ' ,A);


writelnf'B = ' , B);
writeln ( 'not A _ 1 I not A);
writeln (A and = ', A and B);
writeln ( A or = ', A or ) f
writeln ( 'A xor = ', A xor B);
writeln ( 'A shl 1 = ', A shl 1);
writeln ( 'B shr 2 = ', shr 2);

end.

{11110100 = 244}
{00000010
{00001111
{00001101
{00010110
{00000001

=
=
=
=
=

2}
15}
13}
22}
1}

, , <Ctrl+F9>. , . 3.2.
= 11
= 6
not A = 244
A and = 2
A or = 15
= 13
A shl 1 = 22
shr 2 = 1

. 3.2. BitOp.pas
, ,
.
not . ,
. 00001011 ( 11) 11110100 ( 244).
and , or , . and,
or , . 3.5.
, . 3.5,
.
and, 1 , 1.

41

3.5. and, or

0
0
1
1

0
1
0
1

and

0
0
0

or
0
1
1
1

0
1
1
0

or,
1 ,
1.
,
1 ,
.

shl , shr
, .
BitOp 00001011.
(A shl 1) 00010110 ( 22). ,
00000110.
, ( shr 2)
00000001 ( 1).

Pascal . 3.6.
3.6. Pascal


real
2,9*1(39..1,7*1038
single
double
extended
comp

38

1,5*10^ ..3,4*10
324

308

5*10" ..1,7*
.,i9M Q-4951 ,1|104932
63

63

-2 +1..2 -1


11-12

7-8
15-16
19-20
19-20

real ,
single , double comp ,
extended .
Pascal
, <><>. , 0 . 2 2 2 222-03,
1000 .12 1. 00012+03.

+(), - (), * () / (), .
, , . , .

42

3.


char
ASCII (American Standard Code for Information Interchange
' ).
0 255.
.
ASCII .
char , :
' ' , ' ' ( ), ' ' (), '-'. .
. Turbo Pascal ,
CharType. pas. , 3.3,
File | Open (<F3>).
3.3. CharType. pas
program CharType;
var
Letter: char;

Code: byte;
begin
Write(' :');
Readln(Letter);
Writeln(' ', Letter, ' - ', ord(Letter))
Write(' :');
Readln(Code);
Writeln(' ', Code, ' - ', chr(Code));
Read(Letter);
end.
Read CharType.
Read ,
, - . ,
, Turbo Pascal,
.
CharType ,
Letter. ord . Code, chr.
,
.
'


boolean " ".
: True ("") False (""). boolean
.

43


, .
:
type _ = (!, ..., )
, Digits, :
type Digits = (Zero, One, Two, Three);
Digits:
var CurDigit: Digits;
CurDigit, Digits:
var CurDigit: (Zero, One, Two, Three);
. 0, 1 .. , , Ord
( " "). , Ord (One) 1.
.
, CurDigit Four
integer, :
Four := Ord(One) + Ord(Three);
. ,
Writeln (One < Three); TRUE.

Writeln (One), , . , Pascal ,


.



.
, .
:
const
,
Monday = 1; Tuesday = 2; Wednesday = 3; Thursday = 4;
Friday = 5; Saturday = 6; Sunday = 7;
type
ABC = 'A'..'Z';
Digits = 0..9;
WorkDays = Monday..Friday;
Holidays = Saturday..Sunday;


, ,
. , ; , ?
. ,

( , , .).

(Write, Writeln) (Read, Readln) Pascal. . , , , . , .


Read
Readln. . , Read , ,
Readln . Read , , Readln
( <Enter>). .
( ) integer Read:
Read(A);
Read();

,
:
12 100<Enter>
12<Enter>100<Enter>
12<Tab>100<Enter>
, Read <Enter>, ,
.
Read Readln:
Readln(A);
Readln();

45

, ,
<Enter>:
12<Enter>100<Enter>

, Readln ,
.
Read Readln .
:
Read(F, XI, 2,

..., ) ;

F , , XI, 2, . .., , .
10.
:
Read(XI, 2, . . ., ) ;
.
|
XI, 2, . . . , , .
. , XI integer, ,
-.
\

, Write Writeln. Writeln Write ,


.
Write ( Writeln) .
:
W r i t e ( F , XI, 2, . . . , ) ;
|
F , , XI, 2, . . ., .
:
W r i t e ( X I , 2, . . . , ) ;


Write Writeln
.


:
| : __
|

, . , :

46

4.

Writeln('', '', '');


1
Writeln(' , '', ''!

:
Writeln('':6, '':9, '':14);
Writeln('':6, '':9, '':14);
, 6, 9 11 :


, , .


, . . , :
| W r i t e l n ( 5 . 2 : 1 0 , 0.324:11);

:
5.200+00 3.2400-01

5.2 10 : _5.200+00 (
). 0 . 3 2 4 11 : _3.2400-01.

, , :
I :__:__
Writeln
:
| Writeln(5.2:10:4, 0.324:10:4);
:
|

5.2000

0.3240
*


, 10, :
.
Readln Writeln.

Text. Turbo Pascal

47

Text 10.pas. , 4.1,


File | Open (<F3>).
4.1. TextlO.pas
program TextIO;
var

F: Text;
FirstName, FatherName, LastName: string;
begin
{ }
Write(' :');
Readln(FirstName);
Write(' :');
Readln(FatherName);
Write(' :');
Readln(LastName);
{ }
Assign(F,'MyName.txt') ;
Rewrite(F);
Writeln(F,FirstName);
Writeln(F,FatherName);
Writeln(F,LastName);
Close(F);
{ }
Reset OF);
Readln(F,FirstName);
Readln(F,FatherName);
Readln(F,LastName);
Close(F);
{ )
Writeln(' : ', FirstName);
Writeln(' : ',FatherName);
Writeln(' : ',LastName);
end.

TextIO, Text, string. 1 255


.
string 8.

FirstName, FatherName LastName. , F, Readln.
F Assign.
F Rewrite.

, ,
, .
'

48

4.

FirstName, FatherName LastName


F, Close.
Reset,
FirstName, FatherName LastName , . FirstName, FatherName
LastName.

-
.
. Pascal :
if case.
/

if
if ( "if "")
:
if _ then _ ;

if _ then _
else _ ;
True, , then, ( "then" "")
, else ( "else" "").

, ,
then else, (";") .


, " ". ( )
. , ,
.
begin end. "", . ,
begin end,
.
then else if
, . case, , . .
if A > then
begin
:= ;

50

5.

:= 100;
end;
:= 200;

:= := 100 , > ,: = ,
:= 100 . begin end,
> := 200.
if else:
if A > then
begin
:= ;

:= 100;
end else
begin
:= ;
:= 200;
end;
:= 200;

> ,
else. , then else ";" .
begin end if,
else. :
| if > then if > then := else A := ;
else if
> . if, if :
if A > then
begin
if > then A := ;
end else A := ;

if
if ,

/ Turbo Pascal
HexToDec.pas. ,
5.1, File | Open
5.1. HexToDec.pas
program HexToDec;
var
Hex: char;

case

51

5.1
begin
Write(' :');
Readln(Hex);
if Hex in t'O'..'9']
then Writeln(Hex,' = ',Hex)
else if Hex,in ['A'..'F']
then Writeln(Hex,' = ', Ord(Hex)-55)
else if Hex in ['a' . . 'f ]
then Writeln(Hex,' = ', Ord(Hex)-87)
else Writelr(' !');
Read(Hex);
end.
HexToDec , . in.
, , , . if , ' 0' . . ' 9'. , , ,
if. if ,
' ' . . ' F ' . , Ord ASCII , 55. ,
10, ' ' ASCII 65. , 55.
, ,
ASCII 87.
, ' 0 ' . . ' 9 ' , ' ' . . ' F ' , ' ' . . ' f , ,
.
Read (Hex) <Enter>.

case

case ,
. case
. , HexToDec ( 5.1) case, Hex . if,
case :
case _ of
!: _;
:

end;

52

5.

case _ of
1: _ ;
: _
else _
end;
else ,
. , else , , end, case.
, , , case-end.
byte,
shortint integer; boolean char.
case,
5.2.
5.2. case
case A of
1: Writeln('A=l');
2, 4: Writeln('A=2 =4');
3, 5.. 10: Writeln('A=4 5 10')
Ord('F'): Writeln('A=70');
end;

case Ch of
'D': Writeln(' D');
'E', 'F': Writeln(' F');
'A'..'C': Writeln('; ');
Chr(71): Writeln(' G');
end;
5.2,
, , , .

case
HexToDec ( 5.1),
if case. Turbo Pascal HexToDec.pas, File | Save As HexToD_2 .pas.
HexToD_2 .pas , 5.3.
5.3. HexToD 2. pas
program HexToD_2;
var

Hex: char;
begin
Write(' :');
Readln(Hex);

case

53

5.3
case Hex of
1
0'..'9': Writeln(Hex,' = ', Hex);
'A'..'F': Writeln(Hex,' = ', ord(Hex)-55);
'a'-.-f1: Writeln(Hex,' = ', ord(Hex)-87) ;
else Writeln(' !1);
end;
Read(Hex);
end.
, , if.

goto
HexToDec, ,
Re ad In.
, ,
goto.
goto , - . , begin label, , (":").
HexToD_2 ( 5.3), , 5.4,
File | Open (<F3>).
.
5.4. HexToD_2. pas
program HexToD_2;
label
Ml;
var
Hex: char;
begin
Ml:
Write(' :');
Readln(Hex);
case Hex of
'0'..'9': Writeln(Hex,' = ',Hex);
'A'..'F': Writeln(Hex,' = ', ord(Hex)-55);
'a'..'f: Writeln(Hex,' = ', ord(Hex)-87);
else begin
Writeln(' !');
goto Ml;
end;
end;
Read(Hex);
end.

Ml . -

54

5.

goto ,
, (
). .

goto , .
, goto.

case
,
. Turbo Pascal , TheDay.pas, , . 5.5, File | Open
5.5. TheDay.pas
program TheDay;
label
Ml;
var

Hour: byte;
begin
Ml:

Write(' 0 24:');
Readln(Hour);
,
if not (Hour in [0..24]) then goto Ml;
case Hour of
22..24, 0..5: Writeln('');
6.. 9: Writeln('');
10.. 13, 15..18: Writeln('');
14: Writeln('');
19..21: Writeln('');
end;
end.


Hour case.

goto. , .

6

- , .
Pascal : for, while repeat. for , , while repeat.

for
for
( ), .
for. , :
for _ := _ to _ do
_ ;
, :
for _ := _ to _ downto
_ ;
,
for , . for. Turbo Pascal
For_l.pas , 6.1, File | Open (<F3>).

"" '

6.1. For_l.pas
program for_l;
var
i, n: integer;
factorial: longint;
begin
Write(' :');
Readln(n);
factorial := 1;
for i := 1 to n do -factorial := factorial
factorial);
Writeln('
n,
end.
1*2*3*...*, n
. for

56

6.

i 1 . ( factorial) i. , 4. (. 6.1).
6.1. 6.1

1
2
3
4

factorial

1
1
2
6

factorial

1*1 = 1
1*2 = 2
2*3 = 6
6*4 = 24

,
downto. Turbo Pascal , For_2.pas ,
6.2, File |

6.2. For_2 . pas

program for_2;
var
: char;
s: string;
begin
for := 'Z' downto 'A' do s := s + c;
writeln(s);
end.
for_2 char,
' Z ' ( 90) ' ' ( 65).
( s string), Z . (. 6.2).
6.2. 6.2

s
s




Z
Y
X

Z
ZY

Z
ZY
ZYX

ZYXWVUTSRQPONMLKJIHGFEDC

ZYXWVUTSRQPONMLKJI HGFEDCB

ZYXWVUTSRQPONMLKJIHGFEDCB

ZYXWVUTSRQPONMLKJIHGFEDCBA

for .

while

57


, .
, .
-.
break (
), - for .

while
while :
while __ do _;
while , True. , ( , while) , False.
while.
Turbo Pascal WhileEx.pas
, 6.3,
File | Open (<F3>).
6.3. WhileEx. pas
program WhileEx;
var
CharCode: integer;
begin
CharCode := 0;
while CharCode <= 255 do
begin
if Chr(CharCode) in ['0'..'9'] then
Writeln('Kofl '", Chr(CharCode), '" - *,.harCode)
Inc(CharCode);
end;
end.

, . while
ASCII ( 0 255).
CharCode integer, .
CharCode 0, , 255, . CharCode <= 255 False.
CharCode Inc. , , , .
( WhileEx),
. , inc(N) N := N + 1, ,
, Inc ( N , 2 ) N := N + 2.

58

6.

Dec , Inc.

""
while repeat "" .
.
1. , ,
, True.
2. .
,
WhileEx Inc (CharCode). CharCode
0, CharCode <= 255
True.
"" , False
. ,
WhileEx CharCode integer byte,
, 255. , True, "".
, while repeat, , .

"",
<Ctrl+C>
<ctrl+Pause (Break) >. ,
Turbo Pascal, .
13.

repeat
repeat :
repeat __ until __;
repeat while .
. ,
, repeat until .
repeat ,
True.

repeat , . , TheDay,( 5.5),

59

.
Turbo Pascal The Day. pas ( File | Open (<F3>)), Ml:
label
Ml;


Ml:

Write(' 0 24:');
Readln(Hour);
if not (Hour in [0..24]) then goto Ml;
repeat:
repeat
Write(' 0 24:');
Readln(Hour);
until Hour in [0..24];
,
Hour , 0 24. ,
goto.

, repeat
begin end .


Pascal: Break Continue. Break
, ,
for, while repeat. Continue .
.
Turbo Pascal , BrConEx.pas,
, 6.4,
File | Open (<F3>).
6.4. BrConEx. pas
program BrConEx;
var
i: integer;
begin
for i := 1 to 20 do
begin
if (i mod 2) = 0 { )
then Continue
else if i > 10 then Break;
Writeln(i);
end;
end.

60

6.

1 10.
1 20 - i.
2 , , , Continue , Writeln (i) . i , 10. i 10, for break,
i Writeln.


, , "".
, . .
,
. , ,
.
Pascal .
, .
Readln, Writeln, Break .
, , . , , ,
. , Chr Ord.
. , , . ,
, . .

. (":"),
(";").
, .
.
.
.

.
, :
| procedure Proc(a, b: integer; : char);
:
Numl := 1;
Num2 := 2;
Ch := ' ' ;

62

7.

Proc(Numl, Num2, Ch) ;


Proc(12, Numl + Num2, 'D');
Proc(0, Ord('A'), Chr(Numl));
, :
Proc(Numl, Num2); { }
Proc(Ch, Numl, Num2); { }
Proc(12.3, Num2, Ch); { 1- }
, Pascal
: .



. , uses, .
14.
,
Crt,
:
>
program"SomeName;
uses Crt;
.
System , , Turbo Pascal. , uses .
Crt , .
Dos , , MS-DOS.
Graph ,
CGA, EGA, VGA, HERC, IBM 3270, MCGA 6330.
Graphs , ,
.
Overlay ; .
Printer , .
Turbo3 , Turbo Pascal 3.0.
Turbo Vision -
.
.
, DOS 3 4.

Turbo Vision 18.


.

63


.
, ,
.
. , .
, begin .
,
uses.

:
procedure _ () ;
const _;
type _;
var _;
____
begin

end;

, , , , , . ,
( ) , , , , .
,
,
"". ,
, , .
,
, .
,
procedure ShowMessage(s: string; len: integer);
begin
Writeln(s:len);
end;

: '
( ShowMessage('Hello!',10);
, :
procedure ShowHello;
begin
Writelnf Hello! ' ) ;
end;

64

7.

, :
[ ShowHello;
, ,
, , Break Continue.
.
Turbo Pascal , ProcEx.pas
, 7.1, File | Open (<F3>).
7.1. ProcEx.pas
program ProcEx;
procedure SortABC(AscOrder: boolean);
var
c: char;
begin
if AscOrder
' A ' to ' Z ' do W r i t e ( c )
then for
' Z 1 downto ' A ' dp W r i t e ( c )
else f o r
WritelnC ' )
end;

begin
SortABC(True);
SortABC(False)
end.

ProcEx SortABC AscOrder boolean. True,


, ,
. SortABC.
True, False.
ProcEx ,
. 7.1.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZYXWVUTSRQPONMLKJIHGFEDCBA

. 7.1. ProcEx. pas

:
procedure _ () : __;
const _;
type _;
var _;
____
begin

end;

65

, ,
.
, . .
' . , ,
.
, . , 5
. Turbo Pascal
, HexToD_3 .pas , 7.2,
File | Open (<F3>).
7.2. HexToD_3. pas/
program HexToD_3;

var

HexNum: string;
i: integer;
DecDig, DecNum: longint;
IsError: boolean;
{
()*(16)}
function HexToDecimal(HexDig: char; pow: byte): longint;
{ }
function Power(Num, Pow: byte): longint;
var
i: integer;
Res: longint;
begin
Res := 1;
for i := 1 to Pow do Res := Res * Num;
Power := Res;
end;
begin
case HexDig of
''.-'': HexToDecimal
'A'..'F': HexToDecimal
1
a'..'f': HexToDecimal
else HexToDecimal := -1;
end;
end;

:= (Ord(HexDig) - 48) * Power(16, pow)


:= (Ord(HexDig) - 55) * Power(16, pow)
:= (Ord(HexDig) - 87) * Power(16, pow)
{ }

begin
repeat
Write(' :');
Readln(HexNum);
DecNum := 0;
isError := False; {, }

66

7.

7.2
for i := 1 to Length(HexNum) do (
}
begin
(
}
DecDig:= HexToDecimal(HexNumfi],length(HexNum)-i);
if DecDig >= 0 ( ,}
then inc(DecNum, DecDig) (
, }
else begin
,
( ,}
isError := True; ( ,
}
Writeln(' !');
break; ( for}
end;
end;
until not isError; ( ,
repeat}
Writeln' = ', DecNum);
end.
HexToD_3 ,
, .
HexToDecimal. . , A1FD,
40960 (10*1 3), 1 256 (1*162), F
240 (15*16'), D 13 (13*16). , , , 16, ,
.
, .
HexToDecimal. HexDig char,
pow byte.
16 pow Power,
HexToDecimal. , - Power
HexToDecimal. Power
, Num. Pow.
, HexToDecimal. case,
5. case .
, , -1.
. repeat. ,
isError.

67

for, length.
string .
isError
Fatlse. , isError ,
repeat. HexToDecimal (HexToDecimal = -1),
isError True, for break, repeat .
, HexToDecimal, DecDig,
DecNum.
repeat DecNum
.


:
, ;
, ;
-;
-;
.
.

,
, ,
.
, :
procedure SortABC(AscOrder: boolean);
function HexToDecimal(HexDig: char; pow: byte): longint;
function Power(Num, Pow: byte): longint;

. . ,
AscOrder SortABC True False,
pow HexToDecimal
length(HexNum)-i.
, . ,
,
, - ,
.
\
^

,
, , .
var . , -

68

7.

var, .
,
, (, , ). .
, 7.3. ( VarParam.pas File | Open (<F3>) ).
7.3. VarParam. pas
program VarParam;

var
vMod, vDiv: integer;
function Divide(a,b: integer; var rMod: integer): integer;
begin
rMod := a mod b;
divide :'= a div b;
end;
begin
vDiv := Divide(10, 3, vMod);
Writeln('vDiv=',vDiv);
Writeln('vMod=',vMod) ;
end.
Divide VarParam , rMod . , : rMod.
Divide rMod
vMod. 1 (10 mod 3).


, , . - , . - :
_(_)
, VarParam (.
7.3), rMod :
function Divide(a,b: integer; var rMod):
, rMod
mod b integer:
integer(rMod) := a mod b;
rMod char,
:

69

char(rMod) := ' ' ;


vMod '' ( 65).

- -
Pascal .
.
. ,
:
type
Operation = function(,: integer): integer;
, ,
7.4.
7.4.
{$F+}
function Addition(,: integer): integer;
begin
Addition := A + ;
end;
function Subtraction(,: integer): integer;
begin
Subtraction := A - B;
end;
{$F-}

{$F+} () (far) . ,
- -,
{$ F+} .
13.

, :
function SomeOp(A,B: integer; Op: Operation): integer;
begin
SomeOp := Op(A, B);
end;
, . Addition, , Subtraction, .
SomeOp:
W r i t e l n ( 4 0 + 5 ' , SomeOp (10, 5,Addition) ;
W r i t e l n ( ' 1 0 - 5', SomeOp(10,5,Subtraction);

:

70

7.

10 + 5 = 15
10 - 5 = 5

,, ,
, ,
inline interrupt.
" ".

. .

for. .
Turbo Pascal ,
FactorEx.pas , 7.5,
File | Open (<F3>).
7.5. FactorEx.pas
program FactorEx;
var
Num: integer;
function Factorial(N: integer): longint;
begin
if N = 1

then Factorial := 1
else Factorial := N * Factorial(N - 1);
end;

begin
Write(' :');
- Readln(Num);
,
Writeln(' ',Num,' = ', Factorial(Num));

end.

'..

, Num=4.
Factorial 3 (N - 1). , N 1 Factorial (1)
Factorial (2) 1. Factorial (2) 2 ( 2) Factortial ( 3 ) .
, Factorial (3) 3 ( 6) Factorial ( 4 ) . Factorial ( 4 ) , " " , 4
24.


Pascal ,
. : .

71

external
:
[procedure SetMode(Mode: W o r d ) ; external; ($L CURSOR.OBJ}

external .
, , , ( 15).
{$L}
, Pascal. ,
, SetMode,
cursor.obj, .

forward
Pascal
. , ,
, .
forward.
forward,
.
:
I procedure Proc(, : integer); forward;

:
procedure Proc;
begin
end;

, ,
, , Pascal
, ""

Turbo Pascal 7.0

.
.
, , " ". , ,
.


. , ,
,
, , .
, .

ISBN 966-7323-22-6
: 216., .
:
170x240
(70x100/16)

Internet

. , , "
" .
, , . 17 .
.. . ,
,
.
- , : " ", " ", ' ", " ", " ", "
" ..

1.
2.
3.
4. -
5.
6.
7.
8.
9.
10.
11.
12.

1. Borland Pascal 7.0


2.
3.
4. -

II


, , : . ,
. ,
. , . , string char.
3, Pascal: , , , , , . , .
:
8 ;
9 ;
10 ;
11 ;
12 .


,
, - . string 4 "
", "".
, .

char 0 255 . , . string, , ,


. ,
255 .
:
const
MyS = ' ';
var
si: string;
{. 255 }
s2 : string[20]; { 20 }
s3: string[100]; { 100 }

begin
si := MyS;
s2 : ?= ' ';
s3 := si + ' - ' + s2; {' + '};
, .
( ) .
. :
var
si, s2: string;
len: byte;
sl[l] : = ' A ' ;

s2 := sl[l];
s 2 [ 2 ] :=sl[l];
len := O r d ( s 2 [ 0 ] )

{ si A'}
{ s2 = ''}
{ s2 = ''}
{ len = 2 s2}

75

, , ,
, . :
var
si, s2: string[5];
si := 'ABC'
s2 := si + ' D E F ' ;

{ s2 =

'ABODE'}

() +,
=, , >, <, >=, <=.
. ,

ASCII ( ASCII ). , '' = '' True,
. , '' < ''
False, ( ' ' )
( ' ' ) , ,
' ' ' '.
,
.

.
, , char.
, . . ,
.
(), . , . ,
, .
, , ,
, ..
:
[_] of _;
, ,
10 , :
type
MyArr = array[1..10] of integer;
var
A: MyArr;


var
A: array[1..10] of integer;
,
:

76

8.

[1] := 2;
[ 2 ] := [1] + 3;
[3] := [ 2 ] . , , :
type
ArrA: array[1..10] of integer;
ArrB: array[1..5] of ArrA;
var
B: ArrB;
To :
var
: array[1..5,1..10] of integer;

,
: "
, 5 10 ". :
[1,11 := 3;
[1,2] := [1,1] * 5;
[5,10] :=
:
: array[1..2,1..5,1..10] of integer; {}
D: array[1..2,1..2,1..3,1..4] of char; {}
. , :
|[1,1

[1,2],

... [1, [ 2 , 1 ] ,

[2,2]

... [5,10]

,
, ,
.
{$R+},
.
13.


. .
,
,
.

19.

77

Turbo Pascal SortStrs.pas


, 8.1, File | Open (<F3>).
8.1. SortStrs. pas
program SortStrs;
var
ArrOfS: array[1..5] of string;
ArrOfR: array[1..5] of string;
i/ jr P: byte;
s: string;
begin
for i := 1 to 5 do
begin

Write(' ' , i , ' - : ' ) ;


Readln(ArrOfS[i]);
end;
for i := 5 downto 1 do
begin
s := " ;
$

for j := 1 to 5 do
if A r r O f S [ j ] > s then
begin
s := A r r O f S [ j ] ; { "" }
p := j ;
{ }
end;
ArrOfS[p] := ' ' ; { "" }
ArrOfR[i] := s; { ""
}
end;
for i := 1 to 5 do w r i t e l n ( A r r O f R [ i ] ) ;
end.
SortStrs ArrOfS.
, s "" .
ArrOfS . ArrOfS ("" ) , , s, ArrOfR. ,
, "" ,
.
: ,
. Turbo
Pascal Average.pas ,
8.2, File |
Open (<F3>).
8.2. Average .pas
program Average;
var
A: array[1..5,1..5] of integer;
i, j: byte;

78

8.

8.2
sum: longint;
begin
Writeln(' :');
for i := 1 to 5 do
for j := 1 to 5 do Read(A[i,j]);
Writeln(' :');
for i := 1 to 5 do
begin
sum : 0;
for j := 1 to 5 do incfsum, A[i,j]);
Writeln(sum/5:8:2);
end;
end.
Average .
19.

, , , , , , .
,
"", 12.

,
. , ,
, .
Pascal , , [ 1 , 2 , 3 , 4 / 5 ] , [ ' A ' . . ' Z ' ] , [ 0 . . 1 0 , 100..110].
, [ ].
:
set

of _;
:

type
ABC = set of ' A ' . . ' Z ' ;
Digits = set of 0. . 9;
var
Caps: ABC;
Key: Digits;
Odds: set of byte;
Caps , Key
0 9, Odds
byte. 256,
0 255, integer .

,
(=, , >=, <=),
(+), (*), (-), in.
. 9.1.


, char , ,

80

9.

. Turbo Pascal
SetsEx.pas , 8.2,
File | Open (<F3>).
9.1. ,

>=
<

in

. ,
.

. ,

. , >= True
. , <= True
,
.
[1,2,3] + [3,4,5] = [1,2,3,4,5]
, , .
[1 ,2,3]* [3,4,5] = [3]
, , .
[1,2,3] -[3,4,5] = [1,2]
-
. in . , if
if ('(i = 0) or (i = 1) or (i = 2 ) ) and
((j= 3) or (j = 4) or (j = 5 ) ) .then ...

if (i in [0..2]) and (j in [ 3 . . 5 ] ) then ...

9.1. SetsEx.pas
program SetsEx;
var

si, s2: string;


i: byte;
Letters!, Letters2: set of char;
begin
Write(' 1- : ');
Readln(sl);
Write(' 2- : ');
Readln(s2);
for i := 1 to Length(si) do Lettersl := Lettersl + [sl[i]];
for i := 1 to Ord(s2[0]) do Letters2 := Letters2 + [s2[i]];
Writeln(', :');
Lettersl := Lettersl * Letters2;
for i := 0 to 255 do

81

9.1
end.

if C h r ( i )

in Lettersi then W r i t e ( C h r ( i ) ; 2 ) ;

, :
51 = ABABCDEEF
52 = WEAAAFXR

for si, Letter si. ,



.
I'Lettersl := Lettersl + s [ i ] ;

'

,
Lettersl char, . char , , :
| Lettersl := Lettersl + [ s [ i ] ] ;
Letters2.
si s2. Length, ,
, Ord.
for Lettersl Letters2
:
Lettersl = ' ' , ' ' , ' 1 , ' D 1 , ' 1 , ' F 1
Letters2 = ' W , ' 1 , ' ' , ' F 1 , ' X ' , ' R '
, , . ,
.
Lettersl := Lettersl * Letters2;
Lettersl Lettersl Letters2,
, :
Lettersl = ' ' , ' ' , ' F '

_____

ASCII Lettersl. , Writeln.

,
. , ? . . , , , . ,
?

82

9.

, , .
:
type
_ = record
_: _;
_: _;
end;

, Person, :
type
Person = record
LastName: string[20];
FirstName: string[20];
BirthYear: integer;
'--

end;

Person
:
var
Manl, 2: Person;
-
:
_._
/ 9.2 Manl 2.
9.2.
Manl.LastName := '';
Manl.FirstName := '';
Manl.BirthYear := 1974;
Man2.LastName := Manl.LastName;
Man2.FirstName := '';
Man2.BirthYear := Manl.BirthYear + 27;
, :
var
Family: array[1..3] of Person;
Family[1].FirstName := '';
Family[2].FirstName := ''
Family[3].FirstName := '';
Pascal , :
type
Complex = record
RealPart: real; { }

83

ImagePart: real; { }
end;

with
,
. Pascal with, :
with _ do _;
, Manl 2 ( 9.2)
, 9.3.
9.3. with
with Manl do
begin
LastName := '';
FirstName := '';
BirthYear := 1974;
end;
with Man2 do
begin
LastName := Manl.LastName;
FirstName := '';
BirthYear := Manl.BirthYear + 27;
end;
Pascal ( 9 ),
with :
[ with Reel, Rec2,

..., RecN do ...


,
. ,
, , .
. , case:
type
_ =
record
{ }
{ }
case _: __ of
_1: (: );
_:

end;

(:

);

84

9.

:
type
Car = record
Brand: string[20];
Year; integer;
case Kind: string[8] of
'': (Tonnage: real);
'': (Passengers: byte);
end;

Car . Brand
, Year . Tonnage
() real ,
Kind ' ' . , Passengers ()
byte , Kind
''.

.
,
.
, .


-. .
,
. Turbo Pascal
Audio.pas , 9.4, File | Open (<F3>).
9.4. Audio. pas
program Audio;
type
{ )
Track = record
Name: string[50]; { }
Hours: 0..3;
{}
, Minutes: 0..59;
{}
Seconds: 0..59;
{}
end;

{ }
CD = record
Author: string[20];
{}
Title: string[50];
{}
{}
Year: integer;
{}
Kind: string[10];
case Tracks: byte of { }
1: (Trackl: Track) { ,
}
[2..20]: (ATracks: array[1..20] of Track);
end;

85

9.4
var
: char;
CDData: CD;
i, j : byte;

{ )
procedure DataForTrack(var TrackData: Track);
begin
Write(': ');
Readln(TrackData.Name);
Write(' (): ');
Readln(TrackData.Hours);
Write(' (): ');
Readln(TrackData.Minutes) ;
Write(' (): ');
Readln(TrackData.Seconds) ;
end;
begin
i := 0;
repeat
inc(i);
Writeln(' ',i,'-M :');
\
Write(', : ');
Readln(CDData.Author) ;
Write(': ');
Readln(CDData.Title) ;
Write(': ');
Readl*i(CDData.Year) ;
Write('3KaHp (,,,,,,): ']
Readln(CDData.Kind);
Write(' : ');
Readln(CDData.Tracks);
for j := 1 to CDData.Tracks do
begin
Writeln(' ',j,'- :');
if CDData.Tracks = 1
then DataForTrack(CDData.Trackl)
else DataForTrack(CDData.ATracks[j]);
end;
Write(' (/)? ')
Readln();
until in ['N','n','H',''];
end.
Audio : Track CD. CD
-.
Track CD
. CDData CD.
repeat, ,
<>, <>,

<N> <>.

86

9.

, CDData.Tracks
1, Trackl Track. ,
ATracks Track.

DataForTrack, Track.
, CDData.Trackl,
CDData.ATracks.

10

, . "
" 4, Readln Writeln.
, , , . , ,

. , , , , , .
MS-DOS . , 1 8 ,
. .
, ,
. , Turbo Pascal turbo.exe. turbo
, . : !, @, # , % , , & , ( , ) , ' , ~, -,_.
, , . .
10.1 .
10.1.

ar j

asm
bak
bat
com
dat
doc
exe
gif
hip
ini
pas
pcx
pic

, ar j


()
64



GIF


Pascal
PCX
PIC

88

10.

10.1

,sys
tif
txt
zip

,

TIFF

, pkzip

,
.
, .
, , . , ,
. , , , .
, , . ,
.. , MS-DOS .
.
. ,
turbo.exe : e:\work\books\computer\
tp\bin\turbo. , : .

( : z:).
: b:,
. , , :,
.

Pascal
Pascal :
, .
,
256 ,
,
. .
,
- .

. Pascal, ,
^, .

,
(, F).
Assign, :

89

[ Assign(F, ' c : \ d o c s \ d o c l . t x t ' ) ;


F docl.txt, : docs.
Assign , . , . Pascal
: Reset Rewrite. Reset ,
Rewrite .
. Reset, , , . Rewrite.
, , Rewrite, .
Close, . , Assign. ,

:
Assign Reset/Rewrite (/) Close


Pascal,
: Rename Erase. Rename
. : , .
Erase , .
.


- Pascal
lOResult.
integer, . 0.
lOResult ,
-. {$ I}. lOResult , .
13.


, Text:
var
F: Text;

90

10.

,
Chr (13) C h r ( 1 0 ) . Reset
, Rewrite .
: Append. Rewrite , ,
.


Read Readln.
Read , a Readln
. (, ) :
Assign (F, 4.txt');
Reset(F);
Readln(F, s);
Readln(F, i);
Readln(F, r);
Close(F);


Write
Writeln. Writeln , .
( 10.1).
10.1.
var

F:
s:
i:
r:

Text;
string;
integer;
real;

Assign(F, 'l.txt')
Rewrite(F);
Writeln(F, s);
Writeln(F, i);
Writeln(F, r);
Close(F);


Reset , Read
Readln . Pascal , : Eoln,
Eof, SeekEoln SeekEof ( ).

91

Eoln True r
.
Eof True, .
SeekEoln True
.
SeekEof True .
Eof while , Eoln :
while not Eof(F) do readln (F,s);
while not Edln(F) do read(F, c);


,
. Turbo Pascal
FileCopy.pas ,
10.2, File | Open
10.2. FileCopy.pas
program FileCopy;
var

FFrom, FTo: Text;


NameFrom,NameTo,s: string;
isError: boolean;
begin
isError := True;
while- isError do
begin
Writeln(' , :');
Readln(NameFrom);
Assign(FFrom, NameFrom);
{$!-}
{ }
Reset(FFrom); { }
{$!+}
{ }
isError := lOResult > 0;
if isError then Writeln(' ! ');
end;

Writeln(' :');
Readln(NameTo);
Assign(FTo, NameTo);
Rewrite(FTo);
while not Eof(FFrom) do
begin
Readln(FFrom,s); { }
Writeln(FTo,s); { }
end;

Close(FTo);
Close(FFrom);
end.

92

10.

while
. ,
FFrom.
-
{$!-}. Reset
- {$!+}.
, lOResult ,
-, isError
True, while .
, isError False
while .
,
FTo, while FFrom FTo ,
FFrom, .. Eof (FFrom) True. Close.



FileCopy
, .
.
coml, com2, , 1, 2
3, .
con . ,
.
Iptl, Ipt2, Ipt3 , 1, 2 3,
.
.
, , con. ,
Iptl ( LPT1).


,
. , .
22.
, , file of _:
type
Rec = record

end;

93

var

Fl: file of .FileRec;


F2: file of real;
Fl Rec, F2
real.
,
.
SizeOf , (, SizeOf (Rec)).
, Seek:
|

Seek(F,

9);

F}

0, , ,
.
FilePos,
File Size. , F :
[ Seek(F, FileSize (F) ) ;

| Seek(F, FileSize (F) - 1 ) ;


Audio, (. 9.4). Turbo Pascal
Audio. pas, File | Save As,
Audioln.pas. ,
10.3. ( Audioln.pas -
File | Open (<F3>) ).
10.3. Audioln.pas
program Audioln;
type
{ }
Track = record
Name: string[50]; { }
Hours: 0. .3;
{}
Minutes: 0!.59;
{}
Seconds: 0..59;
{}
end;

{ }
CD = record
{}
Author: string[20];
{}
Title: string[50];
{}
Year: integer;
{}
Kind.: string[10];
case Tracks: byte of { }

94

10.

10.3
1: (Track!: Track); { ,
}
[2..20]: (ATracks: array[1..20] of Track) j;
end;
var
c: char;
CDData: CD;
i, j: byte; .
FName: string;
F: file of CD;

{ }
procedure DataForTrack(var TrackData: Track);
begin
end;

begin
Writeln(' :');
Readln(FName);
Assign(F, FName);
{$!-}
Reset(F);
{$!+>

if lOResult = 0
then Seek(F, FileSize(F)) { ,}
{ }
else Rewrite(F); { }
i : FileSize(F); { }
repeat
inc(i);
Writeln(' ',i,'- :');

Write(F, CDData); { F)
Write(' (/)? ');
Readln();
until in ['N','','',''];
Close(F);
end.
Audioln -, , , .
F file of CD.
, Seek , . ,
Rewrite.
,
CDData, F
Write. (! Writeln
.) F Close.

95

-. ,
Audio In. /
File | Save As Turbo Pascal Audioln.pas (. 10.3) AudioOut.pas.
, ,
, 10.4. ( AudioOut, pas File | Open (<F3>) ).
10.4. AudioOut .pas
program AudioOut;
type
{ }
Track = record
Name: string[50]; { }
Hours: 0..3;
{}
Minutes: 0..59;
{}
Seconds: 0..59;
{}
end;
{ }
CD = record
Author: string[20];
{}
Title: string[50];
{}
Year: integer;
{}
Kind: string[10];
{}
case Tracks: byte of { }
1: (Trackl: Track); { ,
}
[2..20]: (ATracks: array[1..20] of Track);
end;
var
c: char;
CDData: CD;
i, num: byte;
FName: string;
F: file of CD;
isError: boolean;
{ }
procedure DataForTrack(var TrackData: Track; num: byte);
var
hh, mm, sa: string[2];
Timing: string[8];
begin
with TrackData do
begin
( , )
Str(Hours, hh);
Str (Minutes, mm);
Str(Seconds, ss) ;
{ )
if Hours = 0 then Timing := '' else Timing := hh + ':';
Timing := Timing + mm + '"' + ss + Chr(39) ;

96

10.

10.4
Writeln(num
end;
end;

'., Name, ' (', Timing, ')');

begin
.
isError := True;
while isError do
begin
WritsIn(' :');
Readln (FNaime) ;
Assign(F> FName);
{$!-}
Reset(F);
{$!+}
isError := (lOResult > 0);
if isError then Writeln(' !');
end;
repeat
Writeln(' ',FileSize(F),' :1);
Seek(F, 0); ( }
for i := 0 to FileSize(F) - 1 do
begin
Read(F, CDData);
Writeln(i + 1, ' - ', CDData.Author, ', "', CDData.Title,'"
( 20 )
if (((i + 1) mod 20) = 0) and
(i < (FileSize(F) - 1))
then begin
\
Writeln(' <Enter>...
Read();
end;
end;
Writeln(' : ');
Readln(num);
, Seek(F, num - 1); ( }
Read(F, CDData);
Writeln('> ', CDData.Author, ', "', CDData.Title,
i n - ', CDData.Year, 'r. (', CDData.Kind, ') <');
{ }
if CDData.Tracks = 1
then DataForTrack(CDData.Trackl, 1)
else for i := 1 to CDData.Tracks do
DataForTrack(CDData.ATracks[i], i);
Write(' (/)? ');
Readln();
1
1
until in ['N ,' ,'',''];
Close(F);
end.
AudioOut . for
20 . 20

97

,
<Enter>.
, . Read - CDData, .
DataForTrack. ,
.
str.


,
,
. , , ,

. , , File:
var
'
F: File;
.
/ ,
:
Rewrite(F, 1);
Reset (F, 10);
128 , Rewrite Reset
,
, 128 .
Pascal, Read Write, BlockRead BlockWrite, . :
BlockRead(var F: file; var Buf; Count: word {; Result: word});
BlockWrite(var F: file; var Buf; Count: word {; Result: word});
Buf , ; Count .
Count * RecSize, RecSize , . Result
.
. Turbo Pascal
FileCopy.pas ( 10.2), CopyFile.pas,
, 10.5,
File | Open (<F3>).

98

10.

10.5. CopyFile .pas


program CopyFile;
var
FFrom, FTo: File;
NameFrom,NameTo,s: string;
isError: boolean;
CurPos, 'FSize: longint;
Blocks: integer;
begin
isError := True;
while isError do
begin
Writeln(' , :');
Readln(NameFrom);
Assign(FFrom, NameFrom);
{$!-}
Reset(FFrom, 1); { 1 }
{$!+)
isError := lOResult > 0;
if isError then Writeln(' !')
end;
Writeln(' :1);
Readln(NameTo);
Assign(FTo, NameTo);
Rewrite(FTo, 1); '{ 1 }
CurPos := 0;
{ }
Blocks := 256;
{ }
FSize := FileSize(FFrom); ( }
Write('... ');
while not Eof(FFrom) do
begin
BlockRead(FFrom,s,Blocks);
BlockWrite(FTo,s,Blocks);
inc(CurPos, Blocks);
( )
if (CurPos + Blocks) > FSize then
Blocks := FSize - CurPos;
end;
Close(FTo);
Close(FFrom);
Writeln('! ') ;
end.
CopyFile , 1 , 256. ,
BlockRead s string 256 . ,
256 , -,
, .
.
, ,
(if (CurPos + Blocks) > FSize then),
() : Blocks := FSize - CurPos;

11

, .
.
, , . ,
.
, 8x86, 65536
(64 ), .
,
.
,
. , . ,
. ,
| var A: array[l. .300] of byte';
300 , . , .
, .
, . ,
. , -
. , ,
. .
, , ,
.
, , 16 ( word). 65536
(64 ), , 16 ( 0, 16,
32 ..).
. , () :
I * 16 +

100

11.


, , .

" ", .
:
type

pint = integer; { }

pReal = 1;
{ )
var

PI, 2: pint;
: pReal;
A
4: byte; { byte}
, @, "". ,
i, @i "
1" " i":
var

: integer;
i: integer;
begin
i := 2;

P := @i; { ,
2}
end.

'

, "".
, i
:
Writeln(i); { i}
Writeln(PA); { ,
}
.

Pascal , ,
. Nil. Nil
, ,
.
Nil ( ), .
=.
, .

. Turbo Pascal

101

, Pointer I. pas
11.1, File I Open

11.1. Pointerl.pas
program Pointer1;
type
TArr = array[1..5] of integer;
var
PArr: ; { }
Arr: TArr;
i: integer;
begin
PArr := @Arr; {PArr Arr}
for i := 1 to 5 do
begin
Write(1,'- = ');
Readln(PArrA[i]); { , PArr
Arr,
PArrA - Arr}
end;
for i := 1 to 5 do
begin
PArr := @Arr[i];
{PArr i- Arr}
Writeln(PArrA[1]); {PArrA - i- }
end;
end.
Pointerl ,
.


Pascal ,
. pointer.
,
.
pointer . " ",
. Nil, pointer
.
.
" " 7.


. -, ,
, .

102

11.

,
, ,
.
Turbo Pascal ,
Links .pas 11.2,
File | Open (<F3>).
11.2. Links .pas
program Links;
type
Link = Person/Person = record
ID: integer;
{}
Lastname: string[20]; {}
FirstName: string[20]; {}
NextRec: Link;
{ }
end;
var
i, , j: integer;
Last, First, Curr: Link; {Last -
First -
Curr - }
procedure ShowList;
begin
Writeln(' :');
Curr := First; { }
while Curr <> Last do { ,
}
begin
Writeln(.ID:3,' - ',CurrA.LastName,' ',.FirstName);
Curr := CurrA.NextRec; { }
end;
end;
begin
Write(' : ');
Readln(c);
Last.:= New(Link); ( Person}
First := Last;
{ }
for i := 1 to do
begin
Writeln(' ',i,':');
LastA.ID := i;
Write(': ');
Readln(LastA.LastName);
Write(': ');
Readln(LastA.FirstName);
A
Last .NextRec := New(Link); {
}
Last := LastA.NextRec;
{ }
end;
Sho'wList; { }
Write(' : ');

103

11.1
readln(j);,
Curr := First; { }
{ }
for i := 1 to j - 2 do Curr := Curr".NextRec;
if j = 1

then First := First".NextRec { ,


First}
else if j =
{ ...}
then begin
Curr".NextRec := Nil; { ,
, NextRec}

Last := .NextRec; { Last}


end else {
, )
A
Curr .NextRec := Curr".NextRec".NextRec;
ShowList;
Dispose(First); { ,
First}
end.

Links
Person. , Link,
Person.

,
.
Person NextRec Link,
.
-: First , Last , Curr
.
, New Person. New , , .
,
Last
New(Link);
,
Link ( Person), - Last. Last
, - First.
for ,
NextRec
.
ShowList. , while , First,
, Last.

104

11.

,
. , , First
. ,
Next Re Nil, Last
. , , NextRec ,
.
Dispose, , , First (
).

, ,
.

12

, , (). "", .
, , . , , .
, .

, . . , : ,
, .. ,
. , : , , ..
, .
, ,
.
. "" .
, ,
: , , ..
, : .
, . , , . , , , ,
.
,
-.
. , . , , , -.
Pascal Object:
type
_ = Object
1: ;

106

12.
_: _;
_1;

eo_N;
end;
.
, . ,
, ,
:
type
TCar = Object
Weight: real;
{ }
Color: string[20];
{}
MotorV: byte;
{ ..}
procedure Start;
{ }
procedure Stop; { }
end;

Weight, Color MotorV (),


Start Stop TCar ("car" "").

, TCar
Pascal (, , ).
TCar:
var
MyCar: TCar;
, :
MyCar.Weight := 2.5;
MyCar.Color := '';
MyCar.Start;
:
type
= ;
var
MyCar: PCar;

New:
MyCar := N e w ( P e a r ) ;
MyCar .Weight := 1;
MyCar .Start;

107


,
"" . , . :
_ = Object (_)
, TSedan, :
type
TSedan = Object(TCar)
Doors: byte;
end;
TSedan,
:
var

MySedan: TSedan;
MySedan.Color := '';
MySedan.Start ;
.
. . ,

procedure TypeInfo(T: TCar);
, TSedan.

procedure TypeInfo(T: TSedan);
TSedan ,
. , , Pascal .
f

, ,
. , . , , , . , , ,
, .
, Filling,
. ,
. , ,
. , Filling . , 12.1.

108

12.

12.1.
type
TCar = Object
TankV: byte; { )
Fuel: byte;
{ }
function Filling(Volume: byte): byte;
end;

{ Filling)
function TCar.Filling(Volume: byte): byte;
begin
if Volume > TankV then Volume := TankV;
Fuel := Volume;
Filling := TankV - Fuel;
end;
var
MyCar: TCar;
{ Filling )
MyCar.TankV := 100;
Writeln(MyCar.Filling(60)); { 40}
, Filling
TCar (
TCar.TankV, TankV, TCar.Fuel, Fuel).
, TankV Fuel ,
Filling, TCar.


, "" . ,
, . , TCar
TSedan (. 12.1) - IsFuel, , 12.2.
12.2.
type
TCar = Object
function isFuel: boolean;
end;

TSedan = Object(TCar)
function IsFuel: integer;
end;

function TCar.IsFuel: boolean;


begin
IsFuel := (Fuel > 0);
end;


11.2
function TSedan.IsFuel:
begin
IsFuel := Fuel/-

109

integer;

end;

, , ,
True. , TSedan, . , IsFuel
:
var
MyCar: TSedan;
Writeln('B ',MyCar.IsFuel,' ');
if TCar(MyCar).IsFuel"
then Writeln(' ')
else Writeln(' ');
,
IsFuel, .
. , , TSedan (. 12.2)
Filling, , 12.3.
12.3.
function TSedan.Filling(Volume, Limit: b y t e ) : byte;
begin
if Fuel > Limit then
begin
Writeln(' ');
Filling := TankV - Fuel;
end else TCar.Filling(Volume) ;
end;

Limit , . , Filling
"" .


, , . , , , "" . ,
( )
, , . , ,
. , ,
.

virtual:

110

12.

| procedure Stop; virtual;


, ""
virtual,
.

, ,
, ,
.

, , .
, ,
. .
,
.
, .
procedure constructor.
,

. , . , , , , .
, (. 12.2) , 12.4.
12.4.
type
= Object

constructor I n i t ( t v , f : b y t e ) ;
end;

constructor T C a r . I n i t ( t v , f : byte);
begin
TankV := tv;
Fuel := f;
end;

, . ,
. :
var

MyCar, YourCar: TCar;


begin
MyCar.Init(100, 0);
YourCar := MyCar; { }

111

Your Car:
YourCar.Init(80, 80);


,
. ,
.

, .
TSedan.IsFuel TSedan.Fuel. .
.
, . Pascal . , .
, public . ,
, private
, :
type
= Object
Fieldl: integer;
procedure Prod;
private
Fields: string;
procedure Proc2;
public
Field3: real;
procedure Procl;
end;

{ }
{ }
{ }
{ }
{ }
{ }


,
. New:
var
:

New(TCar);
New , , ,
.
,
, :

112

12.

.Color := ''
PA.Init(100,100);
Pascal
New , :
[ New(P, Init(100,100)
, , New New, . , New, , :
type
= ;
var
: ;
:= New(Pear);
,
Dispose:
Dispose(P);

, . Dispose .
Pascal , , procedure Destructor. ,
. .
type
TCar = Object
destructor Done;
end;
, , . , . ,
,
.
,
I Dispose (, Done) ;
^
.
, ,
, destructor.
, (, TSedan)
"" , .

113

"" , Pascal inherited,


:
destructor TSedart.Done;
begin
inherited Done;
end;


, , .
. ( 2, 16, 8). . ,
, ,
. ,
.
.
,
DecTo. DecTo
DecToBin (, ), DecToHex (
) DecToOct ( ),

, . Trans ,
DecTo.
Turbo Pascal ,
TransTo.pas 12.5, File | Open (<F3>).
12.5. TransTo. pas
program TransTo;
uses Crt;
type
PDecTo = ADecTo;
DecTo = Object
constructor Init(s: string);
function Trans(Num: word): string; virtual;
private
Symbols: string;
Base: byte;
end;

PDecToBin = "DecToBin;
DecToBin = Object(DecTo)
constructor Ihit;
end;

114

12.

12.5
PDecToHex = ADecToHex;
DecToHex = Object (,DecTo)
constructor Init;
end;
PDecToOct = ADecToOct;
DecToOct = Object(DecTo)
constructor Init;
end;
constructor DecTo.Init(s: string);
begin
Symbols := s;
Base := Length(s);
end;
constructor DecToBin.Init;
begin
inherited Init('01');
end;
constructor DecToHex.Init;
begin
inherited Init('0123456789ABCDEF1);
end;
constructor DecToOpt.Init;
begin
inherited Init ('01234567');
end;
function DecTo.Trans(Num: word): string;
var
i: integer;
s: string;
begin
11.
S .
~
'
,
while Num >= Base do
begin
s := copy(Symbols,(Num mod Base)+!,!) + s;
Num := Num div Base;
end;
Trans := copy(Symbols,Num+1,1) + s;
end;
var ,
P: PDecTo;
DecN: word;
begin
ClrScr;
Write(' : ' ) ;
Readln(DecN);
P := New(PDecToBin,Init);
Writeln(' ',
DecN, ' = ', .Trans(DecN));

115

12.5
Dispose();
:= New(PDecToHex,init);
Writeln('B
DecN, ' = ', .Trans(DecN));
Dispose(P);
P := New(PDecToOct,Init);
Writeln('B ',
DecN, ' = ', .Trans(DecN));
Dispose(P);
end.
DecTo.Trans. Init
,
.
Symbols , DecTo, (
Symbols) Base.
, DecTo,
, New.
, , ,
DecTo, New, .

, . ""
*

*^*

11

WWWiDtASOFt,
JUNIOR.COM,UA

.JUNIOR,CQMH

^11 'ik 1 #* ^ 4* s*4 11


, JUNIOR,
CQWLU.

Ill


, . , . 13, 14 .
,
Crt. tpu Graph.tpu.
15.
16 , , 17
.
Turbo Vision,
- .

13


Turbo Pascal
1. , Compile | Compile <Alt+F9>. ,
Run | Run <Ctrl+F9>
.
, Turbo Pascal , .
, Compile | Information ,
,
. Compile
, .
, Turbo Pascal,
MS-DOS. Turbo Pascal.


, (, 7
{$F} {$L}).
, . , , , $.
.
-. "+" "", (, {+} {$F-}).
-. .
.
.

-
- . ,
.
.

{$}
. {$+}. . {$+} , -

119

{$}
. {$-}.
. {$+} , . ,
, ,
and or ( ).
{$-}, ,
.

{$D}
. {$0+}. . .

. {$D-},
Turbo
Pascal . .tpu, . .

{$}
. {$+}.
,
80x87. {$N} ( ).

{$F}
. {$F-}. . , {$F+}, (far). , .

{$1}
. {$!+}. -.
{$!+}, - , . {$!-}, lOResult.

{$L}
. {$L+}. .
,
. {$L+}
, -

120

13.

Turbo Pascal . ,
..

{$N}
. {$N-}. . - {$N-},
.
{$N+} 80x87.
: Single, Double, Extended .
{$N+, $E+}, 80x87. , , 80x87 .
{$N+, $E-}, ,
80x87.

{$}
. {$0-}. .

, .
.
. ,
.
{$+}, .

{$}
. {$-}. - string.
{$+}, - string .
,
,
.

{$0}
. {$Q-}. . {$Q+},
. {$Q+}
,
.

121

{$R}
. {$R-}. .
{$R+},
, .

{$8}
. {$3+}. . ,
.
" , ".
{$3+},
.
, , . {$3-},
.

{$}
. {$-}. , @.
{$-}, @ . @ {$+}, , , .

{$V}
. {$V+}. , -. {$V+}, . {$V-},
,

.

{$}
. {$+}. Turbo Pascal.
{$+}, .
, . {$+}
, System. /
{$+} PChar.

{$}
. {$Y+}. .

122

13.

. {$Y+}
, . .
. {$Y+} ,
{$D+} {$L+}.
-
Compiler Options (. 13.1), Options | Compiler.
. 13.1.
;

.
:
."
'

lags allowed

[3 86 Instructions
Syntax options

[X J

Sxjl|?-

ipcr:-/0 check intf' ': ,


*t 1 Qverfloe heekinn

|I*1 Complete oolean ewal


tXJ E tended sgntax
. [ .3 yped @ operator
. . J Open araneters

[X] ebusr information


... ,IX]
. I oca
. . . . 1 symbols
...
..

Numeric processing
[ 1 887/80287
[XI nulation

Cortditio al defines

I
. 13.1. Compiler Options
13.1. Compiler Options

Compiler

Compiler
Options
Options
Word Align Data
Overlays allowed
{$}
{$0}
Complete boolean eval
Open parameters
{$}
{$P}
Overflow checking
Debug information
{$0}
{$Q}
Force far calls
Range checking
{$F}
{$R}
Emulation
Stack checking
{$}
{?S}
286 instructions
Typed @ operator
{$G}
{$T}
I/O checking
Strict var-strings
{$V}
{$1}
Local symbols
Extended syntax
{$L}
{$X}
8087/80287
{$N}

-
- .
-, .
, . .

123

{$}
. .
, . (),
. .
MOVEABLE.
.
FIXED.
.
PRELOAD. .
DEMANDLOAD. .
PERMANENT. .
DISCRDABLE. , , .
{$} :
| {$ MOVEABLE DEMANDLOAD DISCARDABLE)

{$D}
.
. . :
[ ($D My program}

{$!}
.
. .pas. :
| {$! InFilel.pas}
,
Turbo Pascal , , Include Directories Directories (. . 1.4).

, program
unit. (, ),
, {$ I}.

{$!_}
. , external, , .
. ob j. :
| procedure SetMode(Mode: W o r d ) ; external; {$L CURSOR.OBJ}
,
Turbo Pascal , , Object Directories Directories (. . 1.4).

124

13.

{$}
. , " ( ., .ovr). :
[ ($0 Unitl.pas Unit2.pas}
\
uses.
, .ovr, - {$0+}.


, . if.
{$DEFINE}. . , .
{$IFDEF}. , .
{$IFNDEF}. , .
{$ELSE}. , else if-else.
{$ENDIF}. ,
.
{$UNDEF}. .
. Turbo Pascal , MultiLan.pas
13.1, ,
File | Open (<F3>).
13.1. Multilan.pas
program MultiLan;
begin
{$DEFINE R};
{$IFDEF R}
Writeln(' ');
{$ELSE}
{$IFDEF U}
Writeln(' ! ');
{$ELSE}
Writeln('The English is selected');
{$ENDIF}
{$ENDIF}
end.

.
" ". ,
{$DEFINE} , R.

MS-DOS

125

{$DEFINE 0} . , . {$DEFINE} , .

MS-DOS
,
Turbo Pascal, MS-DOS. - tpc. exe, ,
Turbo Pascal turbo. exe. Turbo Pascal ,
tpc. exe. MS-DOS tpc. Turbo
Pascal (. 13.2).
:M_BOOKS48387\TP7.8SBIN>tpc.exe
Turbo Pascal Version 7.8 Copyright (c) 1983,92 Borland International
Syntax: TPC [options] filename [options]
-B = Build all units
-L = Link buffer on disk
-D<syms> = Define conditionals
-M = Make m o d i f i e d units
-E<path> = EXE/TPU directories
-0<path> = Object directories
-F<seg>:<ofs> = Find error
-Q = Quiet compile
-GD = Detailed map f i l e
-T<path> = TPL/CFG directory
-GP = Hap f i l e uith publics
-U<path> = Unit directories
-GS = Map f i l e uith segments
-V = Debug information in EXE
-Kpath> = Include directories
-$<dir> = Compiler directive
Compiler suitches: -$<letter><state>
(defaults are shown belou)
A+ Uord alignment
1+ I/O error checking
R- Range checking
B Full boolean eual
L+ Local debug symbols S+ Stack checking
D+ Debug information
N- 88x87 instructions
T- Typed pointers
E+ 88x87 emulation
0- Overlays alloued
V+ Strict uar-strings
F- Force FAR calls
P- Open string params
X+ Extended syntax
G- 88286 instructions
Q- O v e r f l o w checking
Memory sizes'. -$M<stack>,<heapmin>, <heapmax> (default: 16384,8,655368)
E:41_BOOKS\83874TP7.8IM>
ILeft
ZRight 3Uieu.. 4 E d i t . . SComp

6DeComp 7Find

BHistry 9EGft Ln 16Tree

. 13.2. - tpc .exe


, tpc. exe :
tpc _

~-

. , , E^XpOl.pas,
. . : \books.
MS-DOS:
tpc e:\p01.pas -Ee:\books -$B+
.__
'
- ,
$ .
tpc. exe . 13.2.

126

13.

13.2. tpc.

-D
. !

. ,
MultiLan ( 13.1)
{$ DEFINE}, MS-DOS:
| tpc MultiLan. pas -DR

-
-I
-

-
-V
_

. ,

. . tpu
, { $ I }


.
- . :
-$+ -$-

Turbo Pascal
,
Turbo Pascal, {$D+} {$L+}.
, ,
.
.
, Options | Debugger,
(.
13.3) Integrated
()
.
. 13.3. Debugger


, Run, . 13.3.
13.3.

Run
<Ctrl+F9>
( ),

Turbo Pascal
13.3

Step over
<F8>
Trace into
<F7>
Go to cursor
<F4>

127

<Ctrl+F9> ( Run | Run),


<Ctrl+F2> ( Run | Program reset). , .


, .
, .
<Ctrl+F9>,
, <F8> <F7>, .


.
1. Debug | Add breakpoint
Add Breakpoint (. 13.4).
2. Toggle
breakpoint.
3. <Ctrl+F8>.

ass count

lie

?
\UORK\BOOKS \COMPU ERST PSflPPS
ine number

. 13.4. Add Breakpoint


Condition , . Pass count ,
.
File name , Line
number , .
: File name
, Line number ,
.

128

13.

Condition
, TransTo, (. 12.5).
TransTo .pas Turbo Pascal.
70 ( : = New (PDecToBin, Init) ;).
Debug | Add breakpoint.
Add breakpoint,
Condition DecN,> 9 (. 13.5).
,
, DecN
.

onditxon
DecN > 9
ass count

COMPlJTER\TP\flPPSMRflNSTO.PftS
ine number

. 13.5.
TransTo DecN 10. , ,
DecN , .
TransTo , DecN 9. ,
(. 13.6).

Conditional breakpoint "DecN > 9"


in ...\TP4flPPSMRflNSTO.PflS line 70
is true.

. 13.6. ,
- .
<F8>, . <Ctrl+F2>, . <Ctrl+F9>.
,
Colors,
Options | Environment | Colors.

Turbo Pascal

129


,


Pascal Breakpoints (.
Debug | Breakpoints.

<Ctrl+F8>.
Turbo
13.7), -

. 13.7. Breakpoints
( Edit),
( Delete), ( View),
( Clear all).


Edit Breakpoint
(. 13.8).

ondition
DecN > 9
ass count

<OMPUTER\TPSflPPS\TKflNSTO.PflS
ine number
;

"

;_:_

. 13.8. Edit Breakpoint

Add Breakpoint (. . 13.5) ,


: Modify () New ().
Modify,
, New, .

Pass count
Pass count WhileEx, 6 (. 6.3).
WhileEx.pas Turbo Pascal.

130

13.

Writeln
, Debug | Add breakpoint.
Pass count Add breakpoint 2. ,
Writeln.
. . - .
<Alt+F5>, . , Writeln , .
,
<Ctrl+F9>.

, Writeln. , WhileEx .


Turbo Pascal :
Breakpoints ( ), . . 13.7; Call Stack ( ); Register
( ); Watches (); Output ( ).
Debug. ( Breakpoints) . 13.4.
13.4. Turbo Pascal

Call stack
.
. ,
Call stack :
SortABC(False)

,
SortABC,
Register
. 15,
Watches

. -
Watches Turbo
Pascal, - <Ctrl+F7>, Add Watch .
Add Watch,
.
Add Watch
,

Turbo Pascal

131

13.4

Output
, Turbo Pascal
,
Turbo Pascal.
.
Evaluate and Modify.
Debug | Evaluiate/mouify, <Ctrl+F4>
.
Evaluate and Modify Evaluate,
Result , Expression. , Expression,
New value Modify.

14

.
,
64 . , .
64 . 7
,
uses. , , .
, , , .
, Pascal,
, program unit. ,
,
. ,
Graph * , . ,
, ,
.
.pas, .tpu. , program, , unit.
- ,
, uses, :
program Progl;
uses Unit!; {
,
Unitl.pas,
Unit I. tpu}

unit Unitl;
uses Unit2; { Unitl Unit2}

uses , . tpu ,

133

, Unit directories Directories


(. . 1.4), Options | Directories.


:
unit Unitl; { }
interface
{ }
implementation
{ )
begin
{ }
end.

, interface, , .
, , , . ,
,
.
, implementation, , .
, . , ()
, .
, implementation
begin end ,
, .
, uses. , begin
.
. Turbo Pascal , Unitl .pas
14.1, File | Open (<F3>).
14.1. Dnitl.pas
unit Unitl;
interface
function Sum(a,b: integer): longint;
implementation
function Sum(a,b: integer): longint;
begin
Sum := a + b;
end;

function Avg(a,b: integer): real/begin


Avg := Sum(a,b)/2;
end;
end.

134

14.

Unitl Sum,
.
implementation. Avg,
. ,
begin , .
Turbo Pascal ,
Unitl.
Units .pas 14.2,
File | Open (<F3>).
14.2. Units .pas
program Units; *"
uses Unitl;
var
x, y: integer;
begin
x := 10;
:= 5;
Writelnfx + = ', Sum(x,y));
end.
uses Unitl, Sum, . , , . Units :
Writelnf'x + = ', Sum(x,y));
Writeln(' + =
end.
.

Avg(x,y));

.
"Unknown identifier" (" ") Avg. , Unitl
, , .
Unitl Avg, .
Unit2.pas 14.3, File | Open (<F3>).
14,3. Unit2. pas
unit Unit2;
interface
uses Unitl;
function Sum3(a,b,c: integer): longint;
implementation
function Sum3(a,b,c: integer): longint;
begin
Sum3 := Sum(Sum(a,b),c);
end;
end.

135

, . Sum, Unitl.
, Sum,
Unitl uses ( ).
(. 14.2) :
program Units;
uses Unitl, Unit2;
WritelnCx + + = ', Sum3(x,y,y)) ;
end.

, , (Units.pas)
Unit2, .


, Unitl
Sum3, Unit2. , , Unitl uses. ,
:
unit Unitl;
interface
uses Unit2;
TO
"Circular unit reference (Unitl)" (" "). ,
(
), Pascal .
Unitl Unit2 , :
unit Unitl;
interface
function Sum(a,b: integer): longint;
function Avg(a,b: integer): real;
implementation
uses Unit2;
, Unitl
Sum3, Unit2, ,
14.4.
14.4.
,
unit Unitl;
interface
function Sum(a,b: integer): longint;
function Avg(a,b: integer): real;
function Avg3(a,b,c: integer): real;

136 14.
14.4
implementation
uses Unit2;
function Avg3(a,b,c; integer): real;
begin
Avg3 := Sum3(a,b,c)/3;
end;
Units:
program 'Units;
Writeln(' + + = ', Avg3(,,));
end;
,
. ,
, .
Turbo Pascal ,
IsFile.pas 14.5,
File | Open (<F3>).
14.5. IsFile.pas
unit IsFile;
interface
function FileExists(FName
implementation
function FileExists(FName

string): boolean;
string): boolean;

var

F: Text;
isError: boolean;
begin
As s ign(F,Fname);
{$!-}

Reset(F);
{$!+>

isError := lOResult > 0;


if isError then Writeln(' !');
FileExists := not isError;
end;
end.

.
FileExists, uses IsFile.


Compile | Compile, a
Compile | Destination. Compile , : Make, Build, Primary File Clear
primary file, Information,

137

. Make, Build, Primary file Clear primary file.

Compile | Make Compile | Build


Compile | Make, <F9>, , , .
. ,
. .
Compile | Primary file
, , ,
Turbo Pascal.
, .pas,
. tpu, .
, , , .
{$1} , , . tpu , .
.tpu .pas, .
Compile | Build , , , .
Compile | Make ,
- .

Compile | Primary file Compile | Clear primary file


, Primary File ,
.pas,
Make Build. , , , .
Clear primary file ,
Make Build Turbo Pascal.

15

Pascal : .
, , . . , . "".
, ().
, ,
.. , , . ;
.


, ,
Crt. ,
,
uses.


Crt AssignCrt. Assign,
, , . ,
. Turbo Pascal , FToScr.pas 15.1,
File | Open (<F3>).
15.1. FToScr. pas
program FToScr;
uses Crt, IsFile;
var
FDisk, FScr:. Text;
s,FName: string;
begin
ClrScr; { }
repeat
Write (' : ')/'

139

15.1
Readln(FName);
until FileExists(FName); { FileExists
IsFile}
Assign(FDisk,FName);
Reset(FDisk);
AssignCrt(FScr); { }
Rewrite(FScr);
while not EOF(FDisk) do
begin
Readln(FDisk,s) ;
Writeln(FScr,s);
end;
Close(FScr);
Close(FDisk);
end.
: Crt IsFile. IsFile
FileExists, . ClrScr, Crt.
( ). , ,
while ,
.


. 15.1.
Crt
TextMode, 4,
. , 80x25

TextMode(C080);

TextMode(3);

, Crt LastMode, .
/

15.1.

Crt

BW40

040

BW80

080

40x25, -
40x25,

80x25, -
80x25,

16

16

16

16

140

15.

15.1


Crt

Mono

256

Font8x8

80x25, -

43 50 EGA/VGA

3
16


,
, .
$ , $800.
.
( ASCII), . . 15.2.
15.2.

0
1
2
3
4
5
6
7

, (
3), 16 (24) .
( 4 6), 8 (23)
. ,
.
Crt . . 15.3.
15.3. Crt

( )
Black
Blue
Green
Cyan

Red
Magenta
Brown
LightGray
DarkGray

0 (0000)
1 (0001)
2(0010)
3(0011)
4(0100)
5(0101)
6(0110)
7(0111)
8 (1000)

-
-


15.3

( )
LightBlue
9(1001)
LightGreen
10(1010)
LightCyan
11 (1011)
LightRed
12(1100)
LightMagenta'
13(1101)
Yellow
14(1110)
White
15(1111)

141

-
-
-
-
-

Blink ,
128 (10000000).
TextColor, TextBackGround. , . :
TextColor(White); { }
TextBackGround(Blue); { }

Blink. ,
TextColor (White+Blink). White+Blink
00001111 + 1000000 = 10001111. , , .
Crt TextAttr.
TextColor TextBackGround. , , :
TextAttr := $9F; {10011111}
TextAttr := White + Blink + (Blue shl 4);
. ,
White + Blink 10001111. Blue
0001. , ,
4 .
Blue shl 4 00010000 (. 15.1).
10001111 + 00010000 =
10011111 ( 9F).
00001111 White
10000000 Blink

00000001 Blue
[0000

10001111White+Blink
00010000 Blue shl 4

10001111White+Blink

00010000 Blue shl 4

100111119F

. 15.1.
,
ASCII .
Turbo Pascal ,
ClrChars.pas 15.2,
File | Open (<F3>).

142

15.

15.2. ClrChars .pas


program ClrChars;
uses Crt;
var

c, StartAttr: byte;
begin
ClrScr;
StartAttr := TextAttr;

( )

for := 33 to 255 do

begin
if (c mod 16) = 0 then WritelnC');
TextAttr := c;
Write(Chr(c));
end;

TextAttr := StartAttr; { }
end.

ClrChars . 15.2.
Crt
: LowVideo, NormVideo
HighVideo. LowVideo ,
. NormVideo
.
HighVideo . ,
LowVideo,
NormVideo

HighVideo .

feeGeTf 9 = Q - -
. 15.2.
ClrChars

Crt ,
.
Window . Windows
: XI, Y1 , 2, 2
. :
Windowfl,1,80,25); { }
Windowd, 1, 8, 25) ; { }
, . ,
, .
Window Crt word WindMin WindMax. WindMin , WindMax
. X ,
Y . Lo Hi:

143

X := Lo(WindMin);
Y := Hi(WindMin);
, WindMin WindMax 1, 0.
,
Crt, " ". Turbo Pascal , Gatherer.pas ,
15.3, File | Open (<F3>).
15.3. Gatherer .pas
program Gatherer;
uses Crt;
var
CurX, CurY, CInLine, StartAttr, i,j: byte;
Total,Gathered: integer;
'AField: array[1..22,1..80] of char;
PressedKey: char;
procedure ShowCount; {
}
begin
Window(1,1,80,3);
TextColor(Yellow);
GotoXY(40,l);
Write(' : ',Gathered,' ',Total);
end;

^
procedure DrawPos; { }
var
CurChar: Char;
begin
{ }
Window(l,3,80,25);
TextBackGround(Black);
TextColor(LightRed);
GotoXY(CurX,CurY);
Write ('0' )';
if AField[CurY,CurX] = '*' then {
""...}
begin
Inc(Gathered); { 1}
AField[CurY,CurX] := ' '; { ""
}
end;
ShowCount; { ""}
end;

{ }
procedure DrawStatus(FColor, BColor: byte; Si string);
begin
Window(1,25,80, 25);

144

15.

15.3
TextBackGround (BColor ) ;
TextColor (FColor) ;
ClrScr;
GotoXY(l,25) ;
Write (s) ;
end;
begin
ClrScr;
StartAttr := TextAttr; { }
( }
Window (1,1, 80, 3) ;
TextBackGround (Black) ; { }
{ }
TextColor (White) ;
ClrScr; { }
Write ( ' " " ' ) ;
ShowCount; { }
GotoXY(l,2) ;
for i := 1 to 80 do Write ('-') ;
{ }
Window (1,3, 80, 25) ;
TextBackGround (Black) ;
TextColor (LightGreen) ;
ClrScr; { }
GotoXY(l,l) ;
Randomize; { }
{ "")
for i := 3 to 24 do
begin
InsLine; { }
CInLine := Random(9) + 1; { ""
- 0 10}
CurX := 1;
CurY := 1;
for j : = 1 to CInLine do { ""}
begin
CurX := CurX + Random(8) + 1;
if CurX > 80 then CurX := 79; { }
GotoXY(CurX,l) ;
Write ('*');
AField[25-i,CurX] := '*'; { "" }
{ "" }
while (CurX mod 8) > 0 do Inc(CurX);
end;
Inc (Total, CInLine) ; { ""}
end;
{ }
DrawStatus (Blue, LightGray,
' - Esc.' +
' - . ' ) ;
{ }
GotoXY(l,l) ;
CurX := 1;

145

15.3
CurY := 1;
repeat
DrawPos; { }
PressedKey := ReadKey; { }
Window(1,3,80,25);
if Ord(PressedKey) then break
{ Esc, }
else
begin
{ }
GotoXY(CurX,CurY);
TextBackGround(Black);
Write(' ');
{ }
case Ord(PressedKey) of
72: if CurY > 1 then Dec(CurY); { }
75: if CurX > 1 then Dec(CurX); { }
77: if CurX < 80 then Inc(CurX); { }
80: if CurY < 22 then Inc(CurY); { }
end;
end;
until Gathered = Total;
DrawStatus(White+Blink,Red,' !');
ReadKey;
TextAttr := StartAttr; { }
Window(l,l,80,25);
ClrScr;
end.

Gatherer . 15.3.
" "

: 13 89_

*
*

4t

- Esc. - .
. 15.3. " "
, .
. CurX CurY X

146

15.

Y " " . CInLine "" . StartAttr


. i j . Total
"" , Gathered
"". AField
"" . "",
"*".
PressedKey ,
. .
, . StartAttr.
Window , .
, TextBackGround TextColor,
( ). ,
ShowCount.
ShowCount
"" .
GotoXY. Crt
X Y
, Window. , . ShowCount
, "-".
.
Window (1, 3, 80, 2 5 ) , -
"" ( "" "*"). ""
, Randomize . Random, ( 0).
, , InsLine 22 . . ""
0 10. Random 0,
"", Random(9) + 1. ""
(CurX := I; CurY := 1). "*" 0 9. "*" AField AField [25-i, CurX] := ' * ' ;.
25-i
, "
. , "" (i = 1),
(25 - 1 = 24); (1 = 2),
(25 - 2 = 23) ..
"" 8 , "*". , "" AField, -

147

X . -,
"" "" .
( ) DrawStatus.
: , ,
.
.
(1,1). repeat
DrawPos " ". . , , ,
. " ", CurX ""
( , " " -
). "" AField.,
"*" ( ""), , ^
( - , "*").
DrawPos ShowCount.
"" ,
.
ReadKey, Crt.
Char, . PressedKey, if
. <Esc> ( 27),
break repeat, .
- , "" , , , , CurX CurY.
CurX CurY . " " , ..
<Esc>, , "" .
" !",
.


, Crt, .
Graph. ,
. ,
(),
.
, , -

148

15.

.
Graph ,
. Turbo Pascal
BGI .bgi. ,
, Pascal
, .
( ), ,
. .
,
. ,
.
, . , , , . , " "
. , , .
. 15.4.
15.4.

ATT . BGI

AT&T 6300

ATT400CO

320x200
320x200

3
3
3
2
2
3
3
3
3
2
3
3
3
3
2
2
16
16
16
4

ATT400C1
ATT400C2
ATT400MED
ATT400HI
CGA.BGI

IBM CGA

IBM MCGA

CGACO

640x400
320x200

CGAC1

320x200

CGAC2

320x200

CGAC3

320x200

CGAHI

640x200

MCGACO

320x200

MCGAC1

320x200
320x200

MCGAC2

EGAVGA.BGI

IBM EGA

320x200
640x200

MCGAC3
MCGAMED

320x200

MCGAHi
EGALO

640x480

EGAHI
EGA64LO
EGA64HI
EGAMONOHI

640x350

640x200
640x200
640x200
640x350
720x348

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
2
1
1
: 64/ 1
256
2

149

15.4

EGAVGA.BGI

IBM VGA

VGALO
VGAMED
VGAHI

Hercules
IBM 8514

HERCMONOHI

IBM8514.BGI
PC3270.BGI

IBM 3270 PC

PC3270HI

HERC.BGI

IBM8514LO

640x200
640x350
640x480
720x348
640x480
1024x768
720x350

16
16
16

2
1

256
256


Graph
InitGraph, : , .bgi. ,
, . 15.5.
15.5. ,

CurrentDriver
Detect

-128
0
1

CGA
I

MCGA

I
-'

MCGA
EGA

2
3

EGA64

EGAMONO
IBM8514

5
6

HercMono
ATT400 ()

CGACO
CGAC1
CGAC2
CGAC3
CGAHI
MCGACO
MCGAC1
MCGAC2
MCGAC3
MCGAMED
MCGAHI
EGALO
EGAHI
EGA64LO
EGA64HI
EGAMONOHI
IBM8514LO
IBM8514HI
HERCMONOHI
400
4001
4002 -.

0
1
2
3
4
0
1
2
3
4
5
0
1
0
1
0
0
1
0
0
1
2

150

15.

15.5

400 ()

VGA

3270

10


ATT400MED
ATT400HI
VGALO
VGAMED
VGAHI
PC3270HI

4
5
0
1
2
0

, 16- VGAHI
640x480 InitGraph:'
InitGraph(VGA, VGAHI, M:\tp\bin\bgi');
InitGraphQ, 2, ' d : \ t p \ b i n \ b g i ' ) ;
(' '),
.
Detect (0)
.
, .
Turbo Pascal ,
Graph_01.pas 15.4, File | Open (<F3>).
15.4. Graph_01 .pas
program Graph_01;
uses Graph, Crt;
{
var
DriverVar, ModeVar, ErrorCode: integer;
DriverName, ModeName: string;
begin
DriverVar := Detect;
{ )
InitGraph(DriverVar,ModeVar,'\tp\bgi 1 );
{ }
ErrorCode := GraphResult;
if ErrorCode <> grOK then
begin
Writeln(' ' +
': ', ErrorCode);
Writeln(GraphErrorMsg(ErrorCode)) ;
Halt(l); { }
end;
DriverName := GetDriverName; { )
ModeName := GetModeName(ModeVar); { )
RestoreCRTMode; ( }
Writeln(' ;');
Writeln(' ', DriverName,
1
( ' , DriverVar, ' ) ' ) ;
Writeln(' ', ModeName, ' , ModeVar, ' ) ' ) ;
ReadKey; { }
SetGraphMode(ModeVar); { }
OutTextXY(10,10,' ');

151

15.4
OutTextXY(10,30, ' ' + DriverName);
OutTextXY(10,50,' ' + MpdeName);
ReadKey;
CloseGraph; { } *
end.

, , \tp\bgi.
, .
, uses
Graph Crt. Crt
ReadKey, - .

GraphResult, 0, , 14 .1, . Graph (. 15.6).
15.6.


grOK

0
grNoInitGraph
-1


grNotDetected
-2
grFileNotFound

-3
grlnvalidDriver
-4

grNoLoadMem

-5
grNoScanMem

-6
grNoFloodMem
-7

grFontNot Found
-8

grNoFontMem

-9
grlnvalidMode
-10

grError

-11
grIOerror
-12
-

grlnvalidFont
-13
gr Inva 1 idFontNum -14


GraphErrorMsg,
Halt. ,
Graph: Get DriverName GetModeName. , . , ,
Writeln, OutTextXY.

152

15.

RestoreCRTMode.
. SetGraphMode,
, ,
. , Write In ReadKey.
OutTextXY,
Graph.
X Y ( ),
.
CloseGraph.


,
. , . .
, .
SetViewPort.
, , 100x100 ,
:
| SetViewPort(,,100,100,True);
SetViewPort , . True,
. GetViewSettings, -
ViewPortType, :
type
ViewPortType = record
xl, yl, x2, y2: integer;
Clip: boolean;
end;

ClearDevice, .
ClearViewPort.
, , , , . ' SetActivePage, SetVisualPage.

,
. ,
. CGA
(. . 15.3).
EGA/VGA , CGA, .
, 64 (26) 16 (24).

153

. 15.7 16
EGA/VGA, .
15.7. 16 EGA/VGA

( )

EGABlack
0 (000000)

EGABlue
1 (000001)

EGAGreen

2(000010)
EGACyan

3(000011)
EGARed

4(C00100)
EGAMagenta

5(000101)
EGABrown

6(000110)
^EGALightGray
-
7(000111)
EGADarkGray
56(111000)
-
EGALightBlue
-
57(111001)
EGALightGreen
-
58(111010)
EGALightCyan
-
59(111011)
EGALightRed
-
60(111100)
EGALightMagenta
-
61 (111101.)
EGAYellow

62(111110)
EGAWhite
63(111111)

,
, SetColor.
SetBkColor.
,
,
.
EGA/VGA ( 16 EGA, EGA64 VGA)
SetPalette SetAllPalette. SetPalette . ,
, :
SetPalette(0,EGAWhite);
SetPalette(63,EGABlack) ;
SetAllPalette
. , ,
PaletteType:
type
PaletteType = record
Size: byte;
Colors: array[0..MaxColors] of shortint;
end;

Size , Colors . , , .

154

15.

Graph SetRGBPalette, VGA IBM8514. . ( 0 255 IMB8514, 0 15 VGA),


(R), (G) () ). ,
:
SetRGBPalette(Black,63,0,0) ;
, .
Turbo Pascal ,
Graph_02.pas 15.5, File | Open (<F3>).
15.5. Graph_02 .pas
program Graph_02;
uses Graph, Crt;
var
i, DriverVar, ModeVar, ErrorCode: integer;
CurPal: PaletteType;
begin
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar,'\tp\bgi');
ErrorCode := GraphResult;
if ErrorCode <> grOK then
begin
Writeln(GraphErrorMsg(ErrorCode));
Halt(l);
end;
{ )
for i := 0 to 15 do
begin
SetFillStyle(1,i); { }
Bar(i*20, 0, (i+l)*20, 100); { }
end;
ReadKey;
,
{ }
for i := 0 to 15 do SetPalette(i, 15-i);
ReadKey;
{ }
CurPal.Size := 16;
for i := 0 to 15 do CurPal.Colors[i] := i;
SetAllPalette(CurPal);
ReadKey;
CloseGraph;
end.


Turbo Pascal ,
Graph_03.pas ,
15.6, File | Open (<F3>).


15.6. Graph_03.pas
program Graph_03;
uses Graph, Crt;
var
i, j, DriverVar, ModeVar, ErrorCode: integer;
PressedKey: Char;
{ }
procedure ShowPolygon;
var
PolyPoints: arra'y[l. .10] of PointType;
i: byte;
begin
{ }
PolyPoints[1].X := 300;
PolyPoints[1].Y := 50;
PolyPoints[10].X := 300; { }
PolyPoints[10].Y := 50; { }
for i := 2 to 5 do begin
PolyPoints[i] .X := PolyPoints[i-1] X + Random(50);
PolyPoints[i].Y := PolyPoints[i-1].Y + Random(SO);
end;
for i := 6 to 9 do begin,
PolyPoints[i].X := PolyPoints[i-1].X - Random(50);
PolyPoints[i]
Random(50);
end;
DrawPoly(10,PolyPoints); { }
ReadKey;
FillPoly(7,PolyPoints); {
7 }
end;
begin
DriverVar := EGA; { 16- EGA}
ModeVar := EGAHI; { 640x350}
InitGraph(DriverVar,ModeVar,'\tp\bgi');
ErrorCode := GraphResult;
if ErrorCode <> grOK then
begin
Writeln(GraphErrorMsg(ErrorCode)) ;
Halt(l);
end;
Randomize; { }
{ }
OutTextXY(10,10,' ');
for i := 0 to 15 do PutPixel(i*10+10, 30, i);
ReadKey;
ClearDevice; { }
{ }
1
OutTextXY(10,10,' );
^ }
SetViewPort(10,30,GetMaxX-10,GetMaxY-10,True);

155

156

15.

15.6
for i := 0 to 15 do
begin
SetColor(i); { }
for j := 0 to 4 do
begin
SetLineStyle(j,0,1); { )
Line(Random(GetMaxX div 2),Random(GetmaxY div 2),
Random(GetMaxX),Random(GetMaxY));
end;
end;
ReadKey;

ClearDevice;
GraphDefaults; { }
OutTextXY(10,10,' ');
OutTextXY(10,30,' ');
MoveTo(10,50); { }
SetColor(White);
SetLineStyle(SolidLn, 0, 3) ;
{ ,
}
repeat
PressedKey := Rea'dKey;
{ ,
10 }
case Ord(PressedKey) of
72: LineTo(GetX, GetY - 10); { }
75: LineTo(GetX - 10, GetY); { }
77: LineTo(GetX +,10, GetY); { }
80: LineTo(GetX, GetY + 10); { }
end;
until not (Ord(PressedKey) in [0,72,75,77,80]);
t,
ClearDevice;
{ )
OutTextXY(10,10,' ');
SetLineStyle(SolidLn,0,1);
OutTextXY(10,60,'');
Arc(50,80,0,100,50);
OutTextXY(150,60,'');
SetFillStyle(HatchFill,Green); { }
Bar(200,40,220,80);
OutTextXY(270,60,' ');
SetFillStyle(SolidFill,Red);
Bar3D(410,40,430,80,2,TopOn);
OutTextXY(10,100,'');
Circle(50,150,50);
OutTextXY(150,100,'');
Ellipse(200,150,0,360,20,40);
OutTextXY(270,100,' ');
SetFillStyle(XHatchFill,Blue);
FillEllipse(340,150,20,40);
OutTextXY(450,100,'');

157

15.6
Rectangle(470,110,530,160);
OutTextXY(10,210,'');
SetFillStyle(SolidFill,Yellow);
PieSlice(50,260,30,100,50);
OutTextXY(150,210,' ');
Sector(200,270,0,120,20,50);
ReadKey;
SetFillStyle(SolidFill,LightGray) ;
FloodFill(50,150,White); { }
Delay(2000);
{ 2 }
FloodFill(200,150,White); { }
Delay(2000);
FloodFill(500,150,White); { }
ReadKey;
ClearDevice;
OutTextXY(10,10,' ') ;
ShowPolygon;
ReadKey;
ClearDevice;
{ )
OutTextXY(10,10,' ');
SetTextStyle(TriplexFont,VertDir, 1) ;
OutTextXY(10,50,' 1');
SetTextStyle(TriplexFont,HorizDir,3);
OutTextXY(10,30,' 1);
OutTextXY(200,100,' ');
Rectangle(190, 90, 200 + TextWidth(' '),
110 + TextHeight(' '));
SetTextStyle(DefaultFont,HorizDir,3);
{ }
SetTextJustify(CenterText,CenterText);
OutTextXY(200, 200, 'A');
SetTextJustify(CenterText,TopText);
OutTextXY(230, 200, 'A');
SetTextJustify(CenterText,BottomText);
OutTextXY(260, 200, 'A');
SetTextJustify(CenterText,CenterText);
OutTextXY(400, 200, 'B');
SetTextJustify(LeftText,CenterText);
OutTextXY(400, 230, 'B');
SetTextJustify(RightText,CenterText);
OutTextXY(400, 260, 'B');
ReadKey;
CloseGraph;'
end.

Graph_03.pas .
15.4 . 15.5.
, Graph_03 ,
ReadKey. ClearDevice . ,

158

15.

, , .

. 15.5.
Graph 03.pas

. 15.5.
Graph_03. pas
GetMaxX GetMaxY .
GraphDefaults ,
,
SetViewPort.
LineTo Line , ,
, .

159

FloodFill , ,
, ,
. ,
, .
ShowPolygon PointType, (X Y) Integer.
, . , 10 , 10
PointType.

FillPoly .
, ,
, .
SetTextStyle .
DefaultFont', ,
. ,
TriplexFont, Trip.chr.
InstallUserFont. , :
var
Fnt: integer;
...

Fnt := InstallUserFont('MyFont.chr');
SetTextStyle(Fnt, HorizDir, 1);


. 15.4, . , EGAHI 2 . , ,
.
, .
: SetActivePage
SetVisualPage. SetActivePage ,
, .
() , SetVisualPage. , .
Turbo Pascal ,
Graph_04 .pas 15.7,
File | Open (<F3>).
15.7. Graph_04 .pas
program Graph_04;
uses Graph, Crt;
var
CurX, CurY, DriverVar, ModeVar, ErrorCode: integer;

160

15.

15.7
PressedKey: Char;
procedure DrawCircle(X, Y, Color: integer);
begin
SetColor(Color);
SetFillStyle(SolidFill,Color);
FillEllipse(X, Y, 150, 110);
end;
begin
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar,'\tp\bgi');
ErrorCode := GraphResult;
if ErrorCode <> grOK then .
begin
Writeln(GraphErrorMsg(ErrorCode)) ;
Halt(1);
end;
ClearDevice;
CurX := 200;
CurY := 200;
repeat
DrawCircle(CurX, CurY, Red); { }
PressedKey := ReadKey;
DrawCircle(CurX,CurY,GetBkColor); { }
case Ord(PressedKey) of
72: Dec(CurY,10); { }
75: Dec(CurX,10); { }
77: Inc(CurX,10); { }
80: Inc(CurY,10); { }
end;
until not (Ord(PressedKey) in [0,72,75,77,80]);
CloseGraph;
end.
Graph_04 . ,
.
, 15.8.
15.8. Graph_04 .pas
program Graph_04;
uses Graph, Crt;
var
CurPage: byte;
procedure DrawCircle(X, Y, Color: integer);
begin
if Color = GetBkColor


15.7
then FillEllipse(X, Y, 160, 120)
else FillEllipse(X, Y, 150, 110);
end;
begin

161

CurX := 200;
CurY := 200;
CurPage := 0;
SetActivePage(0) ;
repeat
DrawCircle(CurX, CurY, Red); { }
SetVisualPage(CurPage);
PressedKey :=.ReadKey;
CurPage := 1 - CurPage; ( )
SetActivePage(CurPage);
DrawCircle(CurX,CurY,GetBkColor); { }
until not (Ord(PressedKey) in [0,72,75,77,80]);
CloseGraph;
end.

Graph_04 , . ,
, " " .

, DrawCircle, ,
, , 10 .

16


. , , , . Turbo Pascal, , ,
Pascal, 8086 80286. .
.
Pascal .
asm.
assembler.
{$1} ,
external.

asm
asm :
asm
__
_
end;

, ' ";". ,
Pascal.


. :
1
:

,
\
*""
-
- :
[: __ _

.
Pascal,
Label, , "@", Label .

asm

163

,
. Turbo Pascal : LOCK, REP, REPE, REPZ, REPNE, REPNZ,
SEGCS,SEGDS,SEGES,SEGSS.
.

,
8x86 .
. ,
.
, . 16.1.
16.1.

16-


16-
16-
8087

, , , DX
AL, BL, CL, DL
, , , DH
SP, , SI, DI
CS, DS, SS, ES
ST

, Pascal,
, . 16.2.
16.2. ,

BYTE
WORD
DWORD
QWORD
TBYTE
NEAR

1
2
4
8
10
(
, ). :
procedure MyProc;

far;

asm

PUSH CS
' CALL NEAR PTR MyProc;
end;
FAR

, . 16.3.

164

16.

16.3. ,

&
, "&",
,
.
:
&
, ,
[...]

HIGH
. : HIGH
LOW
. : LOW
, , .
: DS : ,
OFFSET
( ) .
: OFFSET
"~
SEG
( ) .
: SEG
TYPE
.
: TYPE
PTR
, , ,
.
: 1/ PTR 2

+, -, *,
/, MOD

SHL,

SHR

NOT, AND, 0
R, XOR

asm
asm, , . Turbo Pascal ,
AsmEx_l .pas 16.1,
File | Open (<F3>).
16.1. AsmEx l.pas
program AsmEx_l;
uses Crt;
var
s: string;
Len: integer;
begin
ClrScr;
Write(' : ');
Readln(s);
Len := Length(s);
asm

assembler

165

16.1
LEA BX,s+l
{ }
MOV CX,Len
{ )
01: MOV ,[]
{ }
CMP ,97
{ ''}
JB @e
{ < '', }
CMP ,127
{ ''}
,
JA @2
{ >= '', - @2}
S0B ,32
{ - 32}
{
JMP @m
}
{ ''}
@2: CMP ,160
{ < '', }
JB @e
{ ''}
CMP , 223
{ >= '', - @3}
JA @3
{ '' '' - 32}
SUB ,32
{
JMP @m
}
{ '' '' - 80}
@3: SOB AH,80
{ }
@m: MOV [BX],AH
{ }
@e: INC BX
{ }
LOOP @1
end;
Writeln(s);
end.

assembler
assembler ,
. ,
. Turbo Pascal ,
AsmEx_2 .pas 16.2,
File | Open (<F3>).
16.2. AsmEx_2. pas
program AsmEx_2;
uses Crt;
var
n: integer;
function Mul2(ri: integer): integer; assembler;
asm

MOV AX,n
SHL AX,1
end;
function Div2(n: integer): integer; "assembler;
asm
MOV AX,n
SHR AX,1
end;

166

16.

16.2
begin
ClrScr;
Write(' : ');
Readln(n);
Writeln(n, ' * 2 = ', Mul2(n));
Writeln(n, ' / 2 = ', Div2(n)) ;
end.
, assembler, .
, Char Boolean
AL ( 1- ), ( 2 ) DX, ( 4- ).
real DX, BX, .
Single, Double, Extended Comp
ST.
DX, .

{$!_}
13, {$L} Pascal ,
. obj.
Pascal external. ,
12 Div2, AsmEx_2 (. 16.2),
(,^ Ops2.obj),
AsmEx_2 , 16.3.
16.3. AsmEx_2 .pas
program AsmEx_2;
uses Crt;
var
n: integer;
{$L Ops2.obj}
function Mul2(n: integer): integer; external;
function Div2(n: integer): integer; external;
begin
ClrScr;
Write(' : ') ;
Readln(n);
Writeln(n, ' * 2 = ', Mul2(n));
Writeln(n, ' / 2 = ', Div2(n));
end.

17


(, ,
, ..) ,
.
(),
.
- BIOS (Basic Input/Output
System), ROM
(Read Only Memory), MSDOS.
. . . 17.1.
17.1.

00
01
02
03
04
05
06
07
08
09

BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS

OF

BIOS
BIOS
BIOS
BIOS
BIOS

10
11
12
13

BIOS
BIOS
BIOS
BIOS

OD











AT .
COM2 COM4
1 COM3
LPT2

LPT1 ,
( )



-

168

17.

17.1

14
15

BIOS
BIOS

16
17

BIOS
BIOS
BIOS

-
AT


BASIC,







,

MS-DOS
,
,
<Ctrl+Break>
,


,18

1C
1D
1
1F

BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS

20
21
22

MS-DOS
MS-DOS
MS-DOS

23

MS-DOS

24

MS-DOS

25
26

MS-DOS
MS-DOS
MS-DOS

19
1
1

27

, - , .
.
.

Pascal
, Pascal,
.
1. Registers, , Intr,
. Registers, Intr Dos.
2. . INT.

Pascal

169


$05, . Turbo Pascal ,
IntOS.pas 17.1,
File | Open (<F3>).
17.1. IntOS.pas
program IntOS;
uses Crt, Dos;
var

Regs: Registers;
begin
Writeln(' Intr...');
Intr($05,Regs);
Writeln(' ');
ReadKey;
1
Writeln(' INT... );

asm
INT 05H
end;
end.
17.1, Intr, Dos, :
Registers. Dos :
type
Registers = record
case Integer of
0: (AX, BX, CX, Dk, BP, SI, DI, DS, ES, Flags: Word);
1: JAL, AH, DL, DH, CL, CH, DL, DH: Byte);
end;

$05 -
, IntOS Regs .

, . ,
$17 . , . ,
0, $17 ,
DX ( 0). AL. . Turbo Pascal , Intl7 .pas
17.2,
File | Open (<F3>).
17.2. Intl7.pas
program Intl7;
uses Crt, Dos;
var

Regs: Registers;

170 17.
17.2
s: string;
i : byte ;
begin
ClrScr;
Wr.iteln ( '
Readln(s) ;
for i : = 1 to Length (s)
begin
Regs. AH := $00;
Regs.AL := Ord(s[i]);
Regs.DX := $00;
Intr ($17, Regs) ;

" ' -\

'

" . . '

');
do
{AH }
{AL - }
{DX - }
{ }

end;
end.
Intl7 , ( ). (, $17) , . , $17,
, : ( = )
( = 2).
.

BIOS
BIOS $00 $1F.
, , , , . BIOS. .


$10 .


$10 $06.
, ( )
AL. AL 0, . ( 15)
, CL X Y ,
DL DH X Y
( 0).
$10 $02. ( 0) , DL DH.
Turbo Pascal ,
IntlO_l.pas 17.3, . File | Open (<F3>).

BIOS

171

17.3. IntlO_l. pas


program IntlO_l;
procedure SetCursor (x, y: byte); assembler/asm
{ }
MOV ,02
{ }
MOV BH,
{ }
MOV DL,x
MOV DH,
INT
end;
procedure ClearArea(Rows,Colors,LeftTopX,LeftTopY,
RightBottomX,RightBottomY: byte); assembler;
asm
MOV ,06
{ }
{ }
MOV AL,Rows
{ }
MOV BH,Colors
{ }
MOV CL,LeftTopX
MOV CH,LeftTopY
MOV DL,RightBottomX { }
MOV DH,RightBottomY
{ }
INT 10H
end;
begin
ClearArea(0,$07,0,0,79,24); { )
SetCursor(0,0);
Writeln('- ');
ClearArea(3,$1,,1,35,3); { }
SetCursor(0,2);
Writeln(' ');
end.
IntlO_l ClearArea, : (Rows), (Colors),
.
, .
, $07 , (0), - (7).
(1),
($ = 14).


$ 10 $09 $. $09 $
, .
AL,
, ( $09) BL, .
$13. AL
: 0 -

172

17.

; 1 ; 2 , , ; 3 , , . , , ,
DX .

$13 $10 , AT.


$09 $21
( " MS-DOS").
.
Turbo Pascal ,
IntlO_2.pas 17.4, File | Open (<F3>).
17.4. IntlO_2 .pas
program IntlO_2;
uses Crt;
var
i,a: byte;
c: integer;
s: string;
procedure SetCursor(x,y: byte); assembler;
asm
MOV AH,02H
MOV BH,OOH
MOV DL,x
MOV DH,y
INT 10H
end;
>!

'

begin
ClrScr;
{ }
> for i := 49 to 57 do
begin
SetCursor(0,i-49) ;
:= i - 48; { }
:: i - 42; { }
asm
MOV AH,09H { }
MOV AL,i
{ }
MOV ,
{ }
MOV BL,a
MOV CX,c
INT 10H
end;
end;
{ }
s := ' $13';
for i := 0 to 24 do
begin

BIOS

173

17.4
:= i+l;

asm

MOV
MOV
MOV
MOV
LEA
MOV
MOV
MOV
INT

{ }
{ }
{ }
{ }

,13
AL,1
BH,0
BL,7
BP,[s+1]
CX,c
DL,10
DH,i
10H

{ s}

{ }
{ X}
{ Y}

end;
end;
end.

IntlO_2 SetCursor (. 17.3), . 1 9, . , ,


, (. 17.1).

22

4444
5S555
666666
7777777
88888888
999999999

-:

$
1
13_

. 17.1. Intl0_2



$10.
$01 . 0 13 EGA 0 7 .
$03 .
DH, DL.

174

17.

$08 .
AL, .

$10 . Turbo Pascal , IntlO_3.pas


17.5, File | Open
17.5. IntlO_3 . pas
program IntlO_3;
uses Crt;
var
x,y,a,c: byte;
PressedKey: char;
procedure SetCursor(x,: byte); assembler;
asm
MOV ,02
MOV BH,
MOV DL,x
MOV DH,
INT 10H
end;
begin
ClrScr;
{ 0 7 }
for := 0 to 7 do
begin
for x := 1 to 15 do
begin
TextColor(x);
( }
TextBackGround(y); ( }
Write(Chr(y+48)); { }
end;
Writeln;
end;
x := 0;
:= 0;
repeat
SetCursor(x,y);
asm
{ )
MOV ,08 { }
MOV BH,0
{ }
INT 10H
MOV c,AL
{ }
MOV ,
{ }
end;
:= - 48; { }
asm
{
}

BIOS

175

17.5
MOV AH,01H
MOV ,

{ }
{ -
}
{ }

MOV CL,07
INT 10H
{ }
MOV ,
MOV ,00
INT 10H
MOV x,DL
MOV ,DH
end;
{
}
TextAttr := a;
SetCursor(20,0);
Writeln(' : =',:2,'/=',:2);
SetCursor(,); { }
PressedKey := ReadKey; { }
{ }
case PressedKey of
#72: if y>0 then Dec(y); { )
#75: if x>0 then Dec(x); { }
#77: if x<14 then Inc(x) { }
#80: if y<7 then Inc(y); { }
end;
until PressedKey = #27;
end.
. 17.2.
SetCursor,
17.3. IntlO_3
,
$10, Crt System.

mi-; 11

: =13/=

''

-I4-1 44 --44

555 55..55

. 17.2. Intl0_3
,

IntlO_3 15
. repeat .
1. ,
, .

176

17.

2. $08 $10 (
) ( ).
3. ,
48 ( "").
4. $01 $10 . ( )
( CL). $07.
$00, ,
$07. , "" , "7" , .
5. $01 $10
( ).
6. TextAtrr
, . . Writeln . ,
.
7. , ,
.
8. <Esc>.


$10: $00 ( ) $
.
, .
$00, AL. ,
16- 80x25 AL=$03, a
16- 320x200 AL=$OD.
$, AL, , DX.
, . Turbo Pascal , IntlO_4.pas 17.6,
File | Open (<F3>).

17.6. intlO 4 .pas


program IntlO_4;
uses Crt;
begin
asm
{ }
MOV ,00
{ . )
MOV AL,ODH { 320x200, 16 }
INT 10H
{ }

BIOS

177

17.6
MOV ,00
{ }
MOV ,00
{ )
MOV DX,00
{ }
@1: MOV AH,OCH { }
MOV AL,BL
{ }
INT 10H
INC CX

CMP CX,320
JNE 01

MOV CX,00
INC BL
INC DX

CMP DX,200
JNE @1
end;

{ }
{ 320?}
{ , }
{ , }
( }
{ }
{ 200?}
{ , )

ReadKey;

asm
{ }
MOV ,00
MOV A1,03
{ }
INT 10H
end;
end.
. 17.3.

. 17.3. Intl0_4


BIOS.
$10 ( $OF) .

178

17.

$11 .
$12 .
$13 ( $08)
. Turbo Pascal ,
Int_Qry .pas 17.7,
File | Open (<F3>).
17.7. Int_Qry.pas
program Int_Qry;
uses Crt;
var
rAL,rAH,rBH,rDL: byte;
rAX,rCX: word;
begin
ClrScr;
{ }
asm
MOV AH,OFH
INT 10H
MOV rAL,AL
MOV rAH,AH
MOV rBH,BH
end;
Writeln(' :');
case rAL of
0: Writeln(' (40x25) 16 ');
1: Writeln (.' (40x25) 16 ');
2: WritelnC' (80x25) 16 ');
3: Writeln(' (80x25) 16 ');
4: Writeln(' (320x200) 4 ');
5: Writeln(' (320x200) 4 ');
6: Writeln(' (640x200) 2 ');
7: Writeln(' (80x25) 3 ');
$OD: Writeln(' (320x200) 16 ');
$: Writeln(' (640x200) 16 ');
$OF: Writeln(' (640x350) 3 ');
$10: Writeln(' (640x350) 16 ');
$11: Writeln(' (640x480) 2 ');
$12: Writeln(' (640x480) 16 ' )-;
$13: Writeln(' (640x480) 256 ');
end;
Writeln(' - ',,' ');
Writeln(' - ',);
ReadKey;
{ }
asm
MOV ,11
INT 11H
MOV rAX,AX
end;

BIOS

179

17.7
Writeln(' ' ) ;
Writeln(' :');
if rAX and $01 = 0 then { 1- = 0}
Writeln(' ');
if rAX and $02 = 2 { 2- = 1}
then Writeln(' ')
else Writeln(' ');
Write(' : ' ) ;
case rAX and $OC shr 2 of { 3 4 }
1: Writeln('16');
2: Writeln('32K');
3: Writeln('64 ');
else Writeln('He ');
end;
Write(' : ');
case rAX and $30 shr 4 of { 5 6 )
1: Writeln(' 40x25');
2: Writeln(' 80x25');
3: Writeln('- 80x25');
else
end;
Writeln(' : ',(rAX and $CO) shr 6 + 1); {7,8}
if rAX and $1000 shr 12 = 1 then { 13- )
Writeln(' ');
Writeln(' : ',rAX shr 14); {15,16}
ReadKey;
\ (
{ }
asm
INT 12H
MOV rAX, AX
end;
WritelnC ') ;
Writeln(' : ',,'');
ReadKey;
{ }
asm
MOV ',08
MOV DL,80H { }
INT 13H
MOV ,
MOV rDL,DL

end;
Writeln('');
Writeln(' :');
Writeln(': ',rCX and $3F); { 6 }
Writeln(': ',rCX shr 6); { 10 }
Writeln(' : ',rDL);
ReadKey;
end.

180 17.

MS-DOS
, MS-DOS, BIOS,
, BIOS-. MS-DOS
$20 $62, 8 .
$20 MS-DOS.
$21 MS-DOS. MS-DOS
, , .
$22 .
$23 ,
<Ctrl+Break>.
$24 , .
$ 2 5 .
$2 6 .
$27 , . , .com.
$21, , , . $21 (,
) .
MS-DOS .


$02 $21,
$09 $40 . , , IntlO_2 ( 17.4) $21. Turbo Pascal IntlO_2 .pas,
Int21_l.pas. , 17.8, File | Open (<F3>).
17.8. Int21 I. pas
program Int21_l;
uses Crt;
var

i: byte;
c: integer;
s: string;
procedure SetCursor(x,: byte); assembler;
asm

MOV ,02
MOV BH,
MOV DL,x
MOV DH,y

MS-DOS

181

17.8
INT
end;

begin
ClrScr;
{ }
for i := 49 to 57 do
begin
SetCursor(0,i-49);
for := 1 to i - 48 do
asm
MOV AH,02H { )
MOV DL,i
( }
INT 21
end;
end;
{ }
for i := 0 to 24 do
begin
s := ' $40';
SetCursor(30,i);
:= i+1;
asm
MOV AH,4
{ )
MOV BX,01H
{ )
LEA DX,[s-] { s}
MOV CX,c
{ )
INT 21H
end;
end;
{ }
SetCursor(0,10) ;
s := ' 09$';
asm
MOV AH,09H
{ )
LEA DX, [s+1] { s)
INT 21H
end;
end.
$40 . 01 ( ), 04 . ,
$40 , .
, $09
, "$".



$21.
$01 .

182

17.

$06 ( ),
( ).
$07
<Ctrl+Break>.
$08
<Ctrl+Break>.
$ .
. Turbo Pascal , Int21_2.pas
17.9,
File | Open (<F3>).
17.9. Int21 2 .pas
program Int21_2;
uses Crt;
type
Buffer = Record
MaxLen: byte;
ActLen: byte;
Chars: array[1..254] of char;
end;
var s: string;
i: integer;
: char;
Buf: Buffer;
procedure EnterString(fNura: byte);
begin
s: = " ;
Writeln(' : ');
for i := 1 to 255 do
begin
asm
MOV AH,fNum { }
INT 21H
MOV c,AL
. end;
if c=#13 then break; { Enter}
s := s + ;
end;
Writeln(' "',s,'"');
,
end;
begin
ClrScr;
EnterString($01); { }
EnterString($07); { }
{ }
Write(' : ');'
Readln(Buf.MaxLen);
Inc(Buf.MaxLen); { }
Writeln(' Enter: ');

MS-DOS

183

17.9
asm
MOV AH,OAH
LEA DX,Buf { )
INT 21H
end;

Write(' : ');
for i:= 1 to Buf.ActLen do Writa(Buf.Chars[i]);
ReadKey;
end.


EnterString,
$21. , B u f f e r ,
DX . : ,
.
, ( 13), , . ActLen.

$21.
$05 ,
DL. $40 . . Turbo Pascal ,
Int21_3.pas 17.10,
File | Open (<F3>).
17.10. Int21_3 .pas
program Int21_3;'
uses Crt;
var

s: string;
i: integer;
: char;
begin
ClrScr;
Write(' : ') ;
Readln(s);
{ )
for i := 1 to Length(s) do
begin
:= s[i];
asm

MOV
MOV
INT
MOV
INT

AH,05
DL,c
21H
DL,OAH
21H

{ )

184

17.

17.10

end;
end;
{ }
i := Length(s) ;
asm
MOV AH,40H
MOV BX,04H ( )
MOV CX,i
{ }
LEA DX, s
{ }
INT 21H
end;
end.
( 10 $), Int21_3, ,
. , , ( 13 $00).


$21
$2 $2. ,
, . Turbo Pascal ,
Int21_4.pas 17.11,
File | Open (<F3>).

17.11. Int21_4 .pas


program Int21_4;
uses Crt;
type
DateType = record
Year: word;
Month: byte;
Day: byte;
end;
TimeType = record
Hour: byte;
Minute: byte;
Second: byte;
end;
var
PriorDate,CurDate: DateType;
PriorTime,CurTime: TimeType;
procedure SetCursor(x,y: byte); assembler;
asm
MOV ,02
MOV BH,
MOV DL,x
MOV DH,
INT 10H
end;

MS-DOS
17.11
{ }
function PadL(num,len: byte): string;
var
s:string[2];
i: integer;
begin
Str(num,s); { }
if Length(s) < len { }
then PadL := '0' + s else PadL := s;
end;
begin
ClrScr;
while not KeyPressed do
begin
{ }
asm
MOV AH,2AH
INT 21H
MOV CurDate.Year,CX
MOV CurDate.Month,DH
MOV CurDate.Day,DL
end;
if (CurDate.Year <> PriorDate.Year) or
(CurDate.Month <> PriorDate.Month) or
(CurDate.Day <> PriorDate.Day)
then begin
PriorDate.Year := CurDate.Year;
PriorDate.Month := CurDate.Month;
PriorDate.Day := CurDate.Day;
SetCursor(0,0);
Write(PadL(CurDate.Day,2), '.',
PadL(CurDate.Month,2), '.',
CurDate.Year);
end;
{ }
asm
MOV AH,2CH
INT 21H
MOV CurTime.Hour,CH
MOV CurTime.Minute, CL
MOV CurTime.Second, DH
end;
if (CurTime.Hour <> PriorTime.Hour) or
(CurTime.Minute <> PriorTime.Minute) or
(CurTime.Second <> PriorTime.Second)
then begin
PriorTime.Hour := CurTime.Hour;
PriorTime.Minute := CurTime.Minute;
PriorTime.Second := CurTime.Second;
SetCursor(72,0);
Write(PadL(CurTime.Hour,2), ':',

185

186 , 17.
17.10
PadL(CurTime.Minute, 2) ,
PadL(CurTime.Second,2)) ;

end;
end;
end.

Int21_4 PadL num,


len. KeyPressed Crt,
True , -
.
,
. , , .
$2 $20.
, , , , ,
$2 $2.

18
Turbo Vision
Turbo Vision - , , .
,
, , Turbo Vision.
, Turbo Vision ( "",
- ). , Turbo Vision, ( ), .
, . ,
, . , "",
"".
Turbo Vision ,
:
;
;
;
;
;
, , ;
.
Turbo Vision -
. , Turbo Vision.
- 12.

,
Turbo Vision
Turbo Vision -. ,
,
TApplication. Turbo Vision
, , TApplication .

188

18. Turbo Vision

Turbo Pascal , tv_l .pas


, 18.1,
File | Open (<F3>).

18.1. TV l.pas
program tv_l;
uses App;
type
TMyApp = Object(TApplication)
end;
var

MyApp: TMyApp;
begin
MyApp.Init;
MyApp.Run;
MyApp.Done;
end.
tv_l .
. 18.1. , , ; , , .

... -

ftIt

. 18.01. , Turbo Vision


tv_l <Alt+X>,
.
, , . tv_l TApplication. Init () . Run ( "" ). Done
(),
, <Alt+x>, , Run.
'

, Turbo Vision

189

,
Turbo Vision, , , TApplication Init, Run Done.


TApplication. Init
:
TApplication.InitDesktop ;
TApplication. InitMenuBar ;
TApplication. InitStatusLine .
(
), Init.
.
InitStatusLine
StatusLine. ,
. , , InitStatusLine , .
Turbo Vision ,

TRect. TRect : . , .
,
.
GetExtent, - TRect, ( TRect Objects). ,
InitStatusLine
GetExtent ,
TRect. tv_l (. 18.1), 18.2.
18.2. Tv_l. pas
program tv_l;
uses App, Objects;
type
TMyApp = Object(TApplication)
procedure InitStatusLine; virtual; { }
end;
procedure TMyApp.InitStatusLine; ( }
var R: TRect;
begin
,
GetExtent(R);
{ }
R.A.Y := R.B.Y - 1; {
}
end;

190

18. Turbo Vision

18.2
var
: ;
begin
.Init;
.Run ;
.Done;
end.
tv_l ,
- , <Alt+x> (. 18.2).

. 18.2.
, InitStatusLine

.
,
. ,
, ,
. , .
, .
NewStatusDef ( Menus).
tv_l , ,
.
InitStatusLine (. 18.2) , 18.3.
New statusLine, Init.
, R, Trect.
*

, Turbo Vision

191

, NewStatusDef,
( 0 SFFFF) , StdStatusKeys. tv_l , NewStatusDef "" nil.
- , nil
NewStatusDef.

18.3.
procedure TMyApp.InitStatusLine;
var R: TRect;
begin
GetExtent(R);
R . A . Y := R . B . Y - 1;

New(StatusLine,
Init (R, { , R }
NewStatusDef (0, $FFFF, (
O..FFFF)
StdStatusKeys (nil), (
)
n i l ) ) ) ; ( )
end;

tv_l . ,
: <Alt+x> , <F10> , <Ctrl+F5> . tv_l
. StdStatusKey NewStatusKey,
StdStatusKey, .
InitStatusLine (. 18.3) ,
18.4.
18.4.
program tv_l;
uses ..., Drivers, Views;
procedure' TMyApp.InitStatusLine;
var R: TRect;
begin
New(StatusLine,
-Init (R, NewStatusDef (0, $FFFF,
t NewStatusKey('~~', kbF3, cmOpen,
NewStatusKey('~Alt+F3~3aKpbiTb', kbAltFS, cmClose,
NewStatusKey (' ~Alt+X~Bbixofl' , kbAltX, cmQuit,
StdStatusKeys (nil) ))))',
nil)));
end;

192

18. turbo Vision

NewStatusKey . : , ; ; .
, ("~"), .
, ,
. .
<Alt> <Ctrl>. , .
, Drivers, kb.
Turbo Vision ,
Views, cm. .
.
tv_l , <F3> ( ""), <Alt+F3> ( ""). , , (<Alt+X>).
tv_l , , <Alt+F3> . , ( cmClose) Turbo Vision (. 18.3).

. 18.3. tv_l
*

'

./


, InitStatusLine , initMenuBar
MenuBar. -

, Turbo Vision

193

InitMenuBar. , , . , . , .
tv_l (. ) InitMenuBar ( 18.5).
18.5. InitMenuBar
program tv_l;
uses App, Objects, Menus, Drivers, Views;
type
TMyApp = Object(TApplication)
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
end;

procedure TMyApp.InitMenuBar;
var R: TRect;
begin
GetExtent(R);
R.B.Y := R.A.Y + 1;
MenuBar :=
New(PMenuBar,
Init(R, NewMenu( ( }
NewSubMenu('', hcNoContext, NewMenu( ( )
( }
Newltem('', 'F3', kbF3, cmCpen, hcNoContext,
Newltem('', 'Alt-F3', kbAltFS, cmClose,
hcNoContext,
NewLine( ( }
NewItem('Bbi~x~ofl', 'Alt-X 1 , khAltX, cmQuit, hcNoContext,
nil)))))),
nil))));
end;

NewMenu, NewSubMenu,
Newltem. NewMenu
NewSubMenu , , NewMenu.
Newltem , , , ,
.
NewLine. tv_l , ,
cmOpen, cmClose cmQuit (. 18.4).


, , : , -

194

18. Turbo Vision

.
, . , , , " " .

. 18.4.
TEvent , . Turbo Vision
, ,
- TEvent. ,
, , , . , .
Word What,
, , . evCommandj
. ,
Command, ,
, .
, Alt+FS (
<Alt+F3>), ,
What evCommand, Command cmClose. . cmClose, Close.
. , ,
, .
,
.

TApplication.HandleEvent, -

, Turbo Vision

195

TEvent. tv_l cmQuit ( 18.6).


18.6. cmQuit
program tv_l;
uses App, Objects, Menus, Drivers, Views, MsgBox;
type
TMyApp = Object(TApplication)
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
end;

procedure TMyApp.HandleEvent(var Event: TEvent);


begin
if Event.What = evCommand then { }
case Event.Command of
cmQuit: if MessageBox(#3' ?',nil,
mfConfirmation or mfOKCancel) = cmCancel
then ClearEvent(Event); { ,
}
end;

inherited HandleEvent(Event);
end;

{ }

HandleEvent . (Event.What = evCommand),


Event. Command. , cmQuit
,
.
MessageBox, MsgBox. .
1. , . , #3,
, .
2. , . ,
"" nil.
3. , .
(mblnformation,
mfWarning, mfConfirmation mfError)
(mfOKButton, mfOKCancel mfYesNoCancel) or.
, MessageBox, . , cmOK, cmCancel, cmYes cmNo.
(. 18.6) cmQuit HandleEvent
: Cancel.
(. 18.5).
,
HandleEvent, cmQuit . Cancel
<Esc>, cmQuit -

196

18. Turbo Vision

ClearEvent. , Event
. , HandleEvent .
I


: ,
.. Turbo Vision StdDlg.
tv_l ,
TFileDialog. tv_l. pas ,
18.7.
18.7.
program tv_l;
uses ..., StdDlg,Editors;
type
TMyApp = Object(TApplication)
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure FileOpen;
end;
MyApp: TMyApp;
procedure TMyApp.HandleEvent(var Event: TEvent);
begin
if Event.What = evCommand then { )
case Event.Command of

cmOpen: FileOpen;
end;
inherited HandleEvent(Event); { }
end;
function OpenEditor(FileName: FNameStr;
Visible: Boolean): PEditWindow;
var
P: PWindow;
R: TRect;
begin
DeskTop- 4 .GetExtent(R) ;

P := New(PEditWindow, Init(R, FileName, wnNoNumber));


if not Visible then PA.Hide;
OpenEditor := PEditWindow(Application*.InsertWindow(P));
end;
procedure TMyApp.FileOpen;
var
FileName: FNameStr; ( }
begin
FileName := '*.*';
( }
if ExecuteDialog(New(PFileDialog, Init('*.*', ' 1,

, Turbo Vision

197

18.7
' : ' , fdOpenButton, 100)), @FileName) <> cmCancel then
OpenEditor(FileName, True);
end;

cmOpen HandleEvent FileOpen.


FileOpen ExecuteDialog, : TFileDialog , ,
. Init TFileDialog 5 : , , ,
, . MessageBox,
ExecuteDialog . ,
( fdOpenButton), OpenEditor, .

DeskTop. OpenEditor TRect
. TEditWindow (
Editors), TRect , (
wnNoNumber).
( Visible = False), TEditWindow.Hide.
OpenEditor TApplication. InsertWindow .
(. 18.7) - , . ,
' EditorDialog ( ) ,
StdEditorDialog.
tv_l . Init, 18.8.
18.8. . Init
type
= Object(TApplication)
constructor Init;
end;
\
constructor .Init;
begin
inherited Init;
EditorDialog := StdEditorDialog;
end;
-
, , . , -

198

18. Turbo Vision

, . tv_l Init,
18.9, .
18.9. Init
program tv_l;
uses ..., Memory;

var
MyApp: TMyApp;
ClipWindow: PEditWindow;
constructor TMyApp.Init;
begin
MaxHeapSize = 8192;
inherited Init;
EditorDialog := StdEditorDialog;
ClipWindow := OpenEditor('', False)
if ClipWindow <> nil then
begin
Clipboard := ClipWindow*.Editor;
4
Clipboard' .CanUndo := False;
end;
end;
MaxHeapSize, Memory, . 16- ,
,
.
MaxHeapSize 8192 128 .
ClipWindow , . OpenEditor
, ClipWindow. , , , MaxHeapSize (
Clipboard). .
tv_l - (. 18.6 . 18.7).
cmClose HandleEvent.

Turbo Vision
Turbo Vision
,
. Turbo Vision TObject. . ( ), Init, Done Free, .

Turbo Vision

199

. 18.6.

E:\HOKKNBOOKS4COMPUIEBMP\flPPSMU_l.PftS =
roefraro tv_l!
.ses ftpp. Objects, Menus, Drivers, Uieus, MsgBox, StdDlg,
Editors, Memory;
type
IMyfipp = Object<Tflpplication>
procedure InitStatusLine; virtual; { >
procedure InitllenuBar; virtual;
procedure HandleEvent<var Event: T E u e n O ; virtual;
procedure FileOpen;
constructor Init;
end;

1 var

Myftpp: TMyflpp;

ClipWindou: PEditHindou;
1:1

_.

;,:

fllt*F33aKpHTb

. 18.7. tv_l .pas,


"" TObject TView, TValidator, TCollection, TResourceFile, TStream, TStringXist TStrListMaker. . 18.1.
18.1. "" TObject

TCollection ()
,

TCollection , , , :

""
TSortedCollection

200

18. Turbo Vision

18.1

""

TCollection ()
TSortedCollection, TStringCollection TResourceCollection.
, TCollection ,

TResourceFile
, . ,
TResourseFile.Put,
, .

TResourseFile.Get.
, , TResourseFile
( TResourseCollection)
TStream
, - . , GetPos, GetSize,
Read, Seek, Truncate Write

TSortedCollection

TDosStream
TEmsStream
TMemoryStream

TSrtingList
, . , ,
() 0 65535.
, , , . ,

, ""
TStrListMaker
TStringList,

'

Tvalidator
.

TView
, , , TView

TbackGround, Tcluster,
Teditor, Tframe,
Tgroup, Thistory,
T.inputLine,
Tlistviewer,
TmenuView, ScrollBar,
TstatioText,
TstatusLine,

. " Turbo Vision" . 21.

Turbo Vision

201

. 18.2 "" TView.


18.2. "" TView

""

TBackGround

,
.
TCluster
,
"" .

TEditor
,
64 Turbo Vision.
, ,
, /, , .

TFrame
.
,

TGroup
.
, TView,
TGroup (
)?
(
)
TInputLine
.
,

THi story
,

TListViewer
,

TCheckBoxes
TMultiCheckBoxes
TRadioButtons
TFileEditor
TMemo
'

TScroller
TWindow

THistoryViewer
TListBox

TMenuView

TMenuBar

TMenuBox

202

18. Turbo Vision

18.2
""


TScrollBar

TStaticText

TLabel

:
,
.

TParamText

TstatusLine

";:-

j :

. 18.3 "" TGroup.


18.3. "" TGroup

""

Tscroller

TDeskTop
TProgram

, . ,

TWindow
,
TFrame, TScroller
TScrollBar

TDialog
TEditWindow
THistoryWindow

. 18.4 "" TScroller.


18.4. "" TScroller

""

Tdesktop

,
TBackground, . TDeskTop ,
( )
( )
TProgram

Turbo Vision
. 18.5 .

- .

TApplication

Turbo Vision

203

18.5.

Dialogs

Editors
Menus

Objects

Menus

StdDlg
Validate

Views

TApplication
TBackGround
TCheckBoxes
TCluster
THistory
THistory Viewer
TInputLine
TLabel
TFileEditor
TEditor
TMenuBar
TMenuBox
TMenuPopup
TBv.f Stream
TCollection
TDosStream
TEmsStream
TMemoryStream
TObject
TRes our ceCol lection
TMenuBar
TMenuBox
TMenuPopup
TChDirDialog
TDialog
TLookupValidator
TPXPictureValidator
TRangeValidator
TFrame
TGroup
TListViewer

TDeskTop
TProgram
TListBox
TMultiCheckBoxes
TRadioButtons
TScrollbar
TStaticText
TParamTest
TEditWindow
TMemo
TMenuView
TStatusLine
TResourceFile
TSortedCol lection
TStrCollection
TStream
TStringCollection
TStringList
,
TStrListMaker
TMenuView
TStatusLine
TFileDialog
TSortedListBox
TStringLookupValidator
dator

TVali-

TS-croller
TView
TWindow

Turbo Vision .

-i

""


S
S

S
S ,

*''

i'* ?'

(. I

wfY '

16.1
* -1

""

^i_

** '|1-:

.. -

. ;
>% (
' 1 Ht.TEH'trfi ^ ( II

*net ' t

. ^-. JS. . 111

,1 pttSwMio oirono ^.,


- ^^^ . - ' :',?/': *'
*
| '; (",1,1 & t CCCI
(1 ^ ^,
; & . Era
eoci. * ^* wn*pe-Kti nav*.
^^'GblHi' 6$.' 0! ^ |?1 !i
* . ***_
^. r*m.rirC!M >, ?5,
1 :>*11*,

!
**
1>
{ *><*> ] K$*t! !}>-' tU!V5 1 .* )
II

ftB1

. ': .

^ iflg,

2. 1'

Op. UHd 3*<1

384

?3

: ;

v - -

3. toHHjp 2003

^UQ}^Uli^fi^iJ1iaKU!ilSJQfl
g^-jiJL ?0ltJ Ci'jJife. Mflftisfi ^

4. 2003 ^

AutoCAD 2000 ^^^ 70!-/!6


HMWK>

;..%;
{^11^"^'--..^.

:^4 e^eol
3&
61 75 .---.--"" T--J.J-T-.-.-.-.-

4 00

*"^
^

^*
": |
2201

'
|

:<u4

I'&SGj

1040 +fr55j
<,

"!

^O^Crb

'

IV

.
19 , .
20 ,
.
Pascal Turbo Vision.

19


, , ,
, (
). .
< , , . 8.


. ,
: , "", .


, ( ) ( ) , . , ,
(,
..). N-1 , N
,
, , N-1 .
.
Turbo Pascal , Sort_l .pas , 19.1,
File | Open (<F3>).

19.1. Sort l.pas


program Sort_l;
uses Crt;

var
A: array[1..20] of byte;
i,j,buf: byte;
{ }
procedure ShowArray;
begin
for i := 1 to 20 do Write(A[i]:4);

end;

207

19.1
{ . ByAsc = True, - .
ByAsc = False, - . }
procedure SortAr ray (ByAsc: boolean);
begin
for i
1 to 19 do
for j := i+1 to 20 do
if (ByAsc and (A[i] > A[j])) or
(not ByAsc and (A[i] < A [ j ] ) )
then begin
bu.f := A [ i ] ;
A[j]
end;

buf;

end;

begin
ClrScr;
{ }
Randomize;
for i := 1 to 20 do A[i] := Random (2 55 );
Writeln ( ' : ' ) ;
ShowArray;
SortAr ray (True) ; { }
Writeln ( ' :');
ShowArray;
SortArray (False) ; { }
Writeln ( ' :');
ShowArray;
ReadKey;
end.
_

,
, ^ . 19.1.

""
"" . , ( )
( )
, .
,
. "" Sort_l (. 19.1). Sort_l.pas
Sort_2.pas SortArray,
19.2 ,
File | Open (<F3>).
19.2. Sort 2 .pas
program Sort_2;
{ . ByAsc = True, - .
ByAsc = False, - .}
procedure SortArray(ByAsc: boolean);

208

19.

19.2
begin
for i := 1 to 19 do
for j := 1 to 20-i do

if

(ByAsc and (A[j] > A [ j + l ] > ) or


(not ByAsc and (A[j] < A [ j + l ] ) )
then begin
buf := A [ j ] ;

A[j+l]

buf ;

end;
end;

87

218

218

-i1
1

87

218

87

218

20

87

218

20

87

218

20

87

218

87

218

20

11
11

87

218

20

218

1111

20

218

42

20

11

200

1 = 1; j = 3

: :;,-

200

42

1 = 1; j = 5

200

11
11

42

i = 2; j = 3

_JL

11

200

42

200

42

i = 2; j = 6

200

i = 3; j = 4

200

11
11
11

i = 3; j = 5

11

42

200

42

1 = 3; J = 6

200

42

1 = 3; j = 9

i = 4; j = 5

1 = 4; j = 6

1 = 4; j = 9

1 = 5; j = 6

i = 5; j = 9

1 = 6; 1 = 7

1 = 6; j = 9

1 = 6; j = 10

i = 7; J = 9

i = 7; j = 10

i = 8; j = 9

i = 8; j = 10

1 = 9; j = 10

1 200 42
87
1 : 42 200
87
1 11 200 42 87
1 3 200 42 87
1 3 42; 200 87
1 _3_ Jl: 200 87
1 _ 3 11 87 200
1 3 11 .42. 200
1 3 11 20 200
1 3 11 20 87
1 3 11 20 ,42
1 3 11 20 42
1 3
20
42
"
1 3
20
42

i = 2j j = 5

_?.

"
-

218
218

1
~~

20

218

10

20

!
1

20

218

,1

20

20
20

20 |
20

:...

218

42

20

218

87

20

218

87

42

218

200

42

218

200

87

200

218

87

87

218

200

87

200

218 |

. 19.1.

209

,
, ''" . 19.2.
1

'.

'

11

i=1; j = 2
i=1; j = 3
1=1; j = 4

200

11
11

i
_

42

_1

3 : 1 200

42

4 2 ' 200

0 '

87 I 218 '

10

20

]
20 |

218

218

20 !

1218
87

20 i

200

42

200 : j

87

218

20 :

42

87

200

218

20 i

1 42

42

87

200

87

200

87

200

87

200

11
11

: f

1=1; j = 9

11

i = 2; j = 1

i = 2; j = 3

[. ;

i = 2; j = 4

11

:11 | 42

i = 2; j = 7

11

i = 2; j = 8

11

i = 3; j = 2

i = 3; j = 3

i = 3; J = 6

0
0
'

42

1
1

42
42
42

-[Tii.; 1 42
1 V:i1... 42
11 t; 42

4
87

87-

20

J 218 i

20 j 218 \
- -)
i
200
20
218 \

200 i 218

87

20

20

87

42

20

87

42

20

42

'

11 I

i = 4; j = 6

11

11

" i

11 | 20

; 218

200 218 I
I
I
!
200 218 |

i = 4; ] = 5

&
i

20

20

i = 4; j = 2

~~!

,::,2 218

200 | 218 i

0:

1
1

i = 4; j = 1

' '

218; 20

87

' "

200
. .-

i
i

20

! 1

11
i 1
1
1
! 11

L"j

i = 3; j = 7

i = 6; j = 3

1=1; J = 6

i = 5; j = 4

42

j.

11

11 ! 3

1 = 1; j = 5

i='l; j = 8

87 i 200 218 j
fi
\200 ! 218
20 I 87

[
" s
20
20

200 ! 218
.j
j
200 j 218 !

"

87

200 I 218

42 I

87

200 , 218

42

87

200 j

218

. 19.2. ""

:
. ,
.
, .
Sort_2.pas (. ) Sort_3.pas
SortArray, 19.3 - i|t
, -3%
File | Open (<F3>).
*&

210

19.

19.3. Sort_3 .pas


program Sort_3;
{ . ByAsc = True, - .
ByAsc = False, - .}
procedure SortArray(ByAsc: boolean);
t
var n,x: byte;
begin
for i := 2 to 20 do { )
begin
:= A[i];
{ }
{ }
j :- 1;
while (ByAsc and (n > A[j])> or
(not ByAsc and (n < A[j]))
do Inc(j);
{ n}
for x := i-1 downto j do A[x+l] := A[x];
{ )
A[j] := n;
end;
end;
,
, . 19.3.

i = 3; j = 1

i = 4; j = 3

i = 5; j = 1

i = 6; \ = 2

0
0
0

i = 10; j = 6

200 I
i

11 I

3
200^
42

0
42
" ' '

1 j 87

10

218

20 ,

218

87

87
I
I
!J ! 42 >ouj 1 I 87
..~*j.
-_
L
: 1

3 J 1 1 I 42
87
1^
:
' | ....7>t -..-.rH- ..~~*_ 200^
1
3
11 ! 42 J 87
200^.

'M

L.

&l -
1 1

4_ ?>
11 ' 20 ;
4

fe

20
)

87^
42

218

218

218

218

i
L
j

20 |
20 i

- i
20 i
20

'.

200^ 218^; 20
__:8I>

200.

.c j
21

^J
. 1 9.3.


,
. , ,
, ( )
, ,
. , .
. ,
.

211

Sort_3.pas (. 19.3) Sort_4.pas SortArray, 19.4 ,


File | Open (<F3>).
19.4. Sort_4 . pas
program Sort_4;
{ . ByAsc = True, - .
ByAsc = False, - .}
procedure SortArray (ByAsc: boolean; First, Last: byte) ;
var
mid : byte ;
begin
i := First; ( )
j : = Last;
( )
( )
mid := A[ (First + Last) div 2] ;
repeat
( ,
)
while (ByAsc and (A[i] < mid)) or (not ByAsc and (A[i] > mid))
do Inc(i) ;
(
, )
while (ByAsc and (A[j] > mid or (not ByAsc and (A[j] < mid))
do Dec ( j ) ;
j
if i <= j then
*
begin ( )
buf := A[i] ;
A[j] := buf;
Inc(i); ( )
Dec(j) ; ( )
end;
until i > j; ( ,
"" )
( )
if First < j then SortArray (ByAsc, First, j) ;
( )
if i < Last then SortArray (ByAsc /i, Last) ;
end;

begin
SortArray (True, 1,20) ;

{ }

SortArray (False, 1,20) ; { }


end;


SortArray.

212 19.



,
.
. ,
. , . ,
. , .
Turbo Pascal (, 19.4),
BSearch.pas , 19.5 , File |
Open (<F3>).
19.5. BSearch.pas
program BSearch;
uses Crt;
var
A: a r r a y [ 1 . . 2 0 ] of byte;
i , j , b u f , n : byte;
Found: boolean;
begin
{ , }
Write(' : ');
Readln(n);
buf := 0;
i := 1;
{ )
j := 20;
{ )
Found := False;
repeat
buf := (i + J) div 2; ( )
if A[buf] = n then
{ )
begin
Found := True; { )
break;
{ )
end;
{ , )
if A[buf] < n then j := buf - 1;
{ , )
if A[buf] > n then i := buf + 1;
until i > j ;
if Found
1
then Writeln(' ',buf,'-My )
else Writeln(' ');
ReadKey;
end.

213


,
. , , .
Turbo Pascal ,
Matrix_l.pas , 19.6, , File | Open (<F3>).
19.6. Matrix_l .pas
program Matrix_l;
uses Crt;

var
A: array [1..5,1..5] of real;
i,j: byte;
sum: real;
( }
procedure ShowArray;
begin
for i := 1 to 5 do
begin
for j := 1 to 5 do Write(A[i,j]:6:1); '
WritelnC ' ) ;
end;
end;
begin
ClrScr;
{ )
Randomize;
for i := 1 to 5 do
for j := 1 to 5 do A[i,j] := Random(255);
Writeln(' :') ;
ShowArray;
{ )
for i := 1 to 5 do
begin
sum := 0; { )
for j := 1 to 5 do sum := sum + A[i,j];
A[i,i] := sum/5;
end;
Writeln(' :');
ShowArray;
ReadKey;
end.
Matrix_l . 19.4.
, , ,
. Turbo
Pascal , Matrix_2 .pas -

214

19.

, 19.7, File | Open (<F3>).

- '

"

.4, [ 5 i 1JJ3 | 4

, 0

2 j 9 7

1 I

raiTratti-'

i 0 3, ^ 9 i 7 | 1

I 3 | 7 I,1!;! 5 ; 0

6 j 4_; 9 j*,j i

0 i 5 I 6 : 5I 5
. 19.4. Matrix_1
19.7. Matrix_2 r pas
program Matrix_2;
uses Crt;
var
A: array [1..5,1..5] of byte;
B: array[1..10] of byte; { }
i, j: byte;
( }
procedure ShowArray;
begin
for i := 1 to 5 do
begin
for j := 1 to 5 do Write(A[i,j]:4);
WritelnC ' ) ;
end;
end;
{ . ByAsc = True, - .
ByAsc = False, - .}
procedure SortArray(ByAsc: boolean);
var
buf: byte;
begin
for i := 1 to 9 do
for j := i+1 to 10 do
if (ByAsc and (B[i] > B[j])) or
(not ByAsc and (B[4J < B[j]))
then begin
buf := B[i];
B[j]
end; /

buf;

end;

{ .
FromAtoB = True,
FromAtoB = False, }
procedure CopyArrays (Lefthalf , FromAtoB: boolean);
var
iBegin, iEnd, jBegin, jEnd, c: byte;


19.7
begin
{
}
if LeftHalf then
begin
{ }
iBegin := 2; iEnd := 5;
jBegin := 1; jEnd := 1;
end else
begin
{ }
iBegin := 1; iEnd := 4;
jBegin := 2; jEnd := 5;
end;
{ }
:= 1; { }
for i := iBegin to iEnd do
begin
for j := jBegin to jEnd do
begin
if FromAtoB"
then B[c] := A[i,j]
else Afi,j] := B[c];
Inc(c) ;
end;
if LeftHalf
then Inc(jEnd) else Inc(jBegin);
end;
end;
{ LeftHalf = True,
, - )
procedure SortHalf(LeftHalf: boolean);
begin
CopyArrays(LeftHalf,True); { }
SortArray(LeftHalf);
{ }
{ }
CopyArrays(LeftHalf,False);
end;
begin
ClrScr;
{ }
Randomize;
for i := 1 to 5 do
for j := 1 to 5 do A[i,j] := Random(255);
Writeln(' :');
ShowArray;
SortHalf(True) ; { }
SortHalf(False); { }
Writeln(' :');
ShowArray;
ReadKey;
end.

215

216

19.

Matrix_2 . 19.5.

9 1
^0
3 7 8 5
6 4 9 2

5 6

3-1

5 9

. 19.5. Matrix_2

. Turbo
Pascal , Matrix_3.pas - ijg,^
, 19.8, 1
File | Open (<F3>).
F~**i
19.8. Matrix_3 .pas
program Matrix_3;
uses Crt;
var
A: array [1..5,1..5] of byte;
i,j: byte;
( }
procedure ShowArray;
begin
for i := 1 to 5 do
begin
for j := 1 to 5 do Write(A[i,j]:4);
WritelnC ' ) ;
end;
end; ,
procedure TranspArray;
var
jEnd,buf: byte;
begin
jEnd := 1;
for i := 2 to 5 do
begin
for j := 1 to jEnd do
begin
buf := A [ i , j ] ;
A [ i , j] : = ' A [ j , i ] ;
A [ j , i ] := b u f ;
end;
Inc(jEnd) ;
end;
end;

217

19.8
begin
ClrScr;
{ }
Randomize;
for i := 1 to 5 do
for j := 1 to 5 do A[i,j] := Random(255);
Writeln(' :');
ShowArray;
TranspArray; { }
Writeln(' :');
ShowArray;
ReadKey;
end.
Matrix_3 . 19.6.

[ : 8[5] 7 1|3}4

8 [J 0 I 3

i 0 ! 2 ! 9 7 | 1

5(2

! ! 7 ! 5 I -o

1
9. - 8
,

; - 4 - -4

: 6

ii 0
!

1--

I-- - --

-+ +--
5 j 6 i 5 ! 9

L_ L__

'

9 6
i-

iLJL

4j- 1 0

Ji,A

. 19.6. Matrix_3

20


, . Pascal
Crt: Sound, NoSound Delay. Sound , , , Word. NoSound. Delay Sound
NoSound . ,
Delay (1000) .
, ,
$33.
. . 17.


, , .
. 20.1.
20.1.

()
- (#)
Pe(D)
- (D#)
()
()
- (F#)
(G)
- (G#)
()
- (#)
()

131
139
147
156
165
175
186
196
208
220
234
247

262
278
294
312
330
349
371
392
416
440
467
494

523
555
587
623
659
699
742
785
832
880
934
988

1047
1111
1174
1246
1318
1396
1482
1568
1664
1760
1868
1975

, . 20.2.
Turbo Pascal ,
Piano.pas , 20.1,
File | Open (<F3>).

219

20.2.

<-

->

<t>


( )

( )
""
"-"
""
"-"
""
""
"-"
""
"-"
""
"-"
""

<i>
<>

<>

<f>

<a>

<v>

<>

<>

<>

<>

<>

<>

<>

<j>

<0>

<>

<>

<k>

<>

<,>

<>

<1>

<>

<.>

<

20.1. Piano.pas
program Piano;
uses Graph, Crt;

var
DriverVar, ModeVar, ErrorCode,
MouseX, MouseY, CurNote, CurDelay: integer;
PressedKey: Char;
CurDiez: boolean;
Notes: string;
( note - ,
. diez = True, - .
IsPoint = True, ,
IsPoint = True, }
procedure DrawPosition(note: char; diez,IsPoint: boolean);
var
x: integer; ( }
begin
if diez ( () }
then begin
SetColor(DarkGray); ( - -}
( X
Notes. 50 - }
:= 170 + (pos(note,Notes) - 1)*50;
if IsPoint
then SetFillStyle (SolidFill, Red)

220

20.

20.1
else SetFillStyle(SolidFill,DarkGray);
FillEllipse(x,125,5,5); ( }
end else begin { }
SetColor(White); { - }
:= 145 + (pos(note,Notes) - 1>*50;
if isPoint
then SetFillStyle(SolidFill,Red)
else SetFillStyle(SolidFill,White);
FillEllipse(x,190,5,5);
end;
end;
{ }
procedure DrawKey(note: char; diez: boolean);
var
x: integer; { X }
begin
if diez { () }
then begin
x := 155 + (pos(note,Notes) - 1)*50;
SetFillStyle(SolidFill,DarkGray);
Bar(x,50,x+30,135); { }
end else begin { }
x := 120 + (pos(note,Notes) - 1)*50;
SetFillStyle(SolidFill,White); { }
SetColor(DarkGray); { }
Rectangle(x, 50, x+50, 200);
FloodFill(x+1,51,DarkGray);
end;
end;
{ }
procedure PlayNote(note: char; diez: boolean)
begin
case note of
if diez then Sound(555). else Sound(523);
{}'
if diez then Sound(623) else Sound(587);
{Pe}'D
{}
Sound(659);
if diez then Sound(742) else Sound(699);
{}
{}
if diez then Sound(832) else Sound(785);
if diez then Sound(934) else Sound(880);
{}
Sound(988);
{}
.
\
end;
Delay(CurDelay*1000); {
CurDelay=l -
CurDelay=2 -
CurDelay=4 - }
NoSound; { }
end;
{ }
procedure DrawDelay;
begin {
- }


20.1
SetFillStyle(SolidFill, LightGray) ;
Bar (200,210,500,350) ;
{ }
SetFillStyle(SolidFill,DarkGray);
SetColor(DarkGray);
case CurDelay of
1: begin ( - }
FillEllipse(300,300,30,15);
Line(330,300,330,220);
end;
2: begin ( - }
Ellipse(300,300,0,360,30,15);
Line(330,300,330,220);
end;
4: Ellipse(300,300,0,360,30,15); { }
end;
end;
begin
Notes := 'CDEFGAH'; { }
CurDelay := 1; { - }
{ )
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar,'\tp\tp\bgi');
{ }
ErrorCode := GraphResult;
if ErrorCode <> grOK then
begin
Writeln(GraphErrorMsg(ErrorCode));
Halt (1);
end;
SetBkColor(LightGray); { - -}
ClearDevice; { - }
{ }
DrawKey('',False)
{ }
DrawKey('D',False)
{ }
DrawKey('E', False)
{ }
DrawKey('F',False)
{ }
DrawKey(,'G1,False)
{ }
DrawKey('A1,False)
{ }
DrawKey ('H' , False)'
{ -}
DrawKey('',True)
{ -}
DrawKey('D',True)
{ -}
DrawKey('F' , True)
{ -}
DrawKey('G',True)
{ -}
DrawKey('A',True)
1; { }
CurNote
CurDiez
False; { }
DrawPosition(Notes[CurNote],CurDiez,True); { }
DrawDelay; { }
{ }
repeat

221

222

20.

20.1
{ , PressedKey #0}
if PressedKey #0 then PlayNote(Notes[CurNote],CurDiez);
PressedKey := ReadKey; { }
DrawPosition(Notes[CurNote],CurDiez,False); {
}
case PressedKey of
{ , , , ,
}
#72: CurDiez := (CurNote in [1,2,4,5,6]);
{ - ,
}
#75: if not ((CurNote = 1) and not CurDiez)
then if CurDiez then CurDiez := False
else Dec(CurNote);
{ , - ""}
#77: if CurNote < 7
then begin
Inc(CurNote); { }
{ , }
if CurDiez then CurDiez := False;
end;
{ , - ,
}
#80: if not ((CurNote = 1) and not CurDiez)
then if not CurDiez then
begin
CurDiez := (CurNote in [2,3,5,6,7]);
Dec(CurNote);
end;
{ }
'','','1,'': begin
CurNote := 1;
CurDiez := False;
end;
'F1, 'f, 'A', 'a' : begin
CurNote := 1;
CurDiez := True;
end;
'V,'v','M1,'M': begin
CurNote := 2;
CurDiez := False;
end;
'G','g','','n1: begin
CurNote := 2;
CurDiez := True;
end;
'','','','': begin
CurNote := 3;
CurDiez := False;
end;
'N','n','T','T': begin
CurNote := 4;

223

20.1
CurDiez := False;
end;
J','j','','': begin
CurNote := 4;
CurDiez := True;
end;
'M','m','','': begin
CurNote := 5;
CurDiez := Falge;
end;
'K','k','', '': begin
CurNote := 5;
CurDiez := True;
end;
'<',',','','6': begin
CurNote := 6;
CurDiez := False;
end;
L','!','','': begin
CurNote := 6;
CurDiez ,:= True;
end;
'>','.','','': begin
CurNote := 7;
CurDiez := False;
end;
{ "+"}
'+','=': if CurDelay < 4 then
begin
( }
Inc(CurDelay,CurDelay);
DrawDelay; { )
end;
{ "-"}
'-','_': if CurDelay > 1 then
begin
Dec(CurDelay,CurDelay div 2);
DrawDelay;
end;
end;
{ . }
DrawPosition(Notes[CurNote],CurDiez,True);
until PressedKey = #27; { -. Esc}
CloseGraph; { }
end.
1

. 20.1.


, , .

224

20.

"" - .

. 20.1. Piano
$33.
$01 .
$03 .
$04 .
$07 .
$08 .
,
.
,
, . , .
Turbo Pascal ,
FreePen.pas ,
20.2, File | Open
20.2. FreePen.pas
program FreePen;
uses Graph, Crt;
var
DriverVar, ModeVar, ErrorCode: integer;
ButtonPressed,MouseX,MouseY,PrevX,PrevY: word;
i,CurColor: byte;

225

20.2
{ }
procedure DrawMarker;
begin
\
SetColor(15 - CurColor); ( , }
OutTextXY(26+CurColor*39, 10,'X'); { "X"}
end;
begin
{ )
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar,'\tp\tp\bgi');
ErrorCode := GraphResult;
if ErrorCode <> grOK then
begin
Writeln(GraphErrorMsg(ErrorCode));
Halt (1);
end;
{ }
SetColor(White);
{ }
for i := 0 to 15 do
begin
SetFillstyle(SolidFill,i); { }
Rectangle(10+i*39, 5, 10+(i+l)*39, 20); { }
FloodFill(ll+i*39, 6, White);
end;
CurColor := White; { )
DrawMarker; { }
asm
MOV AX,01 { )
INT* 33H
MOV AX,07 {
}
MOV CX,01 { XI )
MOV DX,640 { 2 )
INT 33H
MOV ,08 (
}
MOV CX,01 { Y1 }
MOV DX,350 { Y2 }..
INT 33H
MOV ,04 { }
MOV ,320 { X}
MOV DX,175 { Y}
INT 33H
end;
{, - )
while not KeyPressed do
begin
asm
MOV A X , 0 3 { }
INT 33H

226

20.

20.2
MOV ButtonPressed,BX { - }
MOV MouseX,CX
{ - X }
MOV MouseY,DX
{ DX - Y }
end;
if ButtonPressed = 0 { }
then PrevX := 0 ( }
else { - )
if MouseY <= 20 then { }
begin
case ButtonPressed of
1: begin { }
{ :}
{ }
SetFillStyle(SolidFill,CurColor);
Bar(22+CurColor*39,6,
33+CurColor*39,19);
{ }
CurColor := (MouseX-10) div 39;
{ )
DrawMarker;
end;
2: begin { }
{ }
SetFillStyle(SolidFill,(MouseX-10) div 39);
Bar (0,21,640,350); { }
end;
end;
end
else begin {
}
SetColor(CurColor); {
}
if PrevX > 0 then begin { }
{ -
}
if MouseX > PrevX
then MouseX := PrevX+1
else MouseX := PrevX-1;
if MouseY > PrevY
then MouseY := PrevY+1
else MouseY := PrevY-1;
{
}
Line(PrevX,PrevY,MouseX, MouseY);
end;
{ }
PrevX := MouseX;
PrevY := MouseY;
end;
end;
CloseGraph; { }
end.

""

227

. 20.2.

. 20.2. FreePen

""

"". , "", "" , .
"" ( ). "" "", , "" - "".
"" "". "" .
, $09 $33. ES
( Seg), DX
Cursor ( Ofs),
.
.
Turbo Pascal ,
Hunter. pas ,
20.3, File | Open
20.3. Hunter . pas
program Hunter;
uses Graph, .Crt;
const Cursor:array [1..32] of word=

228

20.

20.3
($FFFF,$FFFF,$FFFF,$FFFF,$FFFF, $FFFF, $FFFF, $FFFF/
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF, $FFFF, $FFFF,
$0000., $OFFO,$OFFO, $OFFO, $OFFO, $OFFO, $OFFO, $FFFF,
$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF);
var
Shots, i, d, DriverVar, ModeVar, ErrorCode: integer;
cSeg,cOffs,PressedButton,MouseX,CurX,CufY: word;
Aims,sRating: string;
Rating :v real;
{ Color)
procedure DrawBall(Color: Word);
begin
SetFillStyle(SolidFill,Color);
SetColor(Color);
FillEllipse(CurX,CurY,7,5);
end;
begin
{ }
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar,'\tp\tp\bgi');
ErrorCode := GraphResult;
if ErrorCode <> grOK then
begin
Writeln(GraphErrorMsg(ErrorCodeJ );
Halt(l) ;
end;
cSeg := Seg(Cursor);
{ Cursor}
cOffs := Ofs(Cursor); { Cursor}
asm
MOV AX,01 { }
INT
MOV AX,09 { }
MOV BX,7 { X }
MOV ,0 { Y }
MOV ES,cSeg { }
MOV DX,cOffs { }
INT
MOV ,07 {
}
MOV ,01 { XI }
MOV DX,620 { 2 }
INT
MOV ,08 {
}
MOV ,300 { }
MOV DX,300 { Yl = Y2 = 300}
INT
MOV AX,04 { }'
MOV ,320 { X}

""

229

20.3
MOV DX,300 { Y}
INT
end;
Randomize;
{ )
CurY := 0;
{ Y }
CurX :=,700 { X ( )}
Aims := ''; {, }
Shots := 0; ( }
{ ,
- }
while not KeyPressed do
begin
asm
MOV AX,03 { )
INT
MOV PressedButton,BX { }
MOV MouseX,CX { X }
end;
DrawBall(Black); { }
if CurX > 640 then { }
begin
CurX := 0; { }
CurY := 5 + Random(200); { }
end;
Inc(CurX); { X }
DrawBall(Yellow); ( }
Delay(300); { ,
. , }
if PressedButton = 1 then { }
begin
{ ""}
Inc(Shots);
{ }
Sound(1900);
{ ""}
{
, }
SetColor(Red);
Line(MouseX,l,MouseX,300);
Delay(100); { ""
, }
{ " " }
SetColor(Black);
Line(MouseX,1,MouseX,300);
NoSound; { ""}
,
{ ""
, 5 / ...}
if abs(MouseX-CurX) = 5 then
begin
{~" "}
DrawBall(Red); ( }
{ ' "}
-for i := 200 to 800 do
begin
if (i-mod 20) = 0 then Sound(i);
Delay(20);

230

20.

20.3

end;
DrawBall(Black); { , )
{ " " }
for i := 1000 downto 200 do
begin
{ }
if (i mod 10) = 0 then Sound(i);
{ "
" - , }
SetColor(Red);
d := i div 100;
Line(CurX,CurY,CurX-d,CurY-d);
Line(CurX,CurY,CurX,CurY-d);
Line(CurX,CurY,CurX+d,CurY-d);
Line(CurX,CurY,CurX+d,CurY);
Line(CurX,CurY,CurX+d,CurY+d);
Line(CurX,CurY,CurX,CurY+d);
i
Line(CurX,CurY,CurX-d,CurY+d);
Line(CurX,CurY,CurX-d, CurY);
Delay(30);
{ "" }
SetColor(Black);
SetFillStyle(SolidFill,Black);
Bar(CurX-d,CurY-d,CurX+d,CurY+d);
end;
Aims := Aims + '*'; { ""
""}
Rating := Length(Aims)/Shots*100; {}
Str(Rating:6:2,sRating); { ' }
{ , ,
""}
SetColor(Black);
SetFillStyle(SolidFill,Black) ;
Bar(570,330,640,350);
{ }
SetColor(White);
OutTextXY(5,330,Aims);
OutTextXY(570,330, sRating) ;
NoSound; ( '}
CurX := 700; { } ,
end;
end;
end;
{ }
SetColor(Red);
SetFillStyle(SolidFill,Black);
Bar(5,330,565,350);
OutTextXY(5,330,' ! ');
ReadKey; { ReadKey , }
ReadKey; { ,
repeat KeyPressed}
CloseGraph;
end.

""

231

. 20.3.

3.75

. 20.3. Hunter

21

__^_


.

, . , , ,
(, Microsoft Excel). , ,
, . (, dBase)
, (, Paradox) .
, ,
. ,
, Turbo Vision TCollection -.

,

9 Audio, - . ,
.
, .

,
. , , Audio ,
-.
, , .
, - , . ,
, -.
, . -

_ ,

233

, , .
AudioDB, -. . cdd. . cdd ,

( . trd). . cdd
. trd.

_
,
. , , . AudioDB ,
,
.
. cdd ,
. trd .
. , , , , .

,
.
<>, <Insert>, <Delete>. <t> <4>. ,
- , Crt TextColor TextBackGround.
Turbo Pascal ,
AudioDB. pas ,
21.1, File | Open
21.1. AudioDB . pas
program AudioDB;
uses Crt;
type
{ }
Track = record
DiscNum: word;
{ }
TrackNum: word;
{ )
Name: string[40]; { }
Hours: 0..3; / " {}
Minutes: 0..59;
{}
Seconds: 0..59;
{}
end;
{ }'
CD = record

234

21.

21.1
DiscNum: word;
Author: string[20],
Title: string[40];
Year: integer;
Kind: string[10]
end;

{ }
()
()
()
()

var
: char;
DBName,DBDir: string;
FileCDs: File of CD;
FileTracks: File of Track;
CDRec: CD;
TrackRec: Track;
i,j,CurY: byte;
CurRec,CurTrack,TopCDRec,TopTrack: Word;
PressedKey: char;
InCDArea:
boolean;

{ ' "-"}
procedure DrawLine;
begin
for i := 1 to 79 do Write('-');
Writeln( " ) ;
end;
(
"/")
procedure ShowPosition;
begin
CurY := WhereY; ( )
GotoXY(1,1);
( )
Write (' ':10); ( )
( )
GotoXY(1,1);
Write(CurRec,'/',FileSize(FileCDs));
GotoXY(1,CurY); ( )
end;
(
-)
procedure CDDataLine;
begin
Read(FileCDs,CDRec);
Writeln(CDRec.Author:20,'I',CDRec.Title:40, ' | ',
CDRec.Year:4,'

iCDRec.Kind);
end;
(
)
procedure TrackDataLine;
begin
Writeln(TrackRec.TrackNum,'. ',
, .
TrackRec.Name,' (',
TrackRec.Hours,'',

,
21.1
TrackRec.Minutes, '',
TrackRec.Seconds,'',')')
end;

{ .trd,
. Creating = True,
, - }
procedure OpenTrackFile(Creating: boolean);
var
NumStr: string[8];
begin
if FileSize(FileCDs) > 0 then { }
begin
{ }
{ ,
}
Seek(FileCDs,CurRec-1);
Read(FileCDs,CDRec); { }
{ }
Str(CDRec.DiscNum,NumStr);
{'
FileTracks "NumStr".trd DBDir}
Assign(FileTracks,DBDir+'\'+NumStr+'.trd');
if Creating then
begin
Rewrite(FileTracks);
Close(FileTracks);
end else Reset(FileTracks);
end;
end;
{,
}
procedure ShowTracksCount;
begin
GotoXY(69,21);
Write(': ',FileSize(FileTracks));
end;
{
}
procedure ShowTracks;
begin
CurY := WhereY;
{ ,
, (7 )}
GotoXY(l,14);
for i := 1 to 7 do WritelnC ':79);
if FileSize(FileCDs)> 0 then { }
begin
{ }
{ .trd,
}
OpenTrackFile(False);
ShowTracksCount; { }

235

236

21.

21.1

i := 1;
{ }
GotdXY(l,14);
while not Eof (FileTracks) do
begin
Read(FileTracks,TrackRec);
TrackDataLine;
inc(i) ;
if i = 8 then break; { 7 }
end;
Close(FileTracks);
end;
GotoXY(l,CurY);
CurTrack := 1; { - }
end;
( ..cdd.
}
function InsertCD: word;
var
CurCDRec: CD;
InsertPos: word; { }
begin
InsertPos := 0;
{ }
if FileSize(FileCDs) = 0 { .cdd }
then CDRec.DiscNum := 1
else
begin { .cdd )
{ }
Seek(FileCDs,FileSize(FileCDs)-I);
Read(FileCDs,CurCDRec);
{ 1 }
CDRec.DiscNum := CurCDRec.DiscNum + 1;
{ }
Seek(FileCDs,0);
while not Eof(FileCDs) do { }
begin
Read(FileCDs,CurCDRec);
{ ""+""
, }
if (CurCDRec.Author + CurCDRec.Title) >
(CDRec.Author + CDRec.Title)
then Break; { ,
}
Inc(InsertPos);
end;
{ )
if InsertPos < FileSize(FileCDs) then
begin
Seek(FileCDs,FileSize(FileCDs)); {}
Write(FileCDs,CDRec);
{ }

237

21.1
{ }
for i := (FileSize(FileCDs)-l)
downto InsertPos + 1 do
begin
("" }
' ' Seek(FileCDs,i-l) ;
Read(FileCDs,CurCDRec) ;
Write(FileCDs,CurCDRec) ;
end;
end;
end;
{ }
Seek(FileCDs,InsertPos);
Write(FileCDs,CDRec);
InsertCD := FilePos(FileCDs);
end;
{ .trd)
procedure InsertTrack;
var
CurTrackRec: Track;
InsertPos: word; { }
begin
OpenTrackFile(False); { .trd}
InsertPos := 0;
if FileSize(FileTracks) > 0 then { .trd }
begin
{ )
Seek(FileTracks,0);
while not Eof(FileTracks) do
begin
Read(FileTracks,CurTrackRec);
{
)
}
if CurTrackRec.TrackNum >
TrackRec.TrackNum then Break; { }
Inc(InsertPos); { }
end;
{ }
Seek(FileTracks,FileSize(FileTracks));
{ }
Write(FileTracks,TrackRec);
{ .trd }
for i := (FileSize(FileTracks)-1) downto InsertPos + 1 do
begin
Seek(FileTracks,i-1);
{ }
Read(FileTracks,CurTrackRec) ;
Write(FileTracks,CurTrackRec);
end;
{ }
Seek(FileTracks,InsertPos);
end;

238

21.

21.1
Write (FileTracks,TrackRec); { }
ShowTracksCount;
{ }
Close(FileTracks);
{ .trd}
end;
{ }
procedure DelCD;
var
CurCDRec: CD;
CurPos: word;
begin
CurPos := CurRec; { }
while CurPos < FileSize(FileCDs) do { .cdd}
begin
{ , }
Seek(FileCDs,CurPos);'
Read(FileCDs,CurCDRec);
Seek(FileCDs,CurPos-1);
Write ^FileCDs,CurCDRec);
Inc(CurPos);
end;
{ }
Seek(FileCDs,FileSize(FileCDs)-1);
Truncate(FileCDs);
end;
{ }
procedure DelTrack;
var
CurTrackRec: Track;
CurPos: word;
begin
OpenTrackFile(False); { .trd}
{ , ' }
CurPos := CurTrack;
while CurPos < FileSize(FileTracks) do
begin
{ }
Seek(FileTracks,CurPos);
Read(FileTracks,CurTrackRec);
Seek(FileTracks,CurPos-1);
Write(FileTracks,CurTrackRec);
Inc(CurPos);
end;
{ }
Seek(FileTracks,FileSize(FileTracks)-1);
Truncate(FileTracks);
ShowTracksCount; { }
end;
{ }
begin
(, ""}

,
21.1
while <> '0' do begin
ClrScr; { }
repeat { )
Writeln(' :');
Writeln('0 - ');
Writeln('l - '1;
Writeln('2 - ');
Readln(c);
until in [' 0'. . ' 2'];
if <> '0' then
begin
Write(' : ');
Readln(DBName);
{
, }
if pos('.cdd1,DBName) = 0 then
DBName := DBName + '.cdd';
Assign(FileCDs,DBName);
{ }
DBDir := " ;
for i := Length(DBName) downto 1 do
if DBName[i] = 'V then
{ }
begin
{ ""}
DBDir := copy(DBName,1,i);
Break;
end;
{ }
DBDir := DBDir + copy(DBName,Length(DBDir)+1,
pos('.',DBName)-Length(DBDir))
if = '
!
' then
begin { )
Rewrite(FileCDs);
Writeln(' ',DBName,'.cdd ...');
MkDir(DBDir); { }
Writeln(' ',DBDir,' ...');
end;
{ )
Reset(FileCDs);
Writeln(' ',DBName,'.cdd ...');
ClrScr;
GotoXY(l,24);
{ }
DrawLine;
Write('Esc - , Insert - ',
'Delete - , Tab - ');
GotoXY(l,l);
{ }
Writeln('
|
|',
1

!
' |

');
DrawLine;
{ 7 )

239

240

21.

21.1
Seek(FileCDs,0) ;
for i := 1 to 7 do
if Eof(FileCDs) then
begin
for j := i to 7 do
WritelnC ':20,'I',' ':40,'|',' ':4,'|',' ');
brea,k;
end else CDDataLine;
DrawLine;
CurRec := 1; { }
TopCDRec := 1; ( )
( }
Writeln(' :');
WritelnC ':20,',' ':40,'|',' ':4,',' ');
DrawLine;
ShowTracks; ( }
( }
GotoXY(l,21);
DrawLine;
Writeln(' :');
WritelnC ':3,'.',' ':40,' ( )');
GotoXY(l,3);
TopTrack := 1; ( }
InCDArea := True; { - }
repeat { ,
Esc}
( .cdd }
Seek(FileCDs,CurRec-l);
ShowPosition; ( }
PressedKey := ReadKey; ( }
case PressedKey of
#09: begin {}
{
}
InCDArea := not InCDArea;
{ ,
)
if InCDArea
then GotoXY(l,3 + CurRec - TopCDRec)
else GotoXY(l,14);
end;
#72: begin ( }
if InCDArea then ( }
if CurRec > 1 then ( }
begin
Dec(CurRec); ( )
Seek(.FileCDs,CurRec-l) ;
if WhereY > 3 { }
then GotoXY(l,WhereY-l)
else ( }
begin
{ }
GotoXY(l,9);

241

21.1
DelLine;
{
)
GotoXY(l,3);
InsLine;
{ }
CDDataLine;
{ ,
}
Dec(TopCDRec);
{ }
GotoXYd, WhereY-l) ;
end;
( }
ShowTracks;
end;
( }
if not InCDArea then
if CurTrack > 1 then
begin
Dec (CurTrack);
if WhereY > 14 { }
then GotoXYd, Where Y-l)
else { )
begin
GotoXYd, 20) ;
DelLine;
GotoXYd, 14) ;
InsLine;
OpenTrackFile(False) ;
Seek"(FileTracks,CurTrack-l) ;
Read(FileTracks,TrackRec);
Close(FileTracks);
TrackDataLine;
Dec(TopTrack);
GotoXYd,WhereY-1) ;
end;
end;
end;
180: begin { )
if InCDArea then
if CurRec < FileSize(FileCDs) then
begin
,
Inc(CurRec);
Seek(FileCDs,CurRec-1);
{ , ...}
if WhereY < 9 then
{ }
GotoXY(1,WhereY+l)
else
begin
{
, }

242

21.

21.1
GotoXY(l,3) ;
DelLine;
{
}
GotoXY(1,9);
InsLine;
{ }
CDDataLine;
{
, }
Inc(TopCDRec);
{ }
GotoXY(1,Whe reY-1);
end;
ShowTraCks; { }
end;
if not InCDArea then { }
begin
OpenTrackFile(False);
if CurTrack < FileSize(FileTracks) then
begin
Inc(CurTrack);
if WhereY < 20 then
GotoXY(1,WhereY+l)
else
begin
GotoXY(1,14);
DelLine;
GotoXY(l,20);
InsLine;
Seek(FileTracks,CurTrack-1);
Read(FileTracks,TrackRec);
TrackDataLine;
Inc(TopTrack) ;
GotoXY(1,WhereY-1);
end;
end;
Close(FileTracks);
end;
end;
#82: if InCDArea then { }
begin
{ )
CurY := WhereY;
GotoXY(1,12); { 12- }
Readln(CDRec.Author);
GotoXY(22,12);
Readln(CDRec.Title);
GotoXY(63,12);
Readln(CDRec.Year);
GotoXY(68,12);
Readln(CDRec.Kind);
{ .cdd}

,
21.1
CurRec := InsertCD;
{ }
OpenTrackFile(True);
GotoXY(1,12);
WritelnC ':20,',' ':40,'.,' ':4,',' ':);
{
^ }
if CurRec in [TopCDRec..TopCDRec+6] then
begin
{ }
GotoXYU, 9) ;
DelLine;
GotoXYU, 3+CurRec-TopCDRec) ;
InsLine;
Seek(FileCDs,CurRec-l) ;
CDDataLine;
GotoXY(l,WhereY-l);
end else begin
{ ,
}
GptoXY(l,CurY) ;
CurRec := TopCDRec + CurY - 3;
end;
ShowTracks;
end else
begin
{ }
CurY := WhereY;
{ )
TrackRec.DiscNum := CDRec.DiscNum;
{ 23- }
GotoXYU, 23) ;
Readln(TrackRec.TrackNum) ;
GotoXY(5,23);
Readln(TrackRec.Name);
GotoXY(47,23);
Readln(TrackRec.Hours);
GotoXY(50,23);
Readln(TrackRec.Minutes);
GotoXY(53,23);
Readln(TrackRec.Seconds);
{ .trd}
InsertTrack;
{ )
GotoXY(1,23);
WritelnC ':3,'.',? <:40,' ( )');
{
)
if TrackRec.TrackNum in [TopTrack..TopTrack+6]
then, begin
{ )
GotoXY(1,20);
DelLine;

243

244

) 21.

21.1
GotoXYd, 14+TrackRec.TrackNum-TopTrack) ;
InsLine;
TrackDataLine ;
GotoX Y(l, Where Y-l);
CurTrack := TrackRec.TrackNum;
end else GotoXYd, CurY) ;
end;
#83: { }
if InCDArea then { }
begin
CurY := WhereY;
DelCD; { }
DelLine; { }
{
}
GotoXYd, 9) ;
InsLine;
{ . cdd 7
} '
if (FileSize (FileCDs) < 7) or
(CurRec > FileSize (FileCDs) )
then begin
{
"" }
WritelnC ' :20, ' | ', ' ' :40, ' ,
{
,
}
if CurRec > FileSize (FileCDs)
then CurRec := FileSize (FileCDs) ;
end else
begin
Seek (FileCDs, CurRec-1) ;
CDDataLine;
end;
{
}
if (3 + CurRec - TopCDRec) < .CurY
then Dec (CurY); { }
GotoXYd, CurY) ;
ShowTracks;
end else { }
begin
CurY := WhereY;
DelTrack;
GotoXYd, CurY) ;
DelLine;
GotoXYd, 20) ;
InsLine;
if (FileSize (FileTracks) < 7) or
(CurTrack > FileSize (FileTracks) )
then begin

Turbo Vision

245

21.1
WritelnC ':-79);
if CurTrack > FileSize(FileTracks)
then CurTrack := FileSize(FileTracks)
end else
begin
Seek(FileTracks,CurTrack-1) ;
Read (FileTracks, TrackRec)' ;
TrackDataLine;
end;
Close(FileTracks};
if (14 + CurTrack - TopTrack) < CurY
then Dec(CurY);
GotoXY(l,CurY);
end;

end;
until PressedKey = #27; { Esc}
Close(FileCDs); { .cdd)
end;
' end;
end.
. 21.1.

DC Talk!
DC Talk!
Ron Kennoley!

! !

Jesus Freak! 1998! Bock


Supernatural '2001 !Hock
Dwell in the House 2002 ! Pop

1
:
1. It's killing roe <22>
2. Dive <4!2>
3. consume me <054>

( :

-: 3

>

Esc - , Insert - Delete - , Tab -

. 21.1. AudioDB

Turbo Vision
- Turbo Vision.
, TCollection.
TCollection .
TPhone, Name

246

21.

Number, , Load Save,


.
, TStream, - . , .

-, , ,
RegisterType. , TPhone, TphoneColl.
TphoneColl TCollection. ,
, , , RegisterType:
RegisterType(TPhone);
RegisterType(TPhoneColl);
RegisterType TStreamRec, : , ,
.
, TPhone TPhoneColl
PhoneLst.pas. Turbo Pascal
, PhoneLst.pas 21.2, File | Open (<F3>).
21.2. PhoneLst.pas
unit PhoneLst;
{$X+}
interface
uses
Objects, Drivers, Views, Dialogs, App;
const
{, ,
}
cmAdd
= 104; { TPhone)
cmEdit
= 105; { TPhone}
cmRemove = 106; { TPhone}
type
NameStr = String[40];
{ }
NumberStr = String[12]; { }
{ TPhone.

, Load Store,
}
PPhone = ATPhone;
TPhone = object (TObject)
Name: NameStr;
Number: NumberStr;

Turbo Vision
21.2
constructor Init (AName: NameStr; ANumber: NumberStr);
constructor Load (var S: TStream) ;
procedure Store (var S: TStream);
end;
{ TPhoneListBox.
- Turbo Vision TListBox,
Ge,tText,
TPhone}
A
, PPhoneListBox = TPhoneListBox;
TPhoneListBox = object(TListBox)
function GetText (Item: Integer; MaxLen: Integer): String;
virtual;
end;
{ TPhoneColl.
- Turbo Vision TCollection,
Jhow, ,
,
)

PPhoneColl = 11;
TPhoneColl = object(TCollection)
function Show: Word;
end;
i
{ TViewDialog.
- Turbo Vision TDialog.^
,
TPhone,
.
PhoneColl - TPhoneColl.
L - ,
TPhone}
PViewDialog = ATViewDialog;
TViewDialog = object (TDialog)
PhoneColl: PPhoneColl;
L: PPhoneListBox;
constructor Init (APhoneColl: PPhoneColl);
procedure HandleEvent (var Event: TEvent); virtual;
end,(
{ RegisterPhone.
.

}
rocedure RegisterPhone;
L
implementation
{ TPhone}
{ Init - TPhone.
AName *- , ANumber - )
constructor TPhone.Init (AName: NameStr; ANumber: NumberStr);

247

248

21.

21.2
begin
TObject.Init; { }
{ TPhone}
Name := AName;
Number := ANumber;
end;
{ Load - TPhone
. ( Turbo Vision TSrteam) }
constructor TPhone.Load (var S: TStream);
begin
S.Read(Name, SizeOf(NameStr));
{ )
S.Read(Number, SizeOf(NumberStr)); { }
end;
{ Store - TPhone
( Turbo Vision TSream)}
procedure TPhone.Store (var S: TStream);
')
begin
S.Write(Name, SizeOf(NameStr));
{ }
S.Write(Number, SizeOf(NumberStr)); { }
end;
{ TPhoneListBox}
{ GetText ,
, TPhone.
Item - .
MaxLen }
function TPhoneListBox.GetText (Item: Integer; MaxLen: Integer):
String;
var
S: String; { }
begin
= '
'

'
{Lis^.At(Item) - Item.
PPhone(List* >At(Item)) -
PPhone,
TPhone.Name TPhone.Number}
{ S, ,
Name, ,
Length(Name)}
Move (PPhone (List".At (Item) ) ^NameEl] , S[l],
Length(PPhone(ListA.At(Item))A.Name));
{ S, 42- ,
Number, ,
Length(Number)}

Move(PPhone(List^At(Item)) .Number[1], S[42],


Length(PPhone(List".At (Item) ).Number));
GetText := S; { }
end;
{ TPhoneColl}

Turbo Vision

249

21.2
{ TPhoneColl.Show ExecView
Turbo Vision TViewDialog, ,
}
function TPhoneColl.Show: Word;
begin
Show := DeskTopA.ExecView(New(PViewDialog,Init(@Self)));
end;
>
{ ModifyRecord ,
TPhone.
, , ,
ExecView.

"", TPhone )
function ModifyRecord (Phone: PPhone; Title: TTitleStr): Word;
var
R: TRect;
{ }
D: PDialog; { }
N,P: PInputLine; {
}
Result: Word;
{ }
begin
R.Assign(27,11,73,21); { }
{ ,
R}
D := New(PDialog, Init(R, Title + ' '));
R.Assign(2,2,44,3); { }
{ , R}
N := New(PInputLine, Init(R,40));
{ TPhone.Name}
NA.SetData(PhoneA.Name);
DA.Insert(N); { }
R.Assign(2,1,44,2); { ""}
{ - "")
DA.Insert(New(PLabel, Init(R,'',)));
R.Assign(2,5,16,6); { }
{ , R}
:= New(PInputLine, Init(R,12));
{ Phone.Number}
PA.SetData(PhoneA.Number);
DA.Insert (); { }
R.Assign(2,4,44,5) ; { ""}
{ - ""}
D A . Insert(New(PLabel, Init(R,'',N)));
R.Assign(5,7,15,9); { "OK")
{ - "".
bfDefault ,
, <Enter>)
DA.Insert(New(PButton, Init(R,'OK',cmOK,bfDefault)));
R.Assign (20,7,30,9); { ""}
A
D .Insert(New(PButton, Init(R,'',cmCancel,bfNormal)));
DA.SelectNext(False); { ""}

250

21.

21.2
{ }
Result := DeskTop* .ExecView (D) ;
if Result cmCancel then { "OK")
begin
W.GetData (PhoneA.Name) ;
{
TPhone.Name)
.GetData(.Number); {
Phone.Number)
end;
Dispose(D,Done); { }
ModifyRecord := Result;
end;
{ TViewDialog}
{ TViewDialog.Init -
}
constructor TViewDialog.Init(APhoneColl: PPhoneColl);
var
R: TRect; { }
SB: PScrollBar; { " "}
begin
R.Assign(10,5,70,16); { }
{
, R}
TDialog.Init(R, ' ');
PhoneColl := APhoneColl; { }
R.Assign(57, 2, 58,7); { }
SB := New(PScrollBar, Init(R)); { }
Insert(SB); { }
R.Assign(2,2,57,7); { )
{ - TPhoneListBox )
L := New(PPhoneListBox, Init(R,1,SB));
.NewList(PhoneColl); { }
Insert(L); { }
R.Assign(2,1,57,2); { }
{ }
Insert(New(PStaticText, Init(R,
'
')));
R.Assign(l,8,13,10); { ""}
{ ""}
Insert(New(PButton, Init(R,'',cmAdd,bfNormal)));
R.Assign(13, 8,25,10); { ""}
{ ""}
Insert(New(PButton, Init(R,'',cmEdit,bfNormal)));
R.Assign(25,8,36,10); { ""}
{ ""}
Insert(New(PButton, Init(R,'',cmRemove,bfNormal)));
R.Assign(36,8,49,10); { ""}
{ ""}
Insert(New(PButton, Init(R,'',cmOK,bfDefault)));
R.Assign(49,8,59,10); { ""}
{ ""}

Turbo Vision

251

21.2
Insert(New(PButton, Init(R,'',cmCancel,bfNormal)));
SelectNext(False); { "")
end;
{ TViewDialog.HandleEvent cmAdd, cmEdit
cmRemove, TViewDialog. ,
,
cmEdit cmRemove,
TPhoneColl }
procedure TViewDialog.HandleEvent (var Event: TEvent);
var
P: PPhone;
begin
TDialog.HandleEvent(Event); { }
if Event.What = evConvmand then { - }
begin
case Event.Command of
cmAdd: begin { ""}
{ TPhone
}
:= New (PPhone, Init ('.',"));
{ " "
"" ""}
if ModifyRecord(P,'.') cmCancel then
{ "",
- TPhone,
Name Number}
PhoneCollA.Insert(P)
else Dispose(P,Done); { "",
TPhone}
end;
cmEdit: { ""}
{ " "
.
"" "",

TPhone, .
- LA.Focused.
, - PhoneCollx.At(.Focused)}
ModifyRecord(PPhone(PhoneColl*.At(.Focused)), '');
cmRemove: { "")
{ PhoneColl
, .Focused}
PhoneColl*.AtDelete(LA.Focused);
end;
{
}
. SetRange (. List74. Count) ;
A
L .DrawView; { )
end;
if 111.Count >= 1 {
PhoneColl >= 1}
then EnableCommands([cmRemove,cmEdit]) {
"" "" }

252

21.

21.2
else DisableCommands([cmRemove,cmEdit]); ( ""
"" }
end;
(, }
const
srPhone
= 10001; ( )
srPhoneColl = 10002; ( }
RPhone: TStreamRec =? (
ObjType: srPhone; ( }
VMTLink: Ofs(TypeOf(TPhone)A); (
TPhone}
Load: OTPhone.Load; (
TPhone}
Store: @TPhone.Store ( -
TPhone}
RPhoneColl: TStreamRec = (
ObjType: srPhoneColl;
( )
VMTLink: Ofs(TypeOf(TPhoneColl)); (
TPhoneColl}
Load: @TPhoneColl.Load; (
TPhoneColl}
Store: @TPhoneColl.Store (
TPhoneColl}
( ,
}
procedure RegisterPhone;
begin
RegisterType(RPhone);
( TPhone}
RegisterType(RPhoneColl); ( TPhoneColl}
end;
end.

Turbo Pascal Phone .pas


21.3, File | Open
21.3. Phone. pas
program Phone;
{$X+}
<$S-}
uses
Dos, Drivers, Objects, Views, Menus, Dialogs,
StdDlg, MsgBox, App, PhoneLst;
const
(, ""}

Turbo Vision

253

21.3
cmNew
cmOpen

= 101;
= 102;

{ ""}
{ ""}

{ TPhoneApp - TApplication.
PhoneList TPhoneColl -
( PhoneLst).
CurrentFile
(.phn)}
type
A
PPhoneApp = TPhoneApp;
TPhoneApp = object (TApplication)
PhoneList: PPhoneColl;
{ }
CurrentFile: PathStr;
{ }
constructor Init;
{}
procedure NewPhoneList; { }
procedure OpenPhoneList; { }
procedure SavePhoneList; {" .phn}
procedure HandleEvent (var Event: TEvent); virtual;
procedure InitMenuBar; virtual;
procedure InitStatusLine; virtual;
end;
{ FileExists True, ,
, . ,
False}
function FileExists(FileName: PathStr): Boolean;
var
F: File;
begin
Assign(F,FileName);

{$!-}
Reset(F);
{$!+}
if lOResult <> 0 then FileExists := False
else begin
FileExists := True;
Close(F);
end;
end;
{ TPhoneApp}
( Init - }
constructor TPhoneApp.Init;
begin
TApplication.Init; { }
{ , .
,
-
-.
RegisterType . ,
RegisterDialogs ,
Dialogs, TDialog, TInputLfne, TButton, TCluster, TRadioButtons,
TCheckBoxes, TListBox, TStaticText, TParamText, TLabel THistory}

254

21.

21.3
RegisterOb j ects ; { ,
{ ,
RegisterViews ;
RegisterMenus;
{ ,
RegisterDialogs ; { ,
RegisterApp;
{ ,
RegisterPhone;
{ , -
CurrentFile := ' ' ; {

end;

Objects)
Views}
Menus }
Dialogs}
App}
PhoneLst}

.phn)

{ NewPhoneList - ' TPhoneColl


PhoneList*.Show.

TPhoneColl. , Show
, cmCancel ( ""),
TPhoneColl ( ) .phn}
procedure TPhoneApp.NewPhoneList;
begin
{ TPhoneColl.
- 10 .
10 )
PhoneList := New(PPhoneColl,Init(10,10));
CurrentFile := '';
{ .
PhoneListA.Show PhoneLst.
"", SavePhoneList}
if PhoneList* .Show <> cmCancel then SavePhoneList;
end;
{ OpenPhoneList NewPhoneList ,
TPhoneColl ( ) .phn}
procedure TPhoneApp.OpenPhoneList;
var
D: PFileDialog; {
}
S: TBufStream; { TBufStream
}
begin
{ }
D := New(PFileDialog,
Init('*.PHN',' ',
1
',fdOKButton + fdHelpButton,100));
{ }
if Desktop*.ExecView(D) ^<> cmCancel then
begin { ""}
0.GetFileName(CurrentFile) ; { }
if FileExists (CurrentFile) then
begin { )
{
CurrentFile. 512 }
S.Init (CurrentFile,,stOpenRead, 512) ;
{
TPhoneColl}

Turbo Vision

255

21.3
PhoneList := PPhoneColl(S.Get);
S.Done; { S}
{
( PhoneLst).
"", }
if PhoneLisf.Show <> cmCancel then SavePhoneList;
end
else begin { }
{
( MsgBox)
"Error" "")
MessageBox(' ' + CurrentFile + ' .',
nil,mfError + mfOkButton);
CurrentFile := '';
end;
end;
Dispose (D,Done); { }
end;
{ SavePhoneList -
TPhoneColl ( ). CurrentFile
, SavePhoneList
, PhoneList
, CurrentFile}
procedure TPhoneApp.SavePhoneList;
var
D: PFileDialog; {
}
S: TBufStream; { TBufStream
}
begin
if CurrentFile = '' then { }
begin
{ )
D := New(PFileDialog,
Init('*.PHN',' ',
'',fdOKButton + fdHelpButton,100));
{ ""}
if Desktop'4.ExecView(D) <> cmCancel then
{, ,
CurrentFile}
D .GetFileName(CurrentFile);
Dispose(D,Done); { }
end;
if FileExists(CurrentFile)
then { )
{
CurrentFile. 512 }
S.Init(CurrentFile,stOpenWrite,512)
else
{ CurrentFile
. 512 )
S.Init(CurrentFile,stCreate,512);

256

21.

21.3
S.Put(PhoneList); {
, CurrentFile)
S.Done; { 3}
Dispose(PhoneList,Done); { }
end;
'
{ )
procedure TPhoneApp.HandleEvent (var Event: TEvent);
begin
TApplication.HandleEvent (Event) ; { }
if Event.What = evCommand then
{ - }
begin
,
case Event.Command of
cmNew: NewPhoneList;
{ ""}
cmOpen: OpenPhoneList; { ""}
else Exit; { - }
end;
ClearEvent(Event); { }
end;
end;
{ }
procedure TPhoneApp.InitMenuBar;
var
R: TRect;
begin
GetExtent(R);
R.B.Y := R.A.Y + 1;
MenuBar := New(PMenuBar, Init(R,NewMenu(
NewSubMenu ('',hcNoContext,NewMenu(
Newltem ('','F3',kbF3,cmNew,hcNoContext,
Newltem ('','F5',kbF5,cmOpen,hcNoContext,
NewLine (Newltem('','Alt-X',kbAltX,cmQuit,
hcNoContext,nil))))),nil))));
end;
{ }
procedure TPhoneApp.InitStatusLine;
var
R: TRect;
begin
GetExtent (R);
R.A.Y := R.B.Y - 1;
StatusLine := New (PStatusLine,Init (R,
NewStatusDef (0,$FFFF,
NewStatusKey ('~F3~ ',kbF3,cmNew,
NewStatusKey ('~F5~ ',kbF5,cmOpen,
NewStatusKey ('~Alt-X~ ',kbAltX,cmQuit,
NewStatusKey ('',kbFlO,cmMenu,nil)))),nil)));
end;
var
PhoneApp: PhoneApp;

Turbo Vision

257

21.3
begin
PhoneApp.Init;
PhoneApp.Run;
PhoneApp.Done;
end.

( }
{ }
{ }

, PhoneLst Turbo
Pascal Turbo Vision.
Turbo Pascal .
PhoneLst, Phone.pas
. ,
. 21.2.

F3

"' l"t - X"

. 21.2. Phone

'

.
, . 21.3.
. (. 21.4).
. , . 21.5.
. 2.15 . , , (. . 2.14)

258

21.

. , .

. 21.3.

. 21.4.
. . (. 21.6).

. 21.5.

. 21.6.

Turbo Vision

259

.phn,
, .

Phone | ( <F5>)
. phn.

Turbo Pascal
Turbo Pascal .
, .
, .


( setup.exe install, ) ,
, ,
. , . Turbo Pascal
, . ,
(, Turbo Vision Windows).

. . , ,
Turbo Pascal.
.


Turbo Pascal
turbo.exe ( ) turbo, tpl (
Turbo Pascal). , , . turbo.
tpc.exe. System, Crt, Printer Dos
Turbo.tpl, .tpu
. ,
.


Turbo Pascal, : , PChar, Turbo Vision
. , .

261

graph. tpu
( ) .bgi. .bgi,

(,
egavga.bgi EGA VGA). ,
- , . ch ( .bgi \TP\BGI).

.tpu , turbo.exe,
Options | Directories (. . 1.4) Turbo Pascal. .

PChar Strings . tpu.


Turbo Vision . tpu,
Objects.tpu, Drivers.tpu, Memory.tpu, HistList.tpu, Views.Tpu,
Menus.tpu, Dialogs.tpu, Validate.tpu MsgBox.tpu.
(. . 18) Editors, tpu
StdDlg.tpu.


. tph. -.
Help | Files Turbo Pascal.
turbo. tph , ,
turbo. .



, I II , , ,
, :
, Dialogs, Drivers, Editors, Memory, Menus, MsgBox, Objects,
StdDlg, Views Tv_l ( 18) Phone ( 22).
Graph.
15, : Graph_01, Graph_02, Graph_03, Graph_04.
20, : FreePen, Hunter, Piano.
, : FuncAbs, FuncAtan, FuncCos, FuncExp,
FuncGBkC, FuncGDrN, FuncGetC, FuncGetX, FuncGetY, FuncGGrM,
FuncGMdN, FuncGMxC, FuncGMxM, FuncGMxX, FuncGMxY, FuncGPix,
FuncGPSz, FuncG.rEM, FuncGrRs, FuncImgS, FuncInUF, FuncLn, FuncSin,
FuncTxtH, FuncTxtW, ProcArc, ProcBar, , ProcClsG, ProcClVP.,
ProcCrcl, ProcDetG, ProcDPol, ProcElps, Pro^FEll, ProcFFil, ProcFPol, ProcGDef, FuncGImg, ProcGtAC, ProcGtAR, ProcGtDP, ProcGtFP,
ProcGtFS, ProcGtLS, ProcGtMr, ProcGtPa, ProcGtVS, ProcIniG, ProcLine, ProcLnRl, ProcLnTo, ProcMvRl, ProcMvTo, ProcOTXY, ProcOutT,

262

. Turbo Pascal

ProcPieS, FuncPImg, ProcPPxl, PrpcRCRM, ProcRect, ProcSAlP,


ProcSect, ProcSetC, ProcSetP, ProcSRGB, ProcStAP, ProcStAR,
ProcStBC, ProcStFP, ProcStFS, FuncStGM, ProcStGS, ProcStLS,
ProcStTJ, ProcStTS, ProcStVP, ProcSDCS, ProcSVPg.
Strings , : FuncSCat, FuncSCmp, FuncSCpy, FuncSDsp, FuncSECp, FuncSEnd, FuncSICm, FuncSLCm, FuncSLCp,
FuncSLCt, FuncSLen, FuncSLIC, FuncSLow, FuncSMov, FuncSNew, FuncSPas,
FuncSPCp, FuncSPos, FuncSRSc, FuncSScn, FuncSUpp.

Turbo Pascal 3.5"


:
Turbo.exe;
Turbo, tpl;
Graph.tpu;
Egavga.bgi,
1 . , ,
Turbo Pascal, .


Turbo Pascal
Turbo
Pascal,
.
. , <Alt>, , . ,
- , <Alt>,
, .

Open. . .
Save
Save as. . .
Save all

F3
FZ

Change dir. . .
Print
Printer setup.
DOS shell
Exit
Alt +X
. .1. File

Undo
Redo

filt+BkSp

Cut
Shift Del
Copg
Ctrl* Ins
Paste Shift+Ins
Clear
Ctrl+Del
Show clipboard
. .2. Edit

Find...
Replace. . .
Search again
Go to line number. . .
Show last compiler error
Find error
Find procedure. . .
. .. Search

.1. File (. .1)

New

Open
<F3>

Save
<F2>

Save as

Save all

Change dir
. , Turbo Pascal
Print
.

Printer setup

DOS shell
MS-DOS.
Turbo Pascal MS-DOS exit
Exit
<Alt+X>
Turbo Pascal

264

. Turbo Pascal

.2. Edit (. .2)

Undo
<Alt+Bksp>
,

Redo
,
Undo
Cut
<Shift+Del>

.


Copy

<Ctrl+

Insert>
Paste
<Shift+

Insert>

Clear
Show clipboard

<Ctrl+Del>

.. Search (. .)

Find
<Ctrl+Q+F>
,

Replace
<Ctrl+Q+A>
,
,

Search again
<Ctrl+L>

Find Replace
Go to

line number
Show last

compiler error
Find error
<Alt+F8>
.

""
Find procedure

Run
Ctrl+F9
Step over
F8
Trace into
F7
Go to cursor
F4
Program reset Ctrl+FZ
Parameters. . .
. .4. Run

Compile
Hake
Build

Hlt+F9
F9

Destination Memory
Primary file. . .
Clear primary file
Information. . .
. .5. Compile

Breakpoints
Call stack
Register
Match
Output
User screen

Ctrl+F3

Hlt+F5

Eva luate/nod i f . . . Ctr 1 +F4


Hdd watch. ..
Ctrl+F7
Add breakpoint. . .
. .6. Debug

Run

265

.4. Run (. .4)

Run
<Ctrl+F9>

Step over
<F8>

Trace into
<F7>

Go to cursor
<F4>

Program reset
<Ctrl+F2>

Parameters

,
.:--.
MS-DOS
.5. Compile (. .5)

Compile
<Alt+F9>

Make
<F9>

Build

Destination

( )
Primary file

Clear

primary file

Information

Messages
Go to next
Hlt+F8
Go to previous fllt*F7
Shift+FZ
Grep
Turbo Assembler Shift+F3
Turbo Debugger Shift+F4
Turbo Profiler Shift*F5
. .7. Tools

Compiler. . .
Henorg sizes. . .
Linker...
Debugger. . .
Directories.
Tools. . .
Environment

Open. . .
Save TURBO. TP
Save as. . .
. .8. Options

Tile
Cascade
Close all
Refresh display
Size/Howe Ctrl+F5
Zoom
F5
Next
F6
Previous Shift+F6
Close
Hlt+F3
List...

flit +B

. .9. Window

.6. Debug (. .6)

(. . 13.4)
Breakpoints

Call stack
<Ctrl+F3>

266

. Turbo Pascal

.6

Register
Watch

Output
User screen

<Alt+F5>

Evaluate/modify
Add watch

<Ctrl+F4>

Add breakpoint

<Ctrl+F8>

<Ctrl+F7>


,

Turbo Pascal

Watch

.7. Tools (. .7)

Messages

,
DOS (
GREP). <SpaceBar> ()

Go to next

<Alt+F8>

Go to previous

<Alt+F7>

Grep

<Shift+F2>


, ,
Turbo Pascal
'
, ,
Turbo Pascal
,

.8. Options (. .8) Turbo Pascal

Compiler
Memory sizes

Linker

.- .

Debugger
Directories

(. 13.1)
.
.
(-)
.
(Memory), ,

(. . 1.4)

Options
.8

Tools
Environment

Open
-

Save

Save as

267

,
, Tools
Turbo
Pascal: , , , ,
(. . 1.5)
,
Turbo Pascal,
Options | Save
Turbo Pascal .
. tp
.

.9. Window (. .9)

Tile
,

Cascade

Close all

Refresh display
,

Size/Move
<Ctrl+F5>

Zoom
<F5>

Next
<F6>

Previous
<Shift+F6>

Close
<Alt+F3>

List
<Alt+0>

<Alt+N>
(N)
.10. Help (. .10)

Contents

Index
<Shift+Fl>

Topic search
. -
<Ctrl+Fl>

t Pascal,

268

. Turbo Pascal

.10

Previous topic
<Alt+Fl>
Using help
Files
Compiler
directives
Reserved words
Standard units
Turbo Pascal
Language
Error messages
About



,



Turbo Pascal

Turbo
Pascal

Contents
Index
Shift+Fl
Topic search
Ctrl+Fl
Previous topic
fllt+Fl
Using help
Files..
Compiler directives
Procedures and functions
Reserved words
Standard units
Turbo Pascal Language
Error messages
Hbout...

. .10. Help


,
ReadKey. , ASCII (. ). : #0 , . . . .1.
.1.

16
17
18
19
20
21
22
23
24
25
30
31
32
33
34
35
36
37
38
39
44
45
46
47
48
49

<Alt+Q>
<Alt+W>
<Alt+E>
<Alt+R>
<Alt+T>
<Alt+Y>
<Alt+U>
<Alt+I>
<Alt+0>
<Alt+P>
<Alt+A>
<Alt+S>
<Alt+D>
<Alt+F>
<Alt+G>
<Alt+H>
<Alt+I>
<Alt+J>
<Alt+K>
<Alt+L>
<Alt+Z>
<Alt+X>
<Alt+C>
<Alt+V>
<Alt+B>
<Alt+N>

50
59
60
61
62
63
64
65
66
67
68
71
72
73
75
77
79
80
81
82
83
84
85
86
87
88

<Alt+M>
<F1>
<F2>
<F3>
<F4>
<F5>
<F6>
<F7>
<F8>
<F9>
<F10>
<Home>

<t>
<PageUp>

->
<-
<End>

<4->
<PageDown>
<Insert>
<Delete>
<Shift+Fl>
<Shift+F2>
<Shift+F3>
<Shift+F4>
<Shift+F5>

270

.1

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

<Shift+F6>

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

<Cltr+<->

106
107
108
109
110
111

112
113
114

<Shift+F7>
<Shift+F8>
<Shift+F9>
<Shift+F10>
<Ctrl+Fl>
<Ctrl+F2>
<Ctrl+F3>
<Ctrl+F4>
<Ctrl+F5>
<Ctrl+F6>
<Ctrl+F7>
<Ctrl+F8>
<Ctrl+F9>
<Ctrl+F10>
<Alt+Fl>
<Alt+F2>
<Alt+F3>
<Alt+F4>
<Alt+F5>
<Alt+F6>
<Alt+F7>
<Alt+F8>
<Alt+F9>
<Alt+F10>
<Ctrl+PrtScr>

<Ctrl+->
<Ctrl+End> '
<Ctrl+PageUp>
<Ctrl+Home>
<Alt+l>
<Alt+2>
<Alt+3>
<Alt+4>
<Alt+5>
<Alt+6>
<Alt+7>
<Alt+8>
<Alt+9>
<Alt+0>
<ftlt4 >
<Alt+=>
<Ctrl+PageDown>
<F11>
<F12>
<Shift+Fli>
<Shift+Fl2>
<Ctrl+Fll>
<Ctrl+F12>
<Alt+Fll>
<Alt+F12>

, , -
. . .2.
.2.

16-
10-

<Escape>

01

<!>, <1>

02

<@>, <2>

03

<#>, <>

04

< >, <>


<&>, <7>
<*>, <8>
<(>, <9>

<$>, <4>
<%>, <5>

05

<)>,

06

< >,

16-

07

08

09

10-

10

<0>

11

<->

12

271

.2

<+>, <=>
<BackSpace>
<Tab>
<Q>
<W>
<>
<R>
<>
<Y>
<U>
<I>

<o>
<p>

<{>, <[>
<}>, <]>
<Enter>
<Ctrl>
<A>
<S>
<D>
-<F>
<G>
<H>
<J>
<K>
<L>

<:>, <;>
<">, <>
<~>, < - >
<Shif t> ()
<|>, <\>

<z>
<x>

<c>

<v>
<B>
<N>


16- 10-

OD
13

OF
10
11
12

13 .
14
15
16
17
18
19
1
1
1C
1D
IE
1F
20
21
22
23
24
25
26
27
28
29
2
2
2
2D
2
2F
30
31

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

<>
>, <,>
<, <.>
<?>,, </>
<Shift> ()
<PrintScreen>
<Alt>
<Space>
<Caps Lock>
<F1>
<F2>
<F3>
<F4>
<F5>
<F6>
<F7>
<F8>
<F9>
<F10>
<Num Lock>
<Scroll Lock>
<Home>

<t>
<PageUp>
< >
->
<5>
<-
<+>
<End>
<-l>>
<PageUp>
<Insert>
<Delete>
<F11>
<F12>


816- 10-

32
50
33
34
35
36
37
38
39

3D

3F
40
41
42
43
44
45
46
47
48

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

49
4
4

73
74
75

4
4D
4
4F
50

76
77
78
79
80

51
52
53
D9
DA

81
82
83
217
218

BIOS MS-DOS
BIOS MS-DOS, Turbo Pascal. , , (
, , ),
.

BIOS
$05
: .
: .
$09
<PrintScreen>. , .

$10
, .
. .

$00

= 0
AL (. .1).
: .

. .
.1. , $00 $10

AL

0
1
2
3
4

40x25
40x25
80x25
80x25
320x200

8x8, 8x14
8x8, 8x14
8x8, 8x14
8x8, 8x14
8x8

16/8

16

16/8
16
4

'\

CGA, EGA
CGA, EGA
CGA, EGA
CGA, EGA
CGA, EGA

$10 -

273

.2

AL

320x200
640x200
80x25
320x200
640x200
640x350
640x350
640x480
640x480
640x480

8x8

4*

8x8

2
3
16

4 16

CGA, EGA
CGA, EGA
MDA, EGA
EGA, VGA
EGA, VGA
EGA, VGA
EGA, VGA

2
16

VGA
VGA

256

VGA

6
7
$00
$
$OF
$10
$11
$12
$13

9x14
8x8
8x8

8x14
8x14
8x16
8x16
8x16

16
3

* .
i

'

$01

= 1
.
CL .

: .

} '

0 (
) $1F ( ). = $20, .
0 $ 1F.
( ),
" :
VGA (25 ) 16
;
EGA (25 ) 14 ;
CGA (25 );
EGA (43 );
VGA (50 ) 8 .

$02

= 2
( 0).
DH ( 0).
DL ( 0).

: .
$03

= 3
( 0).

274

BIOS


.
CL .
DH ( 0).
DL ( 0).

$05

= 5
AL ( 0).
: .
CGA, EGA VGA 8 , MDA .

$06
$07

= 6 (7)
AL .
.
( 15)
.
, CL .
DH, DL .
: .

$08


= 8
( 0).

AL ASCII ( ASCII . ).
( 15).

$09


= 9
AL ASCII (>> ASCII . ). , 127, , $1F.
( 0).
BL ;
(<< 15).

$10 -

275

( 1).
: .
.

$


= $
AL ASCII ( ASCII . ). , 127, , $1F.
( 0).
( 1).
: .

$


= $
BL 0 $OF (
) $10 $1F ( ).
0 ( green/red/brown) 1 ( cyan/magenta/white).
: .

$

= $
AL ( 15). $80
XOR .
( 0).
( 1).
DX ( 1).
: .

$00

= $OD
( 0).
( 1).
DX ( 1).
: AL ( 15).

$

= $
AL ASCII ( ASCII . ).
BL (4< 15).
: AL ( 15).

276

BIOS

, AL,
.
, .

$OF
: = $OF.

AL (. . .1).
.
( 0).

$11 (EGA/VGA)
15 , AL.
$00 ,

= $11
AL = 0
.
BL ( EGA 0 3, VGA 0 7).
.
DX ASCII , ES:BP
( ASCII . ).
ES:BP , .
: .
$01 8x14
$02 8x8

= $11
1 = 1 (2)
BL ( EGA 0 3, VGA 0 7).
: .

$03

= $11
1 = 3
BL ( EGA 0 3, VGA 0 7).
: .
$04
8x16 (VGA)

= $11
AL = 4
BL ( 0 7).
: .

$10 -

277

$10
,

= $11
AL = $10
.
BL ( EGA 0 3, VGA 0 7).
.
DX ASCII , ES:BP
( ASCII . ).
ES:BP , .
: .
$11
8x14
$12
8x8

= $11
AL = $11 ($12)
BL ( EGA 0 3, VGA 0 7).
: .

~*

$14
8x16 (VGA)

= $11
AL = $14
BL ( 0 7).

' \

: .
$20 $1F

= $11
AL = $20
ES:BP , ,
8x8 ASCII, 127.
: .

'

$21 ,
,

= $11
AL = $21
BL :
0 ( DL);
1 14 ;
2 25 ;
3 43 .
, .

278

BIOS

DL ( ) BL = 0.
ES:BP , ,
.
/
' . . " .
: .
$22
8x14
$23
8x8
$24
8x16

= $11
AL = $22 ($23, $24)
BL :
0 ( DL);
1 14 ;
2 25 ;
3 43 .
DL ( ) BL = 0.
: .
$30


= $11
AL = $30
:
0 $1F;
1 $43;
2 8x14;
3 8x8;
4 8x8 ( );
5 8x14;
6 8x16 ( VGA);
7 8x16 ( VGA).

( , 1 ).
DL .
ES:BP .

$12 EGA/VGA
EGA VGA,
CGA MDA. , BL. .
$10 EGA

= $12
BL=$10

$10 -

279


BIOS (0 ; 1 ).
BL (0 64 ; 1 128 ; 2 192 ; 3
256 ). BL > 3, BIOS CGA MDA.
( RCA).
CL .
$30


= $12
AL :
0 200 (EGA/VGA);
1 350 (EGA/VGA);
2 400 ( VGA).
BL=$30

VGA,
$12.
$36 /

= $12
AL : 0 ; 1 .
BL = $36

AL , $12.
,
. .

$13 (AT/EGA/VGA)
.
$00
$01

= $13
AL = (1)
( 0).
BL ( 15).
.
DH, DL .
ES:BP , .
: .
$02

280

BIOS

$03


= $13
AL - 2 (3)
( 0).
.
DH, DL .
ES:BP , .
: .

. , .
, "!". . (, s) , :
| s := ' ' + # 7 + ' ' + # 7 + ' ' + 7 + ' ' + 7 + ' ' + # 7 + ' ' + # 7 + ' 1 ' + # 1 5 ;


| LEA , S+1
s .
. ( $07), "!"
( $OF = 15).

$11

: .

.
, . .2.
.2. $11

0
1
2,3
4,5
1

6,7
8

"1",

",
, :
0116 ; 10 32 ; 1 1 64
:
00 ; 01 40x25; 10
80x25; 11 - 80x25
: 00 1 ; 01 2; 10 3; 11 4
"1",

$12 -

281

.2

9-11
12
13

14,15

RS-232:
000 0;0011;... 100 4;... 111 7
", .
"1",
, , : 00 0; 01 1 ; 1 0 2; 1 1 3

$12
: .
: .

$13 /
, . .

$00
: = 0.
: BIOS.

. , . /,
. . . .4.
.. /,

$00
$01





,



64


(CRC)


$01
$02
$03
$04
$06
$08
$09
$
$10
$20
$40
$80

282

BIOS

.4. /,

$00
$01
$02
$03
$04
$05
$06
$07
$08




,
/



(DMA- direct
memory access),
(DMA-)
/ 64





CRC,
,








$09
$
$
$00
$
$OF
$10
$11
$20
$40
$80
$
$
$
$
$FF

(Error Correction Code)


, , . : , , ,
. , .
CRC (Cyclic Redundancy Check)
. ,
. -. , , . ,
, .

$13 /

283


, () .

$01

= 1
DL $00 $03 ; $80 $81
.
: BIOS (. . . . .4).

$02

= 2
AL .
(), 0.
CL , 1.
DL : 03 ; $80 $81 .
DH .
ES:BX .

CF , BIOS (. . .
. .4). = 0, , ES:BX,
.

, 8- ,
6 ( CL) 10 ( +
CL). , 1024, 64.

$03

= 3
AL .
(), 0.
CL , 1.
DL : 0-3 ; $80 $81 .
DH .
ES:BX .

CF , BIOS (. . .
. .4).

$04

= 4
AL .
(), 0.

284

BIOS

CL , 1.
DL : 03 ; $80 $81 .
DH .

CF , BIOS (. . .
. .4).
'.

$05

= 5
AL .
() 10 ( .
$02).
DL : 03 ; $80 $81 .
DH .
ES:BX , .

CF , BIOS (. . .
. .4).
ES:BX. . PC 4 (. .5).
.5. PC

0
1

( 0)
( 0)
( 1 )
:
0 128 ; 1 125 ; 2 512 ; 3 1 024

2
3

AT, BIOS 2- (. .6).


.6. AT

: $00 ; $80
( 0)

XT ,
ES:BX, AL,
1 16.

$08

= 8
DL : 0-3 ; $80 $81 .

$13 - /

285


CF , BIOS (. . .
. .4).
( 6
CL, + CL).
DL .
DH .
ES:DI .
16- ,
. .7.
.7. PC

0
2

2
1

2
3

5
2
()
1
7

1
8
:
0-2 ;
6 ;
7
1
9

1

10
1
11

4

12

$

= $
AL ( 1).
(), 0.
CL , 1.
DL : $80 $81 .
DH .
ES:BX .

CF , BIOS (. . .
. .4). = 0, , ES:BX,
.
$02 ,
,
.
. $00 $13.

286

BIOS

$

= $
AL ( 1).
(), 0.
CL , 1.
DL : $80 $81 .
DH .
ES:BX .

CF , BIOS (. . .
. .4).
$03 ,
, (
); ES:BX.

$

= $
,
() 10 ( .
$02 $13).
DL : $80 $81 .
DH .

CF , BIOS (. . .,
. .4).

$OD

AH = $OD
DL : $80 $81 .

CF , BIOS (. . .
. .4).

$10

= $10

DL : $80 $81 .

CF , BIOS (. . .
. .4).

$11

= $11
DL : $80 $81 .

$13 /

287


CF , BIOS (. . .
. .4).

$14
: = $14

CF , BIOS (. . .
. .4).
\

N '

$15


= $15
DL : 0 3 ; $80 $81 .

CF , BIOS (. . .
. .4). CF , : 0 ; 1 (
); 2 (
); 3 .

$16

= $16
DL 0 3.

CF , BIOS (. . .
. .4). CF , : 0 ; 1 ; 2 ; $80
.

$17

= $17
AL :
1 360 360 ;
2 , 360 1.2 ;
3 1.2 1.2 ;
4 720 720 .
DL 0 3.

CF , BIOS (. . .
. .4).

, 1.44
2.88 . $18 ( ).

288

BIOS

$18

= $18
.
CL .
DL 0 3.

CF , BIOS (. . .
. .4).

$14 /

,
RS-232. .

$00

= 0
AL .
DX - ( 0 3).

.
AL .
AL . . . 8.
.8. -

0,1
2
3,4
5-7

: 10 7 ; 11
: 0 1,1 2
: 00,10 ; 01 ; 11
: 000 110; 001 150; 010 300; 011 600; 100
1200; 101 2400; 1 10 4800; 1 1 1 9600
BIOS , 9600 /

, AL . . .9 . 10.
.9.


0
1

2


3
4

5

6

( 7
)

$16 -

289

. 10.

0
1
2
3
4
5
6
7

$01
V


AH = 1
AL .
DX - ( 0 3).


(. . .9). "",
,
.

$02

= 2
DX - ( 0 3).

.
. ,
I

. 0, , (.
. .9).
AL .

$03

= 3
DX - ( 0 3).

(. . .9).
AL (. . . 10).
/

$16

>

, . .

$00
: = 0

(. ).

290

BIOS

AL ASCII (. ) (.
).

$01
: = I

ZF "",
.
(. ), ZF = 0.
AL ASCII (. ) (. ), ZF = 0.
,
.

$02
: = 2

AL (. . 11).
.11.

", <Shift> -
"1", <Shit> -
",
<Ctrl+Shift>
"1",
<Alt+Shift>

1
2
3
4

<Scroll Lock>

<Num Lock>

<Caps Lock>

<Insert>

$03
,

= 3
AL = 5
(0 250 ; 1 500 ; 2 750 ; 3 1 ).
BL (0 30 ; 1 26,7
; 2 24 ; $1F 2 ).
: .

$17 -

291

$05


= 5
, (. ).
CL ASCII (. ) (. ).

AL 0 ; 1
.

$17

( ).

$00

= 0
AL ASCII (. ).

(. . 12).

.12.

0
3
4
5
6
7

"1", ,
"1", ,
/
"1", ,
", ,

', ,
'1", ,

$01

= 1
DX - (0 - LPT1; 1 - LPT2; 2 - LPT3).

(. . .12).

$02

= 1
DX - (0 - LPT1; 1 - LPT2; 2 - LPT3).

(. . .12).

292

MS-DOS

$1

$1 . , , BIOS , "". ,
18 , 1092 , 65543 , 1573040 .
. , - . , .

$00
: =

AL 0, 24 .
, DX ( , DX ).

$01

= 1
, DX .

CF 0, ; 1
.

MS-DOS
$21 MS-DOS
$00

= 0
CS (PSP Program Segment Prefix)
.
: .
""
PSP.

$01
: = 1

AL ASCII (. ) , (). (.
) .

$21 - MS-DOS

293

$02

= 2
DL
_ ASCII (. ).
: .
$03
(1 AUX)
: = 3

AL ASCII (. ).
$04
(1 AUX)

= 4
DL ASCII (. ).
: .
$05 ( LPT1)

= 5
DL ASCII (. ).
: .

'

$06 /

= 6
DL 0 SOFE ASCII (. ) ,
(); SOFF .
( DL = SOFF).
ZF 0, .
AL ASCII (. ) , ZF = 0.
$07
<Ctrl+Break>
: = 7

AL ASCII , (.
).
$08
<Ctrl+Break>
: = 8

AL ASCII , (.
).

294

MS-DOS

$09

= 9
DS:DX , "$".

: .

$

= $
DS:DX , .
(#13).
.
DS:DX , , (#13).
. , 254 .

$

' : = $

AL $OFF, ; 0,
.

$


= $
AL - $21, ($01, $06, $07, $08 $).
: .

$OD
: = $OD
: .
,
.
,

$

= $
DL , (0 ; 1 ..).
: AL .

$21 - MS-DOS

295

, , ( $24).

$OF FCB
FCB File Control Block ( ).
, 37 , , .
FCB . . 13.
.13. FCB

1'

12 ($)
14 ($)
16 ($10)
20 ($14)

2
2
4
2

22 ($16)
32 ($20)
33 ($21)

8
1
4

.
:
0 ; 1 ; 2 ..
: 0 ; 1 ..
,

,



/ : 0-4 ;
5-8 ; 9-15 ,
1980

( 0 127)

( )


= $OF
DS:DX FCB.

AL 0, ( FCB ); SOFF
.
, FCB, , FCB.
FCB 0, 128.

$10 FCB

= $10
DS:DX FCB.

AL 0, ; $OFF .

296

MS-DOS

$11 FCB

= $11
DS:DX FCB ( "?").

AL 0, ; $OFF .

$12 FCB

= $12
- DS:DX FCB ( "?").

AL 0, ; $OFF .

$13 FCB

= $13
DS:DX FCB ( "?").

AL 0, ; $OFF
, , .

$14 FCB

= $14
DS:DX FCB.

AL 0, ; 1,
; 2, FCB
(DTA Data Transfer Array) ( ); 3, ( ).
, FCB,
,
DTA. .

$15 FCB

= $15
DS:DX FCB.

AL 0, ; 1, ; 2, FCB
(DTA) ( ).

$21 - MS-DOS

297

, FCB,
,
DTA. .

$16 FCB

. - , *N


= $16
DS:DX FCB.

AL 0, ( FCB ); $OFF .

$17 FCB

= $17
DS:DX FCB, .

AL 0, ; $OFF (
, ..).

FCB, $11 (18- ).

$19 ,
MS-DOS
: = $19

AL , MS-DOS (0 - , 1 ..).

FCB, $11 (18- ).

$1 (DTA)

= $1
DS:DX (DTA),
,
$11, $12, $4 $4F.
: .

$1
: = $1

DS:BX (FAT File Allocation Table).
'
DX .
AL .
.

298

MS-DOS

DX * AL * .

$1

= $1
DL (0 ; 1 , ..).

DS:BX (FAT).
DX .
AL .
.

$1F
: = $1F

AL 0, , $OFF.
DS:BX .
. . 14.
.14.

1
0
: 0 ; 1 ..
1
1

2
2

1
(
4
)
1
"-" (,
5
2, )
2
FAT
6
1
8
FAT
9
2
,
11 ($)
2
( )
13 ($00)
2
(
)
15($OF)
1
, FAT
16 ($10)
2

18 ($12)
4

1
22 ($16)
. :
$FO 3,5" (1 ,44 ), 2 , 1 8 ;
3,5" (2,88 ), 2 , 36 ;
$F8 ;
$F9 3,5" (720 ); 2 , 9 ;
$FB 3,5" (640 ); 2 ; 8

$21 - MS-DOS

299

.14

23 ($17)

24 ($18)
28 ($1 )
30($1)

4
2
2

$00 ,
.
$FF


$21 FCB

= $21
DS:DX FCB.

AL 0, ( DTA ); 1, ; 2, FCB (DTA)
( ); 3,
(
).
, FCB, , FCB.

$22 FCB

= $22
DS:DX FCB.

AL 0, ; 1, ; 2, FCB (DTA) ( ).
, FCB, , FCB.

$23 FCB

= $23
DS:DX FCB.

AL 0, ; $OFF .
FCB
, . FCB.

$24 FCB


= $24

300

MS-DOS

DS:DX FCB.
: .
FCB , .

$27

= $27
.
DS:DX FCB.

AL 0, ( DTA ); 1, ; 2,
(DTA) FCB,
, ( ); 3, ( ).
.
, FCB,
, , FCB.

$28

= $28
.
DS:DX FCB.

AL 0, ; 1, ; 2, (DTA) FCB, ,
( ).
, FCB,
, , FCB.

$29
FCB

= $29
AL , . . , "1":
0 ; 1
, FCB; 2 , FCB; 3 ,
FCB.
DS:SI .
ES:DI , FCB..

$21 - MS-DOS

301


AL 0, FCB ; 1,
FCB ; $OFF , , .
DS:DI , .
ES:DI FCB.
, .
: "DrFileName.ext".

$2
: = $2

AL (0 , 1 ..).
- ( 1980 2099).
DH .
DL .
- '

$2

= $2
- ( 1980 2099).
DH .
DL .

AL 0, ; SOFF.

$2
: = $2

( 0 23).
CL ( 0 59).
DH ( 0 59).
DL ( 0 99).

$2D

= $2D
( 0 23).
CL ( 0 59).
DH ( 0 59).
DL ( 0 99).

AL 0, ; SOFF.

$2 /
: = $2
: .

,/

302

MS-DOS


, MS-DOS CRC (44 .
, $00 $13). , .

$2F DTA
: = $2F
: ES:BX DTA.

$30 MS-DOS
: = $30

AL .
.

$31 ,


= $31
AL , $4F.
DX , ( 16 ).
\
: .

$32

= $32
DL (0 ; 1 ; 2 ..).

AL 0, DL ; $OFF.
DS:BX (. . . 14).

$36

= $36
DL (0 ; 1 ; 2 ..).

, DL
, $FFFF.
.
( 512).
DX .
, ,
* * , * * DX.

$21 - MS-DOS

303

$39

= $39
DS:DX , #0.

: , CF "1".

$

= $
DS:DX , #0.
: , CF "1".

$ MS-DOS

= $
DS:DX . , #0.
: , CF "1".


= $
DS:DX , #0.
. "1"
: 0 ; 1 ; 2 ; 3 ; 4 ; 5. .

, CF "1", .

16- , /,
.

$3D

= $30
AL (0 ; 1 ; 2 /).
DS:DX , #0.

, CF "1", .

$

= $
.
: , CF "1".

304

MS-DOS

$3F

AH = $3F
.
.
DS:DX .

, CF "1", .
/ . '\

$40

.
= $40
.
(0 , ).
DS:DX , .
.

, CF "1", .

$41

= $41
DS:DX , #0,
.

: , CF "1".

$42


= $42
AL : 0 CX:DX; 1
CX:DX; 2
CX:DX.
.
CX.-DX (*65536 + DX).

, CF "1".
DX^X .

$43
: , .
$00

= $43

$21 - MS-DOS

305

AL = 0
DS:DX , #0,
.

, CF "1".
( ).
, $ $21.
$01

= $43
AL = 1
, ( , $ $21).
DS:DX , #0,
.
: , CF "1".

$47 ,

= $47
DL (0 ; 1 , ..).
DS:SI (64 ).
: , CF "1".

$4 /

, AL.

$00

= $4
AL-0
DS:DX , #0,
.
ES:BX , .
. . 15.
.15. ,

'


0
2
,
4
2
(PSP) $0080
FCB, 4
6
$005 (
)
FCB, 4
10($)
$006 ( )
: , CF "1".

306

MS-DOS

$01

= $4
AL- 1
DS:DX , #0,
.
ES:BX , .
. . 16.
.16. ,

0
2

2
4

10 ($)

14 ($)
18 ($12)

4
4

.
,
(PSP) $0080
FCB, $005 ( )
FCB, $006 ( )
,
,


, CF "1".
ES:BX , .
i
$05

= $4
AL-5

DS:DX ,
MS-DOS. .
. 17.
.17. ,
MS-DOS

0
2
2
0 ; 1
2
4
, #0,

2
6
(PSP)
2
8
32-
12($)
2
32- ,
: .

$21 - MS-DOS

307

$4

= $4

AL .
: .

$4D
: = $4D

AL .
:
0 ;
1 <Ctrl+Break>;
2 ;
3 $31 $21.

$4
'
= $4
, (<
, $ $21).
DS:DX , #0, ( ).
: , CF "1".
, DTA : 021 ; 22 ; 22, 23 / ; 24,25 / ; 2629 ; 30-42
.

$4F

= $4F
DS:DX , $4.
: , CF "1".
, DTA (. , $4).

$54
: = $54

AL CRC (< .
, $00 $13): 0 ; 1 " .

308

MS-DOS

$56 /

= $56
DS:DX , ' #0,
1.
ES:DI , #0, .
: , CF "1".

$57
/
: , .

$00

= $57
AL = 0
( . ,
$ $21).


, CF "1".
( 0-4 , 2
; 510 ; 1115 ).
DX ( 04 ; 5-8 ; 9-15
, 1980 ).

$01

= $57
AL= 1
.
( 0-4 ; 510
; 1115 ).
DX ( 04 ; 58 ; 915
, 1980 ).

: , CF "1".

$62
: = $62

(PSP Program Segment Prefix) .

$33
,
AL. .

$00
: AL = $00

$33 -

309


$0000 ; SFFFF .
.

$01
: AL = $01
: .

$02
: AL = $02
I

: .
i

$03

: AL = $03


. 0 "1"
; 1 "1" ; 2
"1" .
.
DX ,

$04

AL=$04
.
DX .
: .

$05

AL=$05
(0 ; 1 ; 2 ).

. 0 "1"
; 1 "1" ; 2
"1" .

.

.
DX
.

$06

AL = $06
(0 ; 1 ; 2 ).

310

MS-DOS


. 0 "1"
; 1 "1" ;
2 "1" .

.
, .
DX ,
.

$07


AL = $07
( ).
DX ( ).
: .

$08


AL = $08
( ).
DX ( ).
: .

$09

AL = $09
""
.
""
.
ES:DX 64 ,
.
: .

$10
,
: AL = $10


( ).
DX .
- "", 1/200
.

$33 -

311

$

AL = $
, : 0 ;
1 ; 2 ; 3
; 4 ; 5 ; 6
. ,
$007F.
ES:DX .
: .

$OF

AL = $OF
, "" 8
(1 = 1/200 ).
DX , "" 8
(1 = 1/200 ).
: .

$1F
: AL = $1F

: $00IF ; SFFFF
.

$20
: AL = $20
: .
.

$21
: AL = $21

: $0021 ; $FFFF
.
.

$24

: AL = $24

.
BL .
: 1 ; 2
; 3 ; 4 PS/2; 5 HP.
CL .


8x86
, ,
.

ASCII-
AL ( ADD) ASCII. () AL 9
AF 1, : 1 , 6 AL AF CF,
1. AL,
0.
:

AAD ASCII-

ASCII- . AAD ( ASCII-).


. 10, AL (=0).
: AAD

ASCII-
AL. AL
10, , AL.
:

AAS ASCII-

ASCII- AL.
() 9 CF 1, AAS 6 AL 1 AF CF 1.
() AL ( 0).
: AAS
-

ADC

. CF 1,
ADC 1 .

ADD -

313

ADC 1 . 2
1, ADD.
: ADC /, //

ADD
,
,
.
: ADC /, //

AND ""
( "")
. , ,
. . AND . 1, , .
: ADC /, //

CALL
( near) ( far) . RETN , NEAR RETF FAR.
NEAR CALL
SP 2 ( IP),
IP . RETN .
FAR CALL
, SP, CS, CS , , IP, IP
.
: CALL /

CBW
AL .
CBW (7) AL .
: CBW

CLC CF
(CF=0). , ,
ADC .
: CLC

CLD DF
(DF=0).
, CMPS MOVS, .

314

. 8x86

: CLD

CMC CF
CF, CF
.
: CMC


.
, ,
. AF, CF, OF, PF, SF ZF.
: .
, ; .
: /, //

CMPS (CMPSB/CMPSW/CMPSD) -
( // )
. CMPSB
, CMPSW , CMPSD
( 80386 ). DS:SI, ES:DI.
REPn, . REPNE
, REPE .
, .
DF 0, ,
SI DI : 1 , 2
4 . DF 1,
, SI DI
, .
: [REPn] CMPS/CMPSB/CMPSW

CWD

DX:AX, (15 ) DX. 32- .
: CWD

DEC
1 , . INC.
: DEC /

DIV-

315

DIV
. () , ,
.
\
8- , 8- , DIV BH.
AL, .
16- DX:AX, a
16- , DIV CX.
, DX.
32-
EDX-.EAX, 32- , DIV . , EDX.
: D1V /

ESC
.
8087 80287. ESC
.
: ESC , /'

HLT
, . HLT CS:IP
. CS
IP . IRET CS IP , HLT. , , STI
IF 1.
: HLT

ID1V ()
()
() . ()
.
8- , 8- , DIV BH.
AL, .
16- DX:AX, a
16- , DIV CX.
, DX.
32- EDX:EAX,
32- , DIV .
,
: IDIV /

316

. 8x86

IMUL ()
() . () .
8- AL, , IMUL BL.
.
16- , , IMUL BX.
DX:AX.
32- EDX:EAX, , ,
DIV . EDX:EAX.
: IMUL /
80286 ( ) ( 1), ( 2).
, . ,
IMUL BX, 16.
:
( 2 ),
( 3), , 1. , IMUL BX, CX, 50.
: IMUL ,
IMUL , /,
80386 ( )
( 1), ( 2). , IMUL EBX, EDX.
: IMUL , /

IN
AL, ( ) , .
, DX.
256, DX. , 80186, 80286
80386 INS (Input String ).
: IN AL/AX/EAX, /DX

INC
1 , INC CX.
: INC /
.

INT
256 .
: INC

INTO 317

INTO
( OF
1) IRET 04H. ( ) .
: INTO

IRET
FAR ( ): IP,
SP 2, CS, IP
2 .
: IRET

J-
()
, CS:IP. , , .
CS:IP , IP J-,
. , , , ,
, J-.
: J-
.'

JA/JNBE ""/" "


. ,
CF=0 ( ) ZF=0.

JAE/JNB/JNC
" "/" "/
. ,
CF=0 ( ).

JB/JNAE/JC
""/" "/
. ,
CF=1 ( ).

JBE/JNA " "/" "


. ,
CF=1 ( ) AF=1.

JE/JZ "/""
. JZ , . , ZF=1.

318

. 8x86

JG/JNLE ""/" "


. ,
ZF=0 SF OF (SF=OF).

JGE/JNL " "/" "


. ,
SF OF (SF=OF).
/

JL/JNGE ""/" "


. ,
SF OF (SF*OF).

JLE/JNG " "/" "


. ,
ZF=1 SF OF (SF*OF).

JNE/JNZ " " " "


. JNZ
, .
, ZF=0.

JNO ,
, .
, OF=0 ( ).

JNP/JPO , /
, .
, , 1, . , PF=0 ( ).

JNS ,
, .
, SF=0.

JO
, .
, OF=1 ().

JP/JPE , /
.
, , 1,
. , PF=1 ( ).

JCXZ - =0

319

JS
, .
, SF=1.

JCXZ =0
, .
JCXZ LOOP.
: JCXZ

JMP
.
IP, ,
, CS ( . "J- ").
: JMP

LAHF
. - '
8080. LAHF (8 ) : SZ*A*P*C, "*" .
: LAHF

LDS
. LDS
( ) ( 2),
( ) ( ),
( 1) DS .
: LDS ,
, DS, DI: LDS DI, .
1

LEA
()
( 1) () ( 2).
: LEA ,

LES


.
. LDS.

320

. 8x86

LOCK
. LOCK
,
. ,
, .
: LOCK

LCDS (LODSB/LODSW/LODSD) -
( // )
AL . , LODS ,
REP. DS:SI ( LODSB),
( LODSW), ( LODSD 80386
), AL, , .
DF=0, 1 ( ), 2 ( ) 4 (
) SI. DF=1, SI, , DF=0.
: LODS
LODS :
LODSB/LODSW/LODSD

LOOP
.
. LOOP , .
, ,
( IP );
LOOP (
).
: LOOP

LOOPE/LOOPZ -
, ""/""
,
ZF . LOOPE/LOOPZ
LOOP, , , ZF=0.
: LOOPE/LOOPZ
V

LOOPNE/LOOPNZ -
, " "/" "
,
ZF . LOOPNE/LOOPNZ
LOOP , , ZF=1.

MOV

321

: LOOPNE/LOOPNZ

MOV

, . 1. 1, 2
4 , ( ) . MOV (
MOVS).
: MOV /, //

MOVS (MOVSB/MOVSW/MOVSD) -
( // )
. MOVSB
, MOVSW , MOVSD
. DS:SI
( 2), ES:DI
( 1).
DF=0, SI DI : 1 , 2 , 4 .
DF=1, SI DI , , DF=0.
MOVS(B/W/D) REP,
.
=0, .
: [REP] MOVS/MOVSB/MOVSW/MOVSD

MUL
.
() , .
8- AL, , MUL CL.
.
16- , , MUL BX.
DX:AX.
32- ,
, MUL ECX. EAX:EDX.
: MUL /

NEG
,
, , 0 1. ,
.
: NEG /

322

. 8x86

NOP
. NOP XCHG ,,
.
: NOP

NOT ""
. ,
.
: NOT /

OR ""
( "") . , , .
,
, .
: OR /, //

OUT ,

AL,
.
, DX. 256,
DX. , 80186, 80286 80386 OUTS (Output String ).
: OUT /DX, AL/AX/EAX

POP

, , : , , . SP
( ) . POP ( ) SP 2 (4 ).
: POP /

POPA/POPAD

80286 ( ) ,
DI, SI, BP, SP, BX, DX, , SP 16, . PUSHA.
80386 (( ) POPAD, EDI, ESI, EBP, ESP, EBX,

POPF/POPFD

323

EDX, ,
ESP 32, .
PUSHAD.
: POPA/POPAD

POPF/POPFD
( ) . SP ( ) . POPF ( 80286 ) ( POPFD 80386 ) SP 2 (4 ).
PUSHF/PUSHFD , POPF/POPFD .
: POPF/POPFD

PUSH

( )
. SP " ( ) . PUSH SP 2
ESP 4 ( ) ( )
.' PUSH
, , ( ) 80286 .
: POP //

PUSHA/PUSHAD -

80286 ( ) PUSHA, , , DX, BX, SP, BP V SI, DI
SP 16. .
80386 ( ) PUSHAD, EDI, ESI, EBP, ESP, EBX,
EDX, ,
ESP 32.
PUSHAD.
: PUSHA/PUSHAD

PUSHF/PUSHFD

. SP (PUSHF)
(PUSHFD 80386 ) .
PUSHF SP 2, PUSHFD 4. .
: PUSHF/PUSHFD

324

. 8x86
/

RCL/RCR
/
() , ( 80386 ) CF. 80286 ( ) 1, ; ,
, CL, ( ). 80386 ( )
31 .
RCL, CF, CF
( ) ; .
RCR CF () ,
CF; .
: RCL/RCR /, CL/

REP/REPE/REPZ/REPNE/REPNZ
. CMPS, MOVS, SCAS, STOS, ZF.
.
1 . REP , .
REPE REPZ (: ) ,
ZF 1 ( ) .
REPNE REPNZ (: ) ,
ZF 0 ( ) .
: REP/REPE/REPZ/REPNE/REPNZ

RET/RETF/RETN
, CALL. NEAR, RETN, , FAR RETF.
NEAR RET
IP SP 2.
FAR RET IP CS
SP 4.
, , (,
RET 4) SP.
: RET/RETF/RETN [ ]

ROL/ROR /
() ,
( 80386 )
.
>

SAHF -

325

80286 ( )
1, ; , ,
CL, ( ).
80386 ( )
31 .
, ROL,
0 ( ) ,
. ROR 0
() , .
: ROL/ROR /, CL/

SAHF
8080
8 .
: SZ*A*P*C,
"*" .

SAL/SAR /
,
( 80386 ) .
80286 ( )
1, ; , ,
CL, ( ). 80386 ( )
31 .

SAL . SAR , :
, , (0 1). , ,
.
: SAL/SAR /, CL/

SBB ()
. CF=1,
SBB 1 1. SBB 2 1, SUB.
: SBB /, //

SCAS (SCASB/SCASW/SCASD) -
(, )
, , ES:DI. SCASB ,
AL. SCASW , . SCASD

326

. 8x86

, ( 80386 ).
DF=0,
DI 1 . DF=1,
DI 1 .
REPE REPNE.
,
. REPE/REPNE
1. , =0.
DI SI , /
. , REPE , ,
REPNE.
: [REPn] SCASB/SCASW/SCASD

SHL/SHR /
SHL SHR
.
SHL SAL (<< .
SAL/SAR).
SHR SAR, , , ,
( 1), .
: SHL/SHR /, CL/

STC CF
CF 1.
: STC

STD DF
DF 1. , ,
MOVS CMPS, .

STOS STOSB/STOSW/STOSD
//
, ( 80386 )
. STOSB AL, STOSW , STOSD . ES:DI ,
// . DF=0,
( ) DI
1. DF=1, (
) DI 1.

REP

// , , .
REP 1. ,
=0.
: [REP] STOSB/STOSW/STOSD

SUB -

327

SUB
, ,
; , .
: SUB /, //

TEST
,
" . ,
. . TEST AND,
"", : ZF (ZF=0), 1,
ZF (ZF=1).
: TEST /, //

WAIT
,
.
. ,
, , TEST.
: WAIT

XCHG
, , XCHG
, BL, , , XCHG CX, word.
: XCHG /, /

XLAT
, ,
ASCII- EBCDIC-.

32- . AL , XLAT. AL ,
AL.
: XLAT [AL]

XOR ""
"" . , ,
. XOR . , XOR 1 , , 1 .
: XOR /, //

ASCII
.1. () ASCII

$00

$01

$02

$03

$04

$05

$06

$07

$08

$09

10

11

12
13

$
$00

14

15

$OF

16

$10

17,

$11

18
19

$12

20

$14

21

$15

22

$16
$17

*
*

23
24

$13

$18

25

$19

26
27

$1

9
f

28
29

$1
$10

30

$1

31

$1F

$1

1
2
3
4

<Escape>

fe

4
I

i;

i
'

->
<L
-

.2. ASCII

32
33
34
35
36
37
38
39
40

$20
$21
$22
$23
$24
$25
$26
$27
$28

!
"

&
1

41
42
43
44
45
46
47
48
49

$29
$2
$2
$2
$20
$2
$2F
$30
$31

)
*
+
,
/

$32
50
51
$33
$34
52
53
$35
54
$36
$37
55
56
$38
57 *' $39
$
58

2
3
4
5
6
7
8
9

59
60
61
62
63
64
65
66
67

$
$
$30
$
$3F
$40
$41
$42
$43

;
<
9

>

ASCII

329

.2

68

$44

107

$6B

69

$45

108

$6

70

$46

109

$60

71

$47

110

$6

72

$48

111

$6F

73
74

$49
$4

m
n

112

113

$70
$71

75

$4

114

$72

76
77

$4
$40

115

116

$73
$74

78

$4

117

$75

79

$4F

118

$76

80

$50

119

81

Q
R

120

82

$51
$52

83

$53

84

$54

85

$55

86

$56

87

$57

88

146

$92

185

$9

147

186

148

$93
$94

187

149

$95

150
151

$96
$97

152

$98

153
154

$99
$9

155

$9

u
V

156
157

$9
$90

$77

158

$9

$78

159

$9F

121

$79

160

122

$7

161

$1

123

$7

162

$2

124

$7

163

125

$70

164

$4

126

$7

165

$5

$58

127

$7F

89

$59

128

$80

166
167

$6
$7

90

$5

129

$81

168

$8

91

$5

130

$82

169

$9

92

$5

$83

170

93

$50

131
132

$84

171

94

$5

133

$85

95

$5F

134

$86

188
189
190

$
$

JI

191

$BF

192

193
194

$1
$2

195
196

$
$4

197

$5

198

$6

199

$7

200

$8

J.

201

$9

202

JL

203

204
205

$
$

206

JL
1

207

$CF

208

$00

JL

209

$01

210

$02

172

211

$03

1L

173

212

$04

1=

||=

135

$87

174

213

$05

136

$88

$AF

214

$06

137

$07

99

138

176
177

215

$89
$8

$63

216

100

$64

139

$8

175

$62

$08
$09

101

$65

$8

$66

140

102

141

$80

103
104

$67

142

$8

$69

h
i

143
144

$8F

105
106

$6

145

$91

96

$60

97

$61

98

$68

$90

178

$1
$2

179

180

$4

181
182

$5

183

$6
$7

184

$8

1
1
-

j
1

217
218

219

220

221

$00

222

$
$DF

223

1
1

330

. ASCII

.2

224

225

$1
$2

240

$FO

248

$F8

249

$F9

250

$FA

251

$FB

252

$FC
$FD

$8
$9

241

$F1

234

242

$F2

243
244

$F3
$F4

245

$F5

246
247

$F6
$F7

235

228

$
$4

229

$5

236
237

230

$6

238

231

$7

239

$EF

232
233

226
227

$ED

253
254

255

$FE
$FF

,
System, Crt, Dos, Graph Strings.
uses.
System, .

System

, , , ,
. CoordSys. pas .1.

, , , . , , . Turbo Pascal
File | Open (<F3>).
.1. CoordSys.pas
Unit CoordSys;
interface
uses Graph;
const
ZeroX = 320; { )
ZeroY = 175; { Y }
' procedure DrawCoordSys;
implementation
procedure DrawCoordSys;
DriverVar, ModeVar, ErrorCode: integer;
begin
{ }
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar,'\tp\bgi') ;
ErrorCode := GraphResult;
{ }
if ErrorCode <> grOK then

332

. , : System

.1
begin
Writeln(GraphErrorMsg(ErrorCode)) ;
Halt(l);
end;
ClearDevice; { }
SetColor(White); { }
Line(ZeroX,10,ZeroX,340); { Y}
Line(10,ZeroY,630,ZeroY); { }
end;
end.
DrawCoordSys
uses CoordSys, CoordSys. tpu Unit directories
Directories (. . 1.4).

bgi InitGraph . , tpc.exe


turbo. , Turbo Pascal,
: \TP\BIN, bgi- : \TP\BGI , .2 ' \tp\bgi' '.. \bgi'. , ,
, , : \.
13.

Abs
.
: Abs (X)
X .
: .

= ||
.2, . .1.

.2. FuncAbs. pas


program FuncAbs;
uses Crt, Graph, CoordSys;
var
x, y: integer;
begin
DrawCoordSys; { CoordSys ( .1)}
for x := -150 to 150 do { )
begin
{ ' -150 150}
:- abs(x) ( = ||}
PutPixel(ZeroX+x, ZeroY-y, Yellow); {
, }

ArcTan

333

.2

end;
ReadKey; { - )
CloseGraph; { }
end.

.
: ( X )
X .
: Real.

= () ., . .2.
.. FuncATan.pas
program FuncATan;
uses Crt, Graph, CoordSys;
const
UnitX = 3; { X)
UnitY = 10; { Y}
var
: integer;
: real;
begin
DrawCoordSys; { CoordSys ( .1)}
SetColor(Yellow); { }
for := -150 to 150 do
begin
:= ArcTan();
LineTo(ZeroX+x*UnitX, ZeroY-round(y*UnitY));
end;
ReadKey; { - }
CloseGraph; { }
end.

. .1.
|| FuncAbs

. .2. =
() FuncATan

334

. , : System

UnitX UnitY
X Y. ,
ZeroY, . , Y , .

Cos
( ).
: Cos (X)
X .
: Real.

= Cos(x)
.4, . ..
.4. FuncCos. pas
program FuncCos;
uses Crt, Graph, CoordSys;
const
UnitX = 12; { X}
UnitY = 8 ; { Y}
var
: integer;
: real;
begin
DrawCoordSys; { CoordSys ( .1)}
SetColor(Yellow); { )
for := -150 to 150 do
begin
:= Cos(x);
LineTo(ZeroX+x*UnitX, ZeroY-round(y*UnitY));
end;
ReadKey; { - )
CloseGraph; { )
end.


().
: (X)
X .
: Real.

= .,
. .4.
.5. FuncExp.pas
program FuncExp;
uses Crt, Graph, CoordSys;
const
UnitX = 40; { X)

Frac

335

.5
UnitY = 10; { Y )
var
, : real;
begin
DrawCoordSys; ( CoordSys ( .1)}
SetColor(Yellow); { )
:= -20;

while x <= 5 do
begin
:= Exp(x);
LineTo(ZeroX+x*UnitX, ZeroY-round(y*UnitY));
x := x + 0.1;
end;
ReadKey; { - }
CloseGraph; { }
end.

. .. =
Cos(x) FuncCos

. .4. =
FuncExp

Frac
.
: F r a c ( X )
X .
: Real.

Frac .6.
.6. FuncFrac. pas
program FuncFrac;
uses Crt;
var
x , f P a r t : real;
s: string;
p: byte;
{ }
function Power(Mum, Pow: b y t e ) : longint;
var
i: integer;
Res: longint;

336

. , : System

.6
begin
Res := 1;
for i := 1 to Pow do Res := Res
Power := Res;
end;

Num;

begin
ClrScr; ( }
Write(' :');
Readln(x) ;
fPart := Frac(x); ( }
Str(fPart:10:8,s); ( }
Delete(s,I,2);
( }
(
, }
:= Length(s);
while s[p] = '0' do ( - 0}
begin
Dec(p); ( }
if = 0 then Break; {}
end;

if = 0 ( }
then Writeln(round(x-fPart))
else begin
Val(copy(s, l,p) , i, ) ; (
}
Writeln(round(x-fPart), ' ', i, '/', Power(10,));
end;
ReadKey; ( - }
end.

. ,
.
10 .

Int
.

: I n t ( X )
X .
: Real.
Int .7.
.7. Funclnt. pas
program Funclnt;
uses Crt;
var
x: real;
begin
ClrScr; ( }
Write(' :');

Pi

337

.7
Readln(x);
GotoXY(Round(Int(x)),3); { 3- ,
)
Write(Chr(Round(Int(x))+32)); { ,
ASCII }
ReadKey; { - }
end.

Pi
(3.1415926535897932385).
: Pi
: Real.

, , .8.
.8. FuncPi.pas
program FuncPi;
uses Crt;
var
r: word;
begin
ClrScr; { }
Write(' : ');
Readln(r);
,
Writeln(' = ', Pi*Sqr(r):5:2);
ReadKey; { - }
end.

Sin

( ).

: Sin(X)
X .
: Real.


= Sin(x) .9, . .5.

. .5. =
Sin(x) FuncSin

.9. FuncSin.pas
program FuncSin;
uses Crt, Graph, CoordSys;
const
UnitX = 12; { X}
UnitY = 8; { Y}
var

338

. , : System

.9
: integer;
: real;
begin
DrawCoordSys; { CoordSys ( .1)}
SetColor(Yellow); { }
for x := -150 to 150 do
begin
: = Sin(x);
LineTo(ZeroX+x*UnitX, ZeroY-round(y*UnitY));
end;
ReadKey; { - }
CloseGraph; { }
end.
Sqr
, .
: Sqr ( X )
X .
: .

, , . 10.
.10. FuncSqr.pas
program FuncSqr;
uses Crt;
var
a: word;
begin
ClrScr; { }
Write(' : ');
Readln(a);
Writeln(' = ', Sqr());
ReadKey; { - }
end.
Sqrt
.
: S q r t ( X )
X .
: Real.

, , . 11.

, 2 = 2 + 2 ,
= Va* + *, , b .

Break

339

.11. FuncSqrt.pas
program FuncSqrt;
uses Crt;
var
a,b: word;
begin
ClrScr; { }
Write(' 1- , : ');
Readln(a);
Write(' 2- , );: ');
Readln(b);
Writeln(' , = ', Sqrt(Sqr(a)+Sqr(b)):10:2);
ReadKey; { - }
end.

Break
.
: Break
Break . 12.
.12. ProcBrk.pas
program ProcBrk;
uses Crt;
var
i: integer;
begin
ClrScr; { }
{ 1 4}
for i := 1 to 10 do
if i = 5 then Break else Writeln(i);
{ 5 7}
i := 5; { }
while i <= 10 do
begin
Writeln(i);
Inc(i); { 1}
if i = 8 then Break;
end;
repeat { 8 10}
Writeln(i);
Inc(i);
if i = 11 then Break;
until i = 20;
v
ReadKey; { - }
end.

340

. , : System

Continue
.
: Continue
Continue . 13.
.13. ProcCntn.pas
program ProcCntn;
uses Crt;
'/
var
i: integer;
begin
ClrScr; { }
{ 1 20}
for i := 1 to 20 do
if (i mod 2) = .0 then Continue else Writeln(i);
ReadKey; { - }
end.
Exit
.
,
. ,
.
: Exit
Exit . 14.
.14. ProcExit.pas
program ProcExit;
uses Crt; -\
var
i: integer;
c: char;
procedure TwentyStars;
{ 20 '*' }
begin
for i := 1 to 20 do
if i = 20 then Exit else Write('*');
end;
begin
ClrScr; { }
repeat
TwentyStars;
Writeln;
Write(' ' 20 ?');
Write(' ... : ');
{,
<Enter>}
Readln(c);

Halt

341

.14
if not ( in ['Y1,'','','']) then Exit;
until False;
end.
Halt

DOS.

: Halt (ExitCode)
ExitCode Word .
Halt . 15.
.15. ProcHalt.pas
program ProcHalt;
uses Crt;
procedure PressEsc;
begin
repeat
WritelnCflflfl Esc');
if ReadKey = #27 then Halt;
until False;
end;
begin
ClrScr; { }
PressEsc;
end.
RunError
.
: RunError (ErrorCode)
ErrorCode Byte
( 3).
RunError . 16.
. 16. ProcRnEr.pas
program ProcRnEr;
uses Crt;
var
'--,
a, b: integer;
begin
ClrScr; ( }
repeat
Write(' : ');
Readln(a);
Write(' b: ');
Readln(b);
if b = 0
then RunError(200) ( }

342

. , : System

.18
else begin
Writeln('a/b
^1('

if ReadKey =
end;
ReadKey; (
until False;
end.

= ', a div b);


Esc.
...');
#27 then Exit;
- }

Eof
True, .
: Eof (F)
- F . , Input.
: Boolean.

, ,
. 17, . .6.
.17. FuncEof .pas
program FuncEof;
uses Crt;
var
F: Text;
s: string;
begin
ClrScr; { }
Write(' : ');
Readln(s);
Assign(F,s); { }
Reset(F);
{ }
while not Eof(F) do
begin
Readln(F,s); { }
Writeln(s); { }
end;
Close(F); { )
Write(' ... ' ) ;
ReadKey;
end.

Eoln
Eoln
True
.
: E o l n ( F )

F . ,


Input.

Boolean.

343

: tSavrtoexec.bat
SET COMSPEC=C:SUIMDOUSSCOMAND.COM
SET uindir=C:\UINDOUS
SET uinbootdir=CAUINDOUS
SET PATH=C:SUINDOUS;CAUINDOUSSCOMMAND
SET PROMPT=$p$g
SET TEMP=C:SUINDOUSSTEMP
SET TMP=C:SUINDOUSSTEMP
SET BLASTER=A220 15 Dl P338
.. .
. .6.
autoexec.bat

FuncEof


, ,
. 18.
.18. FuncEoln.pas
program FuncEoln;
uses Crt;
var
F: Text;
*
s: string;
c: char;
begin
ClrScr; { )
Writeln(' : ');
Readln(s) ;
Assign(F,s); { }
Reset(F);
{ }
while not Eoln(F) do
begin
Read(F,); { }
Write(); { }
end;
Close(F); { }
ReadKey; { - }
end.
FilePos
.

: FilePos (F)
- F ,
.
: Longint.

, , . 19.

344

. , : System

.19. FuncFPos.pas
program FuncFPos;
uses Crt;
var
F : file of Byte;
s: string;
begin
ClrScr; { }
Write(' : ' ) ;
Readln(s);
Assign(F,s); ( }
Reset(F); { }
Seek(F, FileSize(F)); { }
WriteLn(' : ', FilePos(F), ' ');
Close(F); { }
ReadKey; { - }
end.
FileSize
.
: FileSize ( F )
- F ,
.
: Longint.

, , .20.
.20. FuncFSz . pas
program FuncFSz;
uses Crt;
var
'
F : file of Byte;
s: string;
begin
ClrScr; { }
Write(' : ');
Readln(s);
Assign(F,s); { }
Reset(F); { }
WriteLn (' : ', FileSize(F), ');'
Close(F); { }
ReadKey; { - }
end.
lOResult
/. {$!-}.
: lOResult(F)
- F ,
.

SeekEof

345

: Integer.

, ,
.21.
.21. FuncIORs. pas
program FuncIORs;
uses Crt;
var
s: string;
function FileExists (FName: string)': boolean;
var
F: file;
isError: boolean;
begin
Assign(F,Fname); { )

{$!-}
Reset(F); { }
{$!+}
isError := lOResult > 0;
if isError
then Writeln(' !')
else Close(F); { }
FileExists := not isError;
end;
1

,
begin
ClrScr; { )
Write(' : ');
Readln(s);
if FileExists(s) then
Writeln(' ');
ReadKey; { - }
end.

SeekEof
, .
: SeekEof ( F )
- F Text.
: Boolean.
SeekEof .22.
.22. FuncSEof .pas
program FuncSEof;
uses Crt;
var
F: Text;
i: Integer;
begin
ClrScr; { }

346 . , : System
.22
Assign(F,'test.txt1); { }
Rewrite(F); { }
{ , Assign.
, , txt-
, -
ProcApnd.pas turbo.exe,
Turbo Pascal}
{ 8 }
Writeln(F, 4 2 3 4 ');
Writeln (,F, ' 5 6 7 8 ' ) ;
Reset(F); { }
{ . SeekEoln True,
uj^p;SeekEof True,
( ) }
while not SeekEof(F) do
begin
if SeekEoln(F) then Readln; { }
Read(F,i); { }
Writeln(i); {
}
end;
ReadKey; { - )
Close(F); { }
end.
SeekEoln
, .
: SeekEoln ( F )
- F Text.
: Boolean.
SeekEoln .22 (< .
).
V

'

Append
.
^

: Append (F)
- F Text.

Append .23.
.23. ProcApnd.pas
program ProcApnd;
uses Crt;
var
F: Text;
s: string;
begin

Assign

347

.23
{ )
ClrScr;
Assign(F, 'test.txt'); { }
Rewrite(F) ,;
{ }
Writeln(F, ' '); {
}
Close(F) ;
{ }
{ }
Append(F);
Writeln(F; ' ');
Close(F);
Reset(F);
( }
WriteIn(' test.txt:');
while not Eof(F) do
begin
Readln(F,s); ( }
Writeln(s); {
}
end;
Write(' .. . ') ;
ReadKey; { - }
end.
Assign
.

: As s ign (F, Name)


- F .
Name ( PChar ).
Assign .24. Name , ,
' testl. t x t ' , , - turbo.exe, Turbo Pascal. ( , , c:\ex),
, , ' : \ex\testl. t x t ' .
.24. ProcAsgn.pas
program ProcAsgn;
var
Fl: Text;
F2: File of Integer;
F3: File;
begin
{ }
Assign(Fl, 'testl.txt');
Assign(F2, 'test2.int');
Assign(F3, 'test3.dat');
( }
Rewrite(Fl);
Rewrite(F2);

348

. .

. , : System

.24
Rewrite(F3);
{ }
Close(F1);
Close(F2);
Close(F3);
end.
BlockRead
.
: .BlockRead (F, Buf, Count, Result)
- F .
- Buf , .
Count Word,
.
- Result Word,
.
BlockRead .25.
i
.25. ProcBlRd.pas
program ProcBIRd;
var
F: Text;
FFrom, FTo: File;
c: char;
begin
{ -)
Assign(F,'testl.txt'); { }
Rewrite(F); { }
WriteIn(F,'-'); {
}
Close(F); { }
{ }
Assign(FFrom,'testl.txt');
Assign(FTo,'test2.txt1);
Reset(FFrom,1); { }
Rewrite(FTo,1);
while not Eof(FFrom) do
begin
BlockRead(FFrom, c, 1); { )
BlockWrite(FTo, c, 1); { }
end;
( )
Close(FTo);
Close(FFrom);
end.

BlockWrite

349

BlockWrite
.
: BlockWrite(F, Buf, Count, Result)
- F . .
- Buf ,
.
Count Word,
.
- Result Word,
.
BlockWrite .26.
.26. ProcBlWr.pas
program ProcBlWr;
var
F: File;
: char;
i: byte;
begin
{ -}
Assign(F,'testl.dat'); { }
Rewrite(F,1); { 1 }
{ 0 255}
for i := 0 to 255 do
begin
:= Chr(i); { i }
BlockWrite(F,,1); { }
end;
Close(F); { )
end.

Close
.
: Close ( F )
- F .
Close .27.
.27. ProcClos.pas
program ProcClos;
var
Fl: Text;
F2: File of Integer;
F3: File;
begin
{ )
Assign(Fl, 'testl.txt');
Assign(F2, 'test2.int');
Assign(F3, 'test3.dat');

350

. , : System

.27
{ }
Rewrite(F1);
Rewrite(F2);
Rewrite(F3);
{ )
Close(Fl);
Close(F2);
Close(F3);

end.

Flush
, .
: Flush ( F )
- F Text.
Flush .28.
.28. ProcFlsh.pas
program ProcFlsh;
uses Crt;
var
F: Text;
i: word;
begin
ClrScr;
{ }
Assign(F; 'test.txt'); { }
Rewrite(F);
{ }
i := 0; { }
Writeln;
Writeln(' ...');
while not KeyPressed do
begin
{
GotoXY(1,1) ;
(1/1) - }
Write(i);
{ }
Writeln(F,i); { }
inc(i);
{ 1}
end;
Flush(F);
{ -
Writeln }
end.
ProcFlsh Flush, , Writeln, .
Read
.
.

Readln

351

Read Eof True.


Read
, .
: Read(F, VI, V2 . . . )
F - Text,
F .
VI, V2 . -, .
Read .29.
.29. ProcRead.pas
program ProcRead;
uses Crt;
var
F: Text;
cl, c2, c3: char;
begin
ClrScr;
{ }
Assign(F, 'test.txt'); { }
Rewrite(F); { )
Writeln(F,423'); { }
Reset(F);
{ }
Read(F,cl); { }
Read(F,c2,c3);
Close(F);
{ }
Writeln(cl,c2,); { }
ReadKey;
{ - )
end.

Readln
, .
,

: Readln (F, VI, V2 . . . )


- F Text.
VI, V2 . -, .
Readln ..
.. ProcRdln. pas
program ProcRdln;
uses Crt;
var
F: Text;
cl, c2: char;
begin
ClrScr;
{ }
Assign(F, 'test.txt'); { }
Rewrite(F);
{ }
Writeln(F,'123'); { }
Writeln(F,'456');
Reset(F);
{ }

352

. , : System

.
Readln(F,cl); { 1- 1- )
Readln(F,c2); { 1- 2- )
Close(F);
{ )
Writeln(cl);
{ )
Writeln(c2);
ReadKey; { - )

end.

'

Reset

.
Assign.
: Reset (F, RecSize)
- F .
RecSize , , RecSize = 128 .
Reset
.31.
.31. ProcRset.pas
program ProcRset;
uses
Crt;
var
F: File;
: char;
s: string;
begin
ClrScr;
{ )
Write(' : ');
Readln(s);
Assign(F,s); { )
Reset(F,1); { 1 )
while not Eof(F) do
begin
BlockRead(F, c, 1); { )
Write (); { )
end;
Close(F);
{ )
ReadKey;
{ - )
end.
Rewrite
.
: Rewrite(F, RecSize)
- F .
RecSize , , RecSize = 128 .
Rewrite .32.

Seek

353

.32. ProcRwrt.pas
program ProcRwrt;
var
Fl: Text;
F2: File of Word;
F3: File;
i: word;
begin
( }
Assign(Fl, 'testl.txt');
Assign(F2, 'test2.int1);
Assign(F3, 'test3.dat');
Rewrite(Fl); { )
WritelnfFl,''); { ' }
Rewrite(F2);

i := 1; ^
Write(F2,i);
Rewrite(F3,2) ; { 2 }
for i := 1 to 10 do BlockWrite(F3,i,1);
{ }
Close (FibClose (F2) ;
Close(F3);
end.

Seek
.
: Seek(F, N)
- F , Text.
N Longlnt, , ( 0).
Seek ..
.. ProcSeek.pas
program ProcSeek;
uses Crt;
var
F: File of Byte;
s: string;
c: byte;

procedure ShowChar(N: Longint);


begin
Seek(P, N);
Read(F, c);
Writeln (Chr (Obend ;
begin
ClrScr; { }
Write(' : ');
Readln(s);

354

. , : System

.
Assign(F, s); { }
Reset(F); ( }
WriteIn(' : ');
ShowChar(0);
Writeln(' : ');
ShowChar(FileSize(F) div2);
Writeln(' : ');
ShowChar(FileSize(F)-1);
Close(F); { }
ReadKey; { - }
end.
SetTextBuf
/.

: SetTextBuf(F, Buf, Size)


- F Text.
- Buf ,
.
Size Word, / .
SetTextBuf .34.
.34. ProcStTB.pas
program ProcStTB;
uses Crt;
var
F: Text;
c: Char;
Buf: array [1..4095] of Char; {4 }
s: string;
begin
ClrScr; { }
Write(' : ');
Readln(s);
Assign(F,s); { }
{ }
SetTextBuf(F,Buf);
Reset(F); { }
{ }
while not Eof(F) do
begin
Read(F,c); { }
Writeln(c); { )
end;
ReadKey; { - }
end.
Truncate
, .
: Truncate (F)

Write

355

- F , Text.
Truncate .35.
.35. ProcTrun.pas
program ProcTrun;
uses Crt;
var
F: File of word;
i: word;
begin
ClrScr; { }
Assign(F,'test.dat'); { }
Rewrite(F); { }
{ 1 10}
for i := 1 to 10 do Write(F,i);
Seek(F,5); { }
Truncate(F); { }
Reset(F); { }
{ }
while not Eof(F) do
begin
Read(F,i); { }
Writeln(i); { }
end;
Close(F); { }
ReadKey; { - }
end.

Write

.
.

: Write (F, VI, V2, . . . )


F - Text,
.
VI, V2 .. , .
Write .36.
.36. ProcWrit.pas
program ProcWrit;
var
Fl: File of word;
F2: Text;
i: word;
begin
{ }
1
Assign(Fl,'test.dat );
Assign(F2,'test.txt');
{ }
Rewrite(Fl);

356

. , : System

.36
Rewrite(F2);
i := 1000;

{ }
Write(Fl,i);
Write(F2,i,i+l);
{ }
Close(Fl);
Close(F2);
end.

Writeln
, .
: Write (F, VI, V2, . . . )
- F Text.
VI, V2 .. , .
Writeln .37.
.37. ProcWrtl. pas
program ProcWrtl;
var

F: Text;
i: word;
begin
Assign(F,'test.txt'); { }
Rewrite(F); { }
for i := 1 to 100 do Writeln(F,i,i+l); { }
Close (F);.
{ }
end.

ChDir
.
: ChDir (S)
s String, , .
ChDir .38.
.38. ProcCDir.pas
program ProcCDir;
uses Crt;
var

s: string;

Erase

357

.38
procedure ShowCurDir;
begin
G e t D i r ( 0 , s ) ; { )
Writeln(' : ', s) ;
end;
begin
ClrScr;
{ }
ShowCurDir;
Write(' , : ' )
Readln(s);
Choir(s); { }
ShowCurDir;
ReadKey; { - }
end.

Erase
.
: Erase (F)
F . Erase , F, .
Erase .39.
.39. ProcEras.pas
program ProcEras;
var
F: File;
begin
{ }
Assign(F,'test.dat');
Rewrite(F); { }
Close(F);
{ }
Erase(F);
{ }
end.

GetDir
.
: GetDir (D, S)
D Byte, ; ,
: 0 , 1 , 2 , 3 ..
- S String,
GetDir .40.
.40. ProcGDir.pas
program ProcGDir;
uses Crt;
var
s: string;

358

. , : System

.40
procedure ShowCurDir;
begin
GetDir(0,s); { }
Writeln(' : ' , s) ;

end;

begin
ClrScr;
{ )
ShowCurDir;
Write(' , : ' ) ;
Readln(s) ;
ChDir(s); { )
ShowCurDir;
ReadKey; { - )
end.
MkDir
.
: MkDir (S)
S String, .
MkDir .41.
.41. ProcMDir.pas
program ProcMDir;
uses Crt;
yar
s: string;
begin
ClrScr;
{ )
GetDir(0,s); { )
Writeln(' : ', s);
Write(' , : ');
Readln(s);
MkDir(s);
{ )
end.
Rename
.
: Rename (F, NewName)
:
F .
NewName String PChar,
.
Rename , F, NewName.
Rename .42.
.42. ProcRenm.pas
program ProcRenm;
uses Crt;

RmDir

359

.42
var

F: Text;
s: string;
begin
ClrScr;
{ )
Assign(F, 'test.dat');
Rewrite(F);
{ }
Writeln(F,1); { )
Write(' test.dat: ');
Readln(s);
Rename(F,s); ( )
Writeln(F,2); { }
Close(F);
{ }
end.
RmDir
.

' '

: RmD i ( S )
S String,
.
RmDir .43.
.43. ProcRDir. pas
program ProcRDir;
uses Crt;
var '
s: string;
begin
ClrScr;
{
Write('
Readln(s);
MkDir(s); {
RmDir(s); {
end.

}
: ');
}
}

"

Addr
, .

: Address ( X )
X , .
: X.
Addr .44.
.44. FuncAddr.pas
program FuncAddr;
uses Crt;

360

. , : System

.44

var
i: integer;
: Integer;
begin
ClrScr;
i := 1;
:= Addr(i);
._ + -^.
Writeln(i);
ReadKey;

end.

{ }
{ i}
{ i:=i+l}
{/ 2}
{ - }

Assigned
, nil.
: As s igned {)
-
.
: Boolean.
Assigned .45.
.45. FuncAsnd.pas
program FuncAsnd;
uses Crt;
var
i: Integer;
P: Integer;
procedure IsAssigned;
begin
if Assigned(P)
then Writeln(' 1)
else Writelnf' ');
end;
begin
ClrScr;
{ )
IsAssigned;
P := Addr(i); { i}
IsAssigned;
ReadKey;
{ - }
end.

CSeg
CS.
: CSeg
: Word.

CSeg .46.

DSeg
.46. FuncCSeg.pas
program FuncCSeg;
uses Crt;

i
{ }
procedure WriteHexWord(W : Word);
const
HexChars: array [0..15] of Char = '0123456789ABCDEF';
begin
Write(HexChars[Hi(W) shr 4],
{4- )
HexChars[Hi(W) and $F] , {3- )
HexChars[Lo(W) shr 4],
{2- )
HexChars[Lo(W) and $F]); {1- )
end;
.

begin
ClrScr; { }
Write(' : $');
WriteHexWord(CSeg);
ReadKey; { - }
end.

DSeg
DS.
\
: DSeg
: Word.
DSeg .47.
.47. FuncDSeg.pas
program FuncDSeg;
uses Crt;
{ }
procedure WriteHexWord(W : Word);
const
HexChars: array [0..15] of Char = '0123456789ABCDEF';
,begin
Write(HexChars[Hi(W) shr 4],
{4- }
HexChars[Hi(W) and $F], {3- }
HexChars[Lo(W) shr 4],
{2- }
HexChars[Lo(W) and $F]); {1- }
end;
begin
ClrScr;
{ }
Write(' : $');
WriteHexWord(DSeg);
ReadKey; { - }
end.

Hi
.
: Hi <)

361

362

. , : System

: Byte.
X Integer Word.
Hi
.48.
.48. FuncHi. pas
program FuncHi;
uses Crt;
var
i: Word;
( }
function DecToHex(n: Word): string;
const
HexChars: array [0..15] of Char = '0123456789ABCDEF';
begin
DecToHex := HexChars[Hi(n) shr 4] +
HexChars[Hi(n) and $F] +
HexChars[Lo(n) shr 4] +
HexChars[Lo(n) and $F];
end;
begin
ClrScr; { )
Write(' : ');
Readln(i);
Writeln(i,' = $',DecToHex(i));
ReadKey; ( - }
end.

Lo
.
: Lo ( X )
: Byte.
X Integer Word.
t

Lo
.49.
.49. FuncLo. pas
program FuncLo;
uses Crt;
var
i: Word;
( )
function DecToHex (n: Word): string/const
HexChars: array [0..15] of Char = '0123456789ABCDEF'
begin
DecToHex := HexChars[Hi(n) shr 4] +
HexChars[Hi(n) and $F] +
HexChars[Lo(n) shr 4] +

MaxAvail

363

.49

end;

HexChars[Lo(n) and $F];

begin
ClrScr; ( }
Write(' : ' ) ;
Readln(i);
Writeln(i,' = $',DecToHex(i));
ReadKey; { - }
end.

MaxAvail
.

, , . , ,
. Pascal .
, , , , , . ,
,
.
: MaxAvail

: Longint.
MaxAvail .50.
.50. FuncMaxA.pas
program FuncMaxA;
uses Crt;
type
MyRec = record
Num: Longint;
Name: array[1..3] of string/end;
begin
ClrScr;
{ }
Writelnf' : ',
MaxAvail, ' ');
if MaxAvail < SizeOF(MyRec)
then Write(' ')
else Write(' ');
Writeln(' MyRec');
ReadKey; { - }
end.

364

. , : System

MemAvail
.
. .
i
(
: MemAvail
: Longint.
MemAvail .51.
.51. FuncMemA.pas
program FuncMemA;
uses Crt;
,
begin
ClrScr; ( }
Writeln('B ', MemAvail, ' ');
ReadKey; { - }
end.

Ofs
.
: Ofs (X)
X .
: Word.
Ofs .52.
.52. FuncOf s .pas
program FuncOfs;
uses Crt;
var
i: Integer;
{ }
procedure WriteHexWord(W : Word);
const
HexChars: array [0..15] of Char = '0123456789ABCDEF';
begin
Write(HexChars[Hi(W) shr 4],
{4- }
HexChars[Hi(W) and $F], {3- }
HexChars[Lo(W) shr 4],
{2- }
HexChars[Lo(W) and $F]); {1- }
end;
begin
ClrScr; { }
Write(' i - $');
WriteHexWord(Ofs(i));
Write (' $');
WriteHexWord(Seg(i));
ReadKey; { - }
end.

Ptr

365

Ptr
, , .
: Ptr (Seg, Of s)
Seg Word, .
Of s Word, .
: .
Ptr .53.
.53. FuncPtr. pas
program FuncPtr;
uses Crt;
var
P: AByte;
Mode: string;
begin
ClrScr; { }
P := Ptr($40, $49);
case of
0: Mode := '- 40x25';
1: Mode := ' 40x25';
2: Mode := '- 80x25';
3: Mode := ' 80x25';
end;
WriteLn(' - ', Mode);
ReadKey; { - }
end.

Seg
.
: Seg ( X )
X .
: Word.
Seg .52 (<< . ,
Of s).

SizeOf
, .
: SizeOf ( X )
X .
: Integer.

SizeOf .54.
.54. FuncSzOf .pas
program FuncSzOf;
uses Crt;
type
MyRec = record

366

. , : System

.54
Fl: integer;
F2: string;
end;
var
: char;
i: integer;
r: real;
s: string;
Rec: MyRec;
begin
ClrScr; { }
Writeln(' ', SizeOf(c),' ');
Writeln(' i ', SizeOf(i),' ');
Writeln(' ', SizeOf(),' ');
Writelnf' s ', SizeOf(s),' 1);
WriteIn(' Rec ', SizeOf(Rec),' '!
ReadKey; { - }
end.

SPtr
SP.
: SPtr
: Word.
SPtr .55.
.55. FuncSPtr.pas
program FuncSPtr;
uses Crt;
var
i: Integer;
{ }
procedure WriteHexWord-(W : Word) ;
const
HexChars: array [0..15] of Char = '0123456789ABCDEF';
begin
Write(HexChars[Hi(W) shr 4],
{4- }
HexChars[Hi(W) and $F], {3- }
HexChars[Lo(W) shr 4],
{2- }
HexChars[Lo(W) and $F]); {1- }
end;
begin
ClrScr;
{ }
Write(' : $');
WriteHexWord(SPtr);
ReadKey; { - }
end.

SSeg
SSeg
SS.
: SSeg
: Word.

SSeg .56.
.56. FuncSSeg. pas
program FuncSSeg;
uses Crt;
var
i: Integer;
{ }
procedure WriteHexWord(W : Word);
const
HexChars: array [0..15] of Char = '0123456789ABCDEF';
begin
Write(HexChars[Hi(W) shr 4],
{4- }
HexChars[Hi(W) and $F], {3- }
HexChars[Lo(W) shr 4],
{2- )
HexChars[Lo(W) and $F]); {1- }
end;
begin
ClrScr;
{ }
Write(' $ ' ) ;
WriteHexWord(SSeg);
ReadKey; { - }

end.

Swap
.
: Swap(X)
X Integer Word.
: .
Swap . 57.
.57. FuncSwap. pas
program FuncSwap;
uses Crt;
var
i: word;
{ }
function DecToHex(n: Word): string;
const
HexChars: array [0..15] of Char = '0123456789ABCDEF';
begin
DecToHex := HexChars[Hi(n) shr 4] +
HexChars[Hi(n) and $F] +
HexChars[Lo(n) shr 4] +

367

368

. , : System

'

.57
HexChars[Lo(n) and $F];
end;
begin
ClrScr; { }
Write(' : ') ;
Readln(i);
Writeln(' Swap i = $ ', DecToHex (i) ) ;
Writeln(' Swap i = $',DecToHex(Swap(i)));
ReadKey; { - }
end.

Dispose
.
: Dispose(P, Destructor)
- .
Destructor .
Dispose .58.
.58. ProcDisp.pas
program ProcDisp;
uses Crt;
var

P: integer;
begin
ClrScr; { }
New(P); { }
:= 100;

Writeln();
Dispose(P); { )
ReadKey; { - }
end.

FillChar
.
: FillChar(X, Count, Value)
- X , .
Count Word, .
Value Byte Char.
FillChar .59.
.59. ProqFChr.pas
program ProcFChr;
uses Crt;

var

FreeMem
\

369

.59
s: string;
i: integer;
begin
ClrScr; { }
for i := 10 downto 1 do
begin
( i }
FillChar(s, i+1, Chr(i+64));
s[0] := Chr(i); { }
Writeln(s);
end;
ReadKey; { - }
end.

FreeMem
, .
: FreeMem(P, Size)
- .
Size Word, .
FreeMem .60.
.60. ProcFMem.pas

program ProcFMem;
uses Crt;
type
MyRec =- record
Num: Longint;
Name: array[1..3] of string;
end;
var
P: '"MyRec;
begin
ClrScr; { }
GetMem(P, SizeOf(MyRec)); { }
with do
begin
Num := 1;
. Name[l] := '';
Name[2] := '';
Name[3] := '';
Writeln(Num, ' - ',Name[l],' ',Name[2],' ' ,Name,[3] ) ;
end;
FreeMem(P, SizeOf(MyRec)j; ( )
ReadKey; ( - }
end.

GetMem
-. -

370

. , : System

, .
* . MaxAvail.
: GetMem(P, Size)
- .
Size Word, .
GetMem .61.
.61. ProcGMem.pas
program ProcGMem;
uses Crt;
var
P: AInteger;
begin
ClrScr; { )
if MaxAvail >= SizeOf(Integer) then {
}
begin
GetMem(P, SizeOf(Integer)); ( )
:= 1;
Writeln(PA);
FreeMem(P, SizeOf(Integer)); { )
end;
ReadKey; { - )
end.

New

: N e w ( P , Constructor)
- .
Conctructor .
New .62.
.62. ProcNew.pas
program ProcNew;
uses Crt;
type
PObj = j;
MyObj = Object
constructor Init(n: integer);
procedure ShowX;
private
X: integer;
end;
constructor MyObj.Init(n: integer);
begin

Mark

371

.60
X := ;
end;
procedure MyObj.ShowX;
begin
Writeln(X);
end;
var
P: PObj;
begin
ClrScr; { }
New(P, Init(lO)); { }
.ShowX;
Dispose(P); { }
ReadKey; { - }
end.

Mark
.
. MaxAvail.
: Mark ()
- .
Mark .63.
.63. ProcMark.pas
program ProcMark;
var
P : Pointer;
PI, P2, P3 : -^Integer;
begin
New(PI); { Integer}
Mark(P); { }
New(P2); { Integer}
New(P3);
Release(P); {, 2 ,
'1 }
end.
Move
.
: Move(Source, Dest, Count)
- Source .
- De.st .
/
Count Word,
.
Move .64.

372

. , : System

.64. ProcMove. pas


program ProcMove;
uses Crt;
var
si, s2: string;
c: Word;
begin
ClrScr; { )
Write(' : ');
Readln(sl);
Write(' ? ');
Readln(c);
Move(si,s2,c+l); { }
s2[0] := Chr(c); { s2)
Write(' : ');
Write(s2);
ReadKey; { - }
end.

Release
.
. MaxAvail.
: Release (P)
- .
Release .63 (< . , Mark).

Odd
True, .
: Odd(X)
X Longint.
: Boolean.
Odd .65.
.65. FuncOdd. pas
program FuncOdd;
uses Crt;
var
i: Word;
begin
ClrScr; { }
for i := 1 to 5 do
begin
Write(i,' - ');

Pred

373

.65
if Odd(i)
then W r i t e l n ( ' ' )
else W r i t e l n ( ' ' ) ;
end;
ReadKey; { - }
end.
Pred
, .
: P r e d ( X )
X .
: .
Pred .66.
.66. FuncPred.pas
program FuricPred;
uses Crt;
var

i: Word;
: char;
begin
ClrScr; { }
Write(' : ');
Readln(i);
Writeln(' ',i,' - ',Pred(i>);
Write(' : ');
Readln(c);
Writeln(' ',c,' - ',Pred(c)>;
ReadKey; { - }
end.

Succ
, .
: Succ ( X )
X .
: .
Succ .67.
.67. FuncSucc.pas
program FuncSucc;
uses Crt;
var

i: Word;
c: char;
begin

374

. , : System

.67
ClrScr;
{ }
W r i t e ( ' : ' ) ;
Readln(i);
Writeln(' ' , i , ' ' , S u c c ( i ) > ;
Write(' : ' ) ;
Readln(c);
Writeln(' ' , , ' ',Succ());
ReadKey; { - }
end.

UpCase
.
: UpCase (Ch)
Ch Char.
: Char.
UpCase .68.
.68. FuncUpCs .pas
program FuncUpCs;
uses Crt;
var
i: Byte;
s: string;
begin
ClrScr; { }
Writeln(' :');
Readln(s) ;
for i := 1 to Length(s) do s[i] := UpCase(s[i]);
Writeln(' :');
Writeln(s);
ReadKey; { - }
end.

Dec
.
: Dec ( X , N)
- X PChar,
.
N Longint, ,
X ( N = 1).
Dec .69.
.69. ProcDec.pas
program ProcDec;
uses Crt;
var

Inc

375

.69
i: Byte;
begin
ClrScr; { }
i := 10;
{ 10 1}
while i > 0 do
begin
Writeln(i);
Dec(i);
end;
ReadKey; { - )
end.

Inc
.
: Inc (X, N)
- X PChar,
.
N Longlnt, ,
X ( N = 1).
Inc .70.
.70. Proclnc. pas
program Proclnc;
uses Crt;
var
i: Byte;
begin
ClrScr; { ) ,
i := 0;
{ 0 9}
while i < 10 do
begin
/
Writeln(i);
Inc(i);
end;
,
ReadKey; { - )
end.

Concat
.
: Concat (SI, S2, . . . )
SI, S2 .. String.

376

. , : System

: string.
Concat .71.
.71. FuncConc.pas
program FuncConc;
uses Crt;
var

A: array[1..3] of string;
i: byte;
begin
ClrScr; { }
for i := 1 to 3 do

begin
Write(i,'-e : ');
Readln(A[i]);
end;

Write(' : ');
Write(Concat(A[l],' ' ,A[2] , ' ',A[3]));
ReadKey; { - }
end.


.
; (S, Index, Count)
S String.
Index . Integer, S.
Count Integer, .
: String.
.72.
.72. FuncCopy.pas
program FuncCopy;
uses Crt;
var

A: array[1..3] of string;
i: byte;
s: string;
begin
ClrScr; { }
Write(' : ');
Readln(s);
for i := 1 to 2 do

begin
A[i] := copy(s,l,pos(' ',s)-D;
Delete(s,l,pos (' ',s)); { i-e }
end;

A[3] := s; { }
for i := 1 to 3 do
Writeln(i,'-e : ',A[i]);

Length
.72
ReadKey; ( - }
end.

Length
.
: Length (S)
S String.
: Integer.
Length .73.
.73. FuncLeng. pas
program FuncLeng;
uses Crt;
var
s: string;
begin
ClrScr; { )
Write(' : ');
Readln(s);
Write(' ', Length(s),' .');
ReadKey; { - }
end.


.
: Pos (Substr, S)
Substr String.
S , , string.
: Byte.
.74.
.74. FuncPos .pas
program FuncPos;
uses Crt;
var
s: string;
CurChar: Char;
c: Word;

begin
ClrScr; { } -'
Write(' : ');
Readln(s);
while Length(s) > 0 do
begin
CurChar := s[l]; { }
:= 0;
while (pos(CurChar,s) > 0) do { }

377

378

. , : System

.74
begin
{ )
Inc (); { }
Delete(s,pos(CurChar,s),1); { }
end;

Writeln(' "',CurChar,'" - ',);


end;

ReadKey; { - }
end.

Delete
.
: Delete(S, Index, Count)
- S String.
Index Integer, .
Count Integer,
.
Delete .75.
.75. ProcDele.pas
program ProcDele;
uses Crt;
var

s: string;
begin
ClrScr;
{ )
Write(' : ');
Readln(s);
while (pos(' ',s) > 0) do { }
Delete(s,pos (' ',s),l>; { }
Write(' : ');
Write(s);
ReadKey; { - }
end.

Insert
.
: Insert(Source, S, Index)
Source String. ,
- S String, .
Index Integer, .
Insert .76.

Chr
.76. Proclnse.pas
program Proclnse;
uses Crt;
var
s: string;
Source: string;
Index: Integer;
begin
ClrScr;
{ }
Writeln(' :');
Readln(s);
Writeln(' :'};
Readln(Source);
Writeln(' :');
Readln(Index);
Insert(Source,s,Index);
Writeln(' :');
Writeln (s);
/
ReadKey; { - }
end.

Chr
ASCII.
: Chr ( X )
X Byte.
: Char.
Chr .77.
.77. FuncChr .pas
program FuncChr;
uses Crt;
var
i: byte;
begin
ClrScr; { }
{ 48 57}
for i := 48 to 57 do
Writeln("",Chr(i),'" - ';i);
ReadKey; { - }
end.

Ord
.
: Ord (X)
X .

379

380

. , : System

: Longint.
Ord .78.
.78. FuncOrd.pas
program FuncOrd;
uses Crt;
var
c: Char;
begin
ClrScr; { }
for := '0' to '9' do { 0 9}
Writeln("",c, '" - ',0rd(c));
ReadKey; { - ;}
end.

Round
.
: Round ( X )
X Real.

: Longint.
Round .79.
.79. FuncRoun.pas
program FuncRoun;
uses Crt;
var
r: Real;
begin
ClrScr; { }
Write(' : ');
Readln(r);
Writeln (r:10:3,', = ',Round(r));
ReadKey; { - }
end.

Trunc
.
: Trunc ( X )
X Real.
: Longint.
Trunc .80.
.80. FuncTrun. pas
program FuncTrun;
uses Crt;
var
r: Real;
begin
ClrScr; { }
Write(' : ');

Str

381

.80
Readln(r);
Writeln(r:10:3,', = ',Trunc(r)>; .
ReadKey; { - }
end.

Str
.
: Str ( X : W i d t h : Decimals, S)
X .
Width Decimals
(
).
- S String, .
Str .81.
.81. ProcStr .pas
program ProcStr;
uses Crt;
var
r: Real;
. :
i: Integer;
s: string;
begin
ClrScr; { }
Write(' : ');
Readln(r) ;
Str(r:10:3,s); { }
Writeln('Ero : ',s);
Write(' : ');
Readln(i);
Str(i,s); { }
Writelnf'Ero : ',s);
ReadKey; { - )
end.

Val
.
: Val (S, V, Code)
S , , .
- V .
- Code Integer,
, , , .
Val .82.

382

. , : System

.82. ProcVal. pas


program ProcVal;
uses Crt;
var
s: string;
n: Real;
Error: Integer;
begin
ClrScr; { )
Write(' : ');
Readln(s);
Val(s,n,Error);
if Error > 0
then Writeln(' ',Error)
else if pos('.',s) = 0 { )
then Writeln(' ',:10:0)
else Writeln(' ',:10:3);
ReadKey; { - )
end.

High
.
: H i g h ( X )
X .
: .
High .83.
.83. FuncHigh. pas
program FuncHigh;
uses Crt;
begin
ClrScr; { )
Write(' Integer = ');
Writeln(High(Integer));
Write(' Char = #');
Writeln(Ord(High(Char)));
ReadKey; { - )
end.

Low
.
: Low(X)
X .
: .
Low .84.

ParamCount

383

.84. FuncLow.pas
program FuncLow;
uses Crt;
begin
ClrScr; { )
Write(' Integer = ');
Writeln(Low(Integer));
Write(' Char = #');
Writeln(Ord(Low(Char)));
ReadKey; { - }
end.

ParamCount

.
,
.
tpc.exe, ,
.
. tpc.exe "
DOS" 13.

: ParamCount
: Word. ( ),
0.
ParamCount .85.
.85. FuncParC. pas
program FuncParC;
uses Crt;
begin
ClrScr; { }
if ParamCount = 0
then Writeln(' ')
else Writeln(' - ', ParamCount);
ReadKey; { - }
end.
'

ParamStr
.

: ParamStr (Index)
Index . Index = 0 .
: String.
ParamStr .86. , , .

384

. , : System


.
.86. FuncParS. pas
program FuncParS;
uses Crt;

var

: Word;
begin
ClrScr;
{ }
Writeln(' :');
{ }
for i := 0 to ParamCount do
Write(ParamStr(i),' ' ) ;
ReadKey; { - }

",

end.
Random
.
,
Randomize.
: Random (Range)
Range Word. ,
0 () Range. ,
() 1.
: Longint Real.
Random .87.
.87. FuncRndm.pas
program FuncRndm;
uses Crt;
begin
ClrScr; { }
Randomize; { }
Write(' 0 100: ');
Writeln(Random(100):8) ;
Write(' 0 1: ');
Writeln(Random:10:3);
ReadKey; { - }
end.

Exclude
.
: Exclude (S, I)
- S .
I , S.

Include

385

Exclude .
.88. ProcExcl. pas
program ProcExcl;
uses Crt;
var
S: set of Byte;
i: Byte;
procedure ShowSet;
{ ,
0 255}
begin
for i := 0 to 255 do
if i in S then Write(i,1 ');
Writeln;
end;
begin
ClrScr;
{ }
S := [1,2,4,5,200,201,255]; { }
Writeln(' :');
ShowSet;
for i := 1 to 255 do
if (i in S) and ((i mod 2) = 0) {
2,}
then Exclude(S,i);
{ }
Writeln(' :');
ShowSet;
ReadKey; { - }
end.

Include
.
: Inc lude (S, I)
- S .
I , S.
Include .89.
.89. Proclncl. pas
program Proclncl;
uses Crt;
var
S1,S2: set of Byte;
i: Byte;
procedure ShowSet;
{ ,
0 255}
begin
for i := 0 to 255 do
if i in SI then Write(i,' ');

386

. , : Crt

.89
Writeln;
end;
begin
ClrScr;
{ }
{ )
51 := [1,5,201,255];
52 := [ 2 , 4 , 2 0 0 ] ;
Writeln(' :');
ShowSet;
for i := 1 to 255 do
{ S2
1 255, si)
if i in S2 then Include(SI,i);
Writeln(' :');
ShowSet;
ReadKey; { - )
end.

Randomize
.
: Randomize
Randomize .87 ( .
, Random).

Crt

KeyPressed
True, - .
: KeyPressed
: Boolean.
KeyPressed .90.
.90. FuncKPrs. pas
program FuncKPrs;
{ )
uses Crt;
var
: byte;
begin
ClrScr; { )
:= 1; { )
while not KeyPressed do { )
begin

Randomize
.90
GotoXY(l,l); { (1,1)}
{ }
case of
1: Write('I');
2 Write('/');
3 Write('-');
4 Write('\');
end
Delay (2000)'; { 2 }
Inc(c); { 1}
if > 4 then := 1; {, ,}
{ 4}
end;
end.
,

ReadKey
.
: ReadKey
: Char.
ReadKey .91.
.91. FuncRKey.pas
program FuncRKey;
uses Crt;
begin
ClrScr; { }
Writeln(' - ');
Writeln(' - ',Ord(ReadKey));
ReadKey; { - }
end.

WhereX
X .
: WhereX
: Integer.
WhereX .92.
.92. FuncWhrX.pas
program FuncWhrX;
uses Crt;
var
x: Integer;
begin
ClrScr; { }
Write(' X
x := WhereX;
Writeln(x);

= ');

387

388

. , : Crt

.92
GotoXY(x,l);
{ ,
}
ReadKey; { - }
end.

WhereY
Y .
: WhereY
: Integer.
WhereY .93.
.93. FuncWhrY.pas
program FuncWhrY;
uses Crt;
begin
ClrScr; { }
Write(' Y = ', WhereY);
ReadKey; { - }
end.

AssignCrt
CRT. ,
AssignCrt,
. , ,
, Assign. ,
Write Writeln , .
: AssignCrt ( F )
- F Text.
AssignCrt .94.
.94. ProcACRT.pas
program ProcACRT;
uses Crt;

var

F: Text;
begin
ClrScr;
{ }
Assign(F,' test.txt'); { }
AssignCrt(F);
Rewrite(F); { }
{ }
Write(F, ' AssignCrt');

Randomize

389

.94
Close(F); ( )
ReadKey; { - }
end.

ClrEol
( ) ,
.
: ClrEol
ClrEol .95.
.95. ProcCEol.pas
program ProcCEol;
uses Crt;
var
i,j: integer;
begin
ClrScr; { )
{ : 5 75 )
for i := 1 to 5 do
begin
for j := 1 to 75 do Write(i);
Writeln;
end;
Writeln(' .. . ') ;
ReadKey;
{ ClrEol}
forti := 1 to 5 do
begin
GotoXY(i+l,i);
ClrEol;
end;,
ReadKey; { - )
end.

ClrScr
.
: ClrScr
ClrScr .96.
.96. ProcCScr.pas
program ProcCScr;
uses Crt;
var
c: char;
begin
ClrScr;
{ }
Randomize; { )

390

. , : Crt

.96
repeat
:= #0;

while not KeyPressed do { }


begin
{ }
GotoXY(Random(80),Random(25));
( }
Write(Chr(33+Random(60)));
Delay(3000); { 3 }
end;
ClrScr; { }
:= ReadKey; {, )
until = #27; { , Esc}
end.

Delay
.
: Delay (MS)
MS Word, ,
.
Delay .97.
.97. ProcDely.pas
program ProcDely;
uses Crt;
var
DelayTime: Word;
c: Char;
begin
ClrScr; { }
Writeln(' - "+", - "-", - Esc');
DelayTime := 4000; { - 4 .)
repeat
:= #0;
while not KeyPressed do { }
begin
Writer*');
Delay(DelayTime); {}
end;
:= ReadKey; {, }
{ )
case of
'+','=': if DelayTime > 2000 then Dec(DelayTime,1000); {}
'-','_': Inc(DelayTime, 1000); {}
end;
until = #27; { , Esc}
end.

Randomize

391

DelLine
, .
: DelLine
DelLine .98.
.98. ProcDelL.pas
program ProcDel'L;
{ <Del>}
uses Crt;
var
i,j: integer;
begin
ClrScr; { }
{ }
for i := 1 to 25 do Writeln (' "Turbo Pascal 7.0 .
.. . "1" );
GotoXY(1,1);
repeat
case ReadKey of
#27: Break; { - Esc}
#72: if WhereY > 1 then GotoXY(WhereX,WhereY-l); { }
#80: if WhereY < 25 then GotoXY(WhereX,WheieY+1); { }
#83: DelLine; { Delete)
end;
until False;
end.

GotoXY
.
: GotoXY (X, Y)
X Y Integer,

.
GotoXY .99.
.99. ProcGoXY.pas
program ProcGoXY;
uses Crt;
begin
ClrScr; { }
' - Esc');
Writeln (' - .
repeat
case ReadKey of
#27: Break; { - Esc}
#72: if WhereY > 1 then GotoXY(WhereX,WhereY-1) { }
#75: if WhereX > 1 then GotoXY(WhereX-1,WhereY) { }
#77: if WhereX < 80 then GotoXY(WhereX+1,WhereY) { }
#80: if WhereY < 25 then GotoXY(WhereX,WhereY+1) ; { }
end;
until False;
end.
\

392

. , : Crt

HighVideo
.
: HighVideo
HighVideo . 100.
. 100. ProcHVid.pas
program ProcHVid;
uses Crt;
begin
ClrScr; { )
HighVideo;
Writeln ( ' ');
NormVideo;
Writeln ( ' ' ) ;
ReadKey; { - )
end.

InsLine
.
: InsLine
InsLine . 101.
.101. ProcInsL.pas
program ProcInsL;
{ <Insert>)
uses Crt;
var
i,j: integer;
begin
ClrScr; { )
{ )
for i := 1 to 25 do Writeln (' "Turbo Pascal 7. .
.. . ""');
GotoXY(l,l);
repeat
case ReadKey of
#27: Break; { - Esc)
#72: if WhereY > 1 then GotoXY(WhereX,WhereY-1); { )
#80: if WhereY < 25 then GotoXY(WhereX,WhereY+1) { )
#82: InsLine; { Insert)
end;
until False;
end.

LowVideo
i

.
: LowVideo
LowVideo . 102.

Randomize
. 102. ProcLVid.pas
program ProcLVid;
uses Crt;
begin
ClrScr; { }
i
LowVideo;
Writeln(' ');
NormVideo;
Writeln(' ');
ReadKey; { - }
end.

NormVideo
.
: NormVideo
NormVideo . 103.
. 103. ProcNVid.pas
program ProcNVid;
uses Crt;
begin
ClrScr; { }
LowVideo;
Writeln(' ');
HighVideo;
Writeln(' ');
NormVideo;
Writeln(' ');
ReadKey; { - }
end.

NoSound
.
: NoSound
NoSound . 104.
.104. ProcNSnd.pas
program ProcNSnd;
uses Crt;
begin
ClrScr;
{ }
Sound(lOOO); { 1000 }
Writeln(' , ');
ReadKey;
NoSound;
Writeln(' ');
ReadKey; { - }
end.

393

394

. , : Crt

Sound
.
: Sound (Hz)
Hz Word, .
Sound . 105.
.105. ProcSoun.pas
program ProcSoun;
uses Crt;
var
i: Word;
begin
{ }
ClrScr;
i := 1000;
Write(' ...');
while i <= 5000 do
begin
Sound(i);
{ i }
Delay(SOOO); { 5 }
Inc(i,100); { 100 }
if KeyPressed then break;
end;
NoSound;
{ },
end.

TextBackGround
.
: TextBackGround (Color)
Color Byte,
. Crt (. .1).
.1. Crt ,

0
1
2
3

(Black)
(Blue)
(Green)
(Cyan)

8
9
10
11

4
5

(Red)
(Magenta)

12
13

6
7

(Brown)
-
(LightGray)

14
15

- (DarkGray)
- (LightBlue)
- (LightGreen)
-
(LightCyan)
- (LightRed)
-
(LightMagenta)
(Ye How)
(White)

TextBackGround . 106.

Randomize

395

. 106. ProcTBgr.pas
program ProcTBgr;
uses Crt;
var

i: Byte;
(
begin
ClrScr; /{ }
for i := 0 to 15 do

begin
TextBackGround(i) ;
Writeln (' "Turbo Pascal 7.0 .
.. . ""');
end;

ReadKey; { - }
end.

TextColor
.
: TextColor (Color)
Color Byte, .

Crt (. . .1).
TextColor . 107.
.107. ProcTClr.pas
program ProcTClr;
uses Crt;
var

i: Byte;
begin
ClrScr; { }
for i := 0 to 15 do

begin
TextColor(i);
Writeln (' "Turbo Pascal 7. .
.. . ""');
end;
ReadKey; { - }
end.

TextMode
.
: TextMode (Mode)
Mode Integer, . Crt
(. .2).
TextMode . 108.

396

. , : Crt

.2.

0
- 40x25 (BW40)
1
40x25(0040)
2
- 80x25 (BW80)

Crt

3
80x25(0080)
7
80x25 (Mono)
43/50
256
EGA/VGA (Font8x8)

. 108. ProcTMod. pas


program ProcTMod;
uses Crt;
var
CurMode: Integer;
procedure ShowStr(Mode: Integer; s: string);
begin
TextMode(Mode); { }
TextBackGround(Blue); ( - }
TextColor(Yellow); { - }
Writeln(s);
Writeln (' "Turbo Pascal 7.0 .
.. . ""');
ReadKey; { - }
end;
begin
ClrScr; { }
CurMode := LastMode; { }
ShowStr(BW40,'BW40');
ShowStr(C040,'40');
ShowStr(BW8,'BW80');
ShowStr(C080,'080');
ShowStr(Mono,'Mono');
ShowStr(Font8x8,'FontSxS');
TextMode(CurMode); { }
end.

Window
. . .
: Window (XI, Y1, 2, Y 2 )
XI, 1, 2, Y2 Byte, .
Window . 109.
. 109. ProcWind.pas
program ProcWind;
uses Crt;
procedure ShowWindow(xl,yl,x2,y2,Color: Byte);
begin
Window(xl,1,x2,y2); { }

Randomize

397

. 109
TextBackGround(Color); { }
TextColor(White); ( - }
ClrScr; { }
GotoXY(l,l); { }
Writeln(Color); { }
end;
begin
ShowWindowd, 1,40,12,Blue) ;
ShowWindow(41,1,80,12,Green) ;
ShowWindowd, 13, 40, 24, Cyan) ;
ShowWindow(41,13,80,24,Red) ;
ReadKey; { - }
end.
ProcWind . .7.

. .7.

Dos

DiskFree
.

: DiskFree (Drive)
Drive Byte, : 0 ;
1 ; 2 ; 3 ..
: Longlnt.
DiskFree .110.
.110. FuncDFre.pas
program FuncDFre;
uses Crt, Dos;
var

398

. , : Dos

.110
Drive: Char;
FreeSpace: Longlnt;
begin
ClrScr; { }
Write(' : ');
Readln(Drive);
Drive := UpCase(Drive); { }
FreeSpace := DiskFree(Ord(Drive)-64);
Write(' ',Drive,' ');
Write(FreeSpace div 1024,' ');
Writeln(FreeSpace mod 1024,' ');
ReadKey; { - }
end.

DiskSize
.
: DiskSize (Drive)
Drive Byte, : 0 ;
1 ; 2 ; 3 ..
: Longlnt.
DiskSize .1.
.111. FuncDSiz.pas
program FuncDSiz;
, '
uses Crt, Dos;
var
Drive: Char;
Size: Longlnt;
begin
ClrScr; { }
Write(' : ');
ReadlnfDrive);
Drive := UpCase(Drive); { }
Size := DiskSize(Ord(Drive)-64) ;
Write(' ',Drive,' ');
Write(Size div 1024,' ');
Writeln(Size mod 1024,' ');
ReadKey; { - }
end.

DosExitCode
.
: DosExitCode
: Word. ; : 0 ; 1
<Ctrl+C>; 2 ; 3 Keep.
DosExitCode .112.

Randomize

399

.112. FuncDsEC.pas
program FuncDsEC;
uses Crt,Dos;
var
ProgramName, CmdLine: String;
.,begin
ClrScr; { )
Write(' : ');
Readln(ProgramName);
Write(' ', PrograraName, ': ');
Readln(CmdLine);
Writeln(' ...');
SwapVectors; { }
Exec(ProgramName, CmdLine); { }
SwapVectors; { }
WriteLn('... Exec');
if DosError <> 0 { DOS)
then Writeln(' DOS #', DosError)
else Writeln(' . = ', DosExitCode);
ReadKey; {^ - )
end.

DosVersion
DOS.

: DosVersion

: Word. ,
.
DosVersion .113.
.113. FuncDosV.pas
program FuncDosV;
uses Crt,Dos;
var
Ver: Word;
begin
ClrScr;
{ }
Ver := DosVersion;
WriteLn(' DOS: ',Lo(Ver),'.',Hi(Ver));
ReadKey; { - )
end.

EnvCount
DOS.
: EnvCount
: Integer.

(enviroment) ,
, .

400

. , : Dos


MS-DOS : . =, . MS-DOS ( ). MS-DOS .
, ,
.. ,
. ,
COMSPEC ':\' , MS-DOS COMMAND.COM. ,
PATH, , , , , .
MS-DOS SET
=.
AUTOEXEC.BAT (. . .6) CONFIG.SYS. ,
SET =: \; : \DOS; : \NC,
AUTOEXEC.BAT, , , ,
.

EnvCount . 114.
.114. FuncEnvC.pas
program FuncEnvC;
uses Crt,Dos;
begin
ClrScr; { )
WriteLn(' ',EnvCount,' DOS');
ReadKey; { - }
end.

EnvStr
DOS.
. .
: EnvStr (Index)
Index Integer, DOS.
: String.
EnvStr . 115.
.115. FuncEnvS. pas
program FuncEnvS;
uses Crt,Dos;
var

i: integer;
begin
ClrScr; { )

Randomize

401

.115
WriteLn(' DOS: ') ;
for i := 1 to EnvCount do Writeln(EnvStr(i));
ReadKey; { - }
end.

FExpand
( ).

'.
: FExpand (Path)
Path PathStr ( ,
Dos), .

: PathStr.
FExpand . 116.
.116. FuncFExp.pas
program FuncFExp;
uses Crt,Dos;
begin
ClrScr; { )
Writeln(' FuncFExp.exe:');
Writeln(FExpand('FuncFExp.exe') ) ;
ReadKey; { - )
end.

FSearch
.
: FSearch(Path, DirList)
Path PathStr ( ,
Dos), .
DirList String,
, .
: PathStr.
FSearch . 117.
.117. FuncFSrc.pas
program FuncFSrc;
uses Crt,Dos;
var
s: PathStr;
nf: String;
begin
ClrScr;
{ )
Writeln(' ,')
Writeln(' PATH')
Write(' : ')}
Readln(nf);
s := FSearch(nf, GetEnv('PATH')); { )

402

. , : Dos

.117

,
if s = "
then Writeln(nf,' !')
else Writeln(' ', FExpand(s));
ReadKey; { - }

end.

. DOS EnvCount.

GetEnv
DOS.
: GetEnv (EnVar)
EnVar String, DOS.
: string.
GetEnv . 118.
;.118. FuncGEnv.pas
program FuncGEnv;
uses Crt,Dos;
var
Name: string;
begin
ClrScr; { )
Write(' DOS: ');
Readln(Name);
Writeln (' ',Name,':');
Writeln(GetEnv(Name));
ReadKey; { - }
end.

Exec

. DosError.
: Exec (Path, CmdLine)
Path CmdLine String, .
Exec
( . , DosExitCode).

.2

FindFirst
.
: FindFirst(Path, Attr, F)
Path String, ,
* ?.

Randomize

403

Attr Word, .
Dos ( ): 1 Readonly ( ); 2
Hidden (); 4 System (); 8 VolumelD ( ); 16 Directory (); 32 Archive (); 63 AnyFile (
).
- F Dos
SearchRec.
:
type
SearchRec = Record
Fill: array[1..21] of Byte; {He }
Attr: Byte;
{ )
Time: Longlnt;
{ )
Size: Longlnt;
{ )
Name: String[12]; ()
end;

, Time, UnpackTime.
FindFirst . 119.
.119. ProcFlst.pas
program ProcFlst;
uses Crt, Dos;
var

F: SearchRec;
s:, string;
begin
ClrScr; { )
Write(' : ');
Readln(s);
FindFirst(s,AnyFile,F);
Writeln(' ',s);
Writeln(': F,F.Name);
Writeln(': ',F.Size,' ');
WriteIn(': ',F.Attr);
ReadKey; { - )
end.

FindNext
, FindFirs't. ,
, ,
FindNext Dos DosError. ,
18.
: FindNext (F)
- F Dos
SearchRec.
:

404

. , : Dos

type
SearchRec = Record
Fill: array[1..21] of Byte; {He }
{ }
Attr: Byte;
{ }
Time: Longlnt;
Size: Longlnt;
{ }
Name: String[12]; {}
end;

, Time, UnpackTime.
FindNext . 120.
.120. ProcFNxt .pas
program ProcFNxt;
uses Crt, Dos;
var

F: SearchRec;
s: string;
begin
ClrScr; { }
Write(' : ') ;
Readln(s);
FindFirst(s,AnyFile,F);
Writeln(' ',s,' :');
while DosError = 0 do
begin
Writeln(F.Name);
PindNext(F);
end;

ReadKey; { - }
end.

FSplit
.
: FSplit(Path, Dir, Name, Ext)
Path Dos PathStr, .
- Dir Dos
DirStr, .
- Name Dos
NameStr, ( ).
- Ext Dos
ExtStr, .
FSplit . 121.
.121. ProcFSpl.pas
program ProcFSpl;
uses Crt, Dos;
var
Path: PathStr;

Randomize

405

.121
Dir: DirStr;
,,
Name: NameStr;
Ext: ExtStr;
begin
ClrScr; { }
Writeln(' :');
Readln(Path);
FSplit(Path, Oir, Name, Ext);
Writeln(': ',Dir);
Writeln(': ',Narae);
Writeln(': ',Ext);
ReadKey; { - }
end.

GetCBreak
DOS
<Ctrl+Break>.
: GetCBreak (Break)
- Break Boolean.
GetCBreak False, DOS
<Ctrl+Break> / ; True, .
GetCBreak . 122.
.122. ProcGCBr.pas
program ProcGCBr;
uses Crt, Dos;
const
OffOn: array [Boolean] of String[4] = ('','');
var

Cb: Boolean;
begin
ClrScr; { )
GetCBreak(Cb);
Writeln(' <Ctrl+Break>: ', OffOnfCb]);
Cb := Not(Cb);
Writeln(' : ', OffOn[Cb]);
SetCBreak(Cb);
GetCBreak(Cb);
Writeln(' <Ctrl+Break>: ', OffOn[Cb]);
ReadKey; { - }
end.

GetDate
, .
: GetDate(Year, Month, Day, DayOfWeek)

4015

. , : Dos

- Year, Month, Day DayOfWeek Word,


^ Get Date , ,
: 0 , 1 ..
GetDate . 123.
.123. ProcGDat.pas
program ProcGDat;
uses Crt, Dos;
const
Months: array[1..12] of String[8] =
('','','','',
'','','','',
'','','', '');
Days: array[0..6] of String[ll] =
('','','',
'','','','') ;
var
Year, Month, Day, DayOfWeek: Word;
begin
ClrScr; { }
GetDate(Year, Month, Day, DayOfWeek);
Writeln(': ?,Year);
Writeln(': ',Months[Month]);
Writeln(': ',Day);
Writeln(' : ',Days[DayOfWeek] );
ReadKey; { - }
end.

GetFAttr
.
: GetFAttr (F, Attr)
- F .
- Attr Word, . Attr Dos: I Readonly ( ), 2 Hidden (), 4 System (), 8
VolumelD ( ), 16 Directory (), 32 Archive (), 63 AnyFile ( ).
Ge t FAt t . 124.
.124. ProcGFAt.pas
program ProcGFAt;
uses Crt, Dos;
var
F: File;
Attr: Word;
s: string;
begin
ClrScr; { }
Write(' : ');
Readln(s);

Randomize

407

.124
Assign(F, s); { }
GetFAttr(F, Attr);
{ , Dos}
if (Attr and Readonly) <> 0 then Writeln(' ');
if (Attr and Hidden) <> 0 then Writeln('');
if (Attr and SysFile) <> 0 then Writeln('');
if (Attr and VolumelD) <> 0 then Writeln('ID ');
if (Attr and Directory) <> 0 then Writeln(' ');
if (Attr and Archive) <> 0 then Writeln(' ()
ReadKey; { - }
end.

GetFTime
.
: Ge t FT ime (F, ime)
- F .
- Time Longint,
F.
Time UnpackTime.
GetFTime . 125.
.125. ProcGFTm.pas
program ProcGFTm;
uses Crt, Dos;
var
s: string;
F: File;
Time: Longint;
DT: DateTime; { DateTime Dos}
begin
ClrScr; { )
Write(' : ');
Readln(s);
Assign(F, s); { }
GetFTime(F,Time); { )
{ DateTime}
UnpackTime(Time, DT) ;
Writeln(' ',s, ' ');
Write (DT. Day, ' . ', DT. Month,'' . ',DT.Year) ;
Writeln(' ',DT.Hour,':',DT.Min,':',DT.Sec);
ReadKey; { - }
end.
DateTime, Dos, :
type
DateTime = Record
Year, Month, Day: Word;
Hour, Min, Sec: Word;
end;

408

. , : Dos

__

GetlntVec
, ,
: GetlntVec(IntNo, Vector)
IntNo Byte, .
- Vector.
GetlntVec . 126.
.126. ProcGlVc.pas
program ProcGIVc;
uses Crt, Dos;
var

IntlCSave: Pointer;
procedure TimerHandler; interrupt;
begin { - }
end;

begin
ClrScr; ( }
{ $1 - ( )}
( IntlCSave}
GetlntVec($1C, IntlCSave);
( }
SetIntVec($lC, @TimerHandler);
WriteLn(' ...');
repeat
until KeyPressed; ( }
( }
SetIntVec($lC, IntlCSave);
end.
$1 TimerHandler.
interrupt. GetlntVec
IntlCSave, SetlnVec ,
, , .

GetTime
, .
: GetTime(Hour, Minute, Second, SeclOO)
- Hour, Minute, Second, SeclOO -
Word, , , .
GetTime . 127.
.127. ProcGtTm.pas
program ProcGtTm;
uses Crt, Dos;

Randomize

409

.127
,

var

H1,H2,M1,M2,S1,S2,S100: Word;
begin
ClrScr; { }
Writeln(' ...');
ReadKey;
GetTime(Hl,Ml,Sl,S100);
Writeln(' ...');
ReadKey;
GetTime(H2,M2,S2,S100) ;
Writeln(' ');
Write(' : ',
2-1,' , ', 2-1,' , ', S2-S1, ' ');
ReadKey; { - }

end.

GetVerify

DOS.
: GetVerify (Verify)
- Verify Boolean. Verify
False, .
GetVerify . 128.
.128. ProcGVrf .pas
program ProcGVrf;
uses Crt, Dos;

var

IsVerify: Boolean;
begin
ClrScr;
{ }
GetVerify(IsVerify);
Write(' ' ) ;
if not IsVerify then W r i t e ( ' ' ) ;
Writeln('');
ReadKey; { - }

end.

Intr
.
: Intr (IntNo, Regs)
IntNo Byte, .
- Regs Registers.
Intr . 129.
.129. Proclntr.pas
program Proclntr;
uses Crt, Dos;

410

. , : Dos

.129
var
Year, Month, Day: String;
Regs : Registers;
begin
( }
ClrScr;
{ }
Regs.AH:=$2A;
Intr($21, Regs); { 21)
with Regs do
{ }
begin
Str.(CX, Year) ; { - }
Str(DH, Month); {DH - }
Str(DL, Day);
{DL - }
end;
Writen(': ',Day,'.',Month,'.',Year);
ReadKey; { - }
end.

Keep
.
: Keep (ExitCode)
ExitCode Word, .
Keep . 130.
.130. ProcKeep.pas
program ProcKeep;
{$ $800, 0, 0 }

{ 2, }

uses Crt, Dos;


var
KbdlntVec: Procedure; { }
{$F+} { (FAR) }
procedure KeyClick; interrupt;
begin \
{ $60 - ( $64 )}
if Port[$60] < $80 then
begin { }
Sound(SOOO);
Delay(1);
NoSound;
end;
InLine($9C); {PUSHF - }
{
}
KbdlntVec;
end;
{$F-}
begin
{ ^ )

Randomize

411

.130
GetlntVec($9, SKbdlntVec); {9 - }
( KeyClick}
SetIntVec($9, Addr(KeyClick));
( )
-^
Keep();
end.
.

MsDos
DOS ( $21).
: MsDos (Regs)
- Regs Registers, .
MsDos . 131.
.131. ProcMsDs.pas
program ProcMsDs;
uses Crt, Dos;

var
Year, Month, Day
i Regs : Registers
begin
ClrScr;
Regs.AH:=$2A;
MsDos (Regs) ;
with Regs do
begin
Str(CX Year);
Str(DH Month)
Str(DL Day) ;

String;
( )
( )
( 21)
( )
( - )

(DH - )
(DL - )

end;

WriteLn( : ' , Day, ' . ' , Month, ' . ' , Year) ;


ReadKey; ( - )
end.

. . 129.

PackTime
DateTime Longint.
: PackTime fDT, Time)
- DT DateTime.
- Time Longint,
.
PackTime . 132.

'

412

. , : Dos

.132. ProcPkTm.pas
program ProcpkTm;
uses Crt, Dos;
var
nf: string;
DT: DateTime;
Time: Longlnt;
F: File;
Y,Mo,D,DW,H,Mi,S,S100: Word;
begin
ClrScr; { }
Write(' : ');
Readln(nf);
Assign(F, nf); { }
{ )
GetDate(Y,Mo,D,DW);
GetTime(H,Mi,S,S100) ;
with DT do
begin
Year := Y;
Month := Mo;
Day := D;
Hour := H;
Min := Mi;
Sec := S;
end;
PackTime(DT,Time)
, { }
Reset(F);
{ F}
SetFTime(F,Time); { F}
Close(F);
{ F}
end.

ProcPkTm , ,
PAS, .

SetCBreak

<Ctrl+Break>.

DOS

: SetCBreak (Break)
Break Boolean.
True, <Ctrl+Break>
.
/ .
SetCBreak . 133.
.133. ProcSCBr .pas
program ProcSCBr;
uses Crt, Dos;
const

Randomize

413

.133
OffOn: array [Boolean] of String[4] = ('','');
var

Cb: Boolean;
begin
ClrScr; { }
GetCBreak(Cb);
WritelnC <Ctrl+Break>: ', OffOn[Cb]);
Cb := Not(Cb);
Writeln(' : ', OffOn[Cb]);
SetCBreak(Cb);
GetCBreak(Cb);
Writeln(; <Ctrl+Break>: ', OffOnfCb]);
ReadKey; ( - }
end.

Set Date
.
: SetDate(Year, Month, Day)
Year, Month Day Word, ,
.
SetDate . 134.
.134. ProcSDat.pas
program ProcSDat;
uses Crt, Dos;
var

Y,M,D: Word;
begin
ClrScr;
( }
Write(' : ');
Readln(Y);
Write(' : ');
Readln(M);
Write(' : ');
Readln(D);
SetDate(Y,M,D); ( }
end.

SetFAttr
.
: SetFAttr (F, A t t r )
- F .
Attr Word, .
Attr Dos: 1 Readonly ( ), 2
Hidden (), 4 System (), 8 VolumelD ( ), 16 Directory (), 32 Archive (), 63 AnyFile (
).
SetFAttr .135.

414

. , : Dos

.135. ProcSFAt .pas


program ProcSFAt;
uses Crt, Dos;
var
s: string;
F: File;
Attr: Word;
begin
ClrScr; { }
Write(' : ');
Readln(s);
Assign(F, s); { }
{ " " " "}
Attr := Readonly + Hidden;
Reset(F); { )
SetFAttr(F, Attr);
Close (F);- { )
end.
. PackTime.

SetFTime
.

*.

: S e t FT ime (F, ime)


- F .
Time Longint,
F .
DateTime PackTime.
SetFTime . 132 (<< .
, PackTime).

SetlntVec
.
: SetlntVec(IntNo, Vector)
IntNo Byte, .
Vector ().
SetlntVec .126 (
. , GetlntVec).

SetTime
.
: SetTime(Hour, Minute, Second, SeclOO)
Hour, Minute, Second SeclOO Word, , , .
SetTime .136.

Randomize

415

.136. ProcStTm.pas
program ProcStTm;
uses Crt, Dos;
var

H,M,S: Word;
begin
ClrScr; { }
Write(' : ');
Readln(H);
Write(' : ') ;
Readln(ty);
Write(' : ') ;
Readln(S);
SetTime(H,M,S,0) ; { }
end.

SetVerify
DOS .
: SetVerify ( V e r i f y )
V e r i f y Boolean,
: True .
SetVerify .137.
.137. ProcSVrf .pas
program ProcSVrf;
uses Crt, Dos;
const
OffOn: array [Boolean] of string[4] = ('', '');
var

v: Boolean;
begin
ClrScr; { }
GetVerify(V);
WriteLn(' : ', OffOn[V]);
V := not V ;

WriteLn(' ', OffOn[V]);


SetVerify(V);
GetVerify(V);
WriteLn(' : ', OffOn[V]);
ReadKey; { - }
end.

SwapVectors
SavelntXX, System,
.
: SwapVectprs
SwapVectors . 112 (<
. , DosExitCode).

416

. , : Graph

UnpackTime
Longlnt DateTime.
: UnpackTime (Time, DT)
Time Lungint, .
- DT DateTime,
.
UnpackTime . 125 (
. , GetFTime).

Graph
, , .
,
IniGraph.pas, .138.
.138. IniGraph.pas
unit IniGraph;
interface
uses Graph;
procedure Graphlnit;
implementation
procedure Graphlnit;
var
DriverVar, ModeVar, ErrorCode: integer;
begin
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar, '\tp\bgi');
ErrorCode := GraphResult;
if ErrorCode <> grOK then
begin,
Writeln(GraphErrorMsg(ErrorCode));
Halt(l) ;
end;
end;
end.

Graphlnit uses IniGraph,


IniGraph.tpu Unit directories
Directories (. . 1.4).
. " " .

Randomize

GetBkColor
0 15.
: GetBkColor
: Word.
GetBkColor .139.
.139. FuncGBkC.pas
program FuncGBkC;
uses Crt, Graph, IniGraph;
const
Colors: array[0..15] of String =
('','','','','',
'1,'','-','-',
1
-','-','-',
'-','-','','');
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { }
{ }
SetBkColor(Random(16));
{ }
SetColor(15-GetBkColor);
{ }
OutText(' - ' + Colors[GetBkColor]);
ReadKey; { - }
CloseGraph; { }
end.

GetColor
0 15.
: GetColor
: Word.
GetBkColor . 140.
.140. FuncGetC.pas
program FuncGetC;
uses Crt, Graph, IniGraph;
const
Colors: array[0..15] of String =
('','','','','',
'','','-','-'
1
-','-','-',
'-','-','','')
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { }

417

418

. , : Graph

.140
{ )
SetColor(Random(16));
{ }
SetBkColor(15-GetColor);
{ }
OutText(' - ' + Colors[GetColor]);
ReadKey; { - }
CloseGraph; { }
end.

GetDriverName
.
: GetDriverName
: String.
GetDriverName . 141.
.141. FuncGDrN.pas
program FuncGDrN;
uses Crt, Graph, IniGraph;
begin
Graphlnit; { IniGraph ( .138)}
OutText(GetDriverName); { }
ReadKey; { - }
CloseGraph; { }
end.

GetGraphMode
.
: GetGraphMode
: Integer.
GetGraphMode . 142.
.142. FuncGGrM.pas
program FuncGGrM;
uses Crt, Graph, IniGraph;
var
OldGrMode: Integer;
begin
Graphlnit; { IniGraph ( .138)}
OutText(' EGAHI');
ReadKey; { - }
OldGrMode := GetGraphMode;
SetGraphMode(0);
OutText(' EGALO');
ReadKey;
SetGraphMode(OldGrMode) ;
1
OutText(' EGAHI );

Randomize

419

.142
ReadKey;
CloseGraph; ( -}
end.

GetMaxColor
,
SetColor.
: GetMaxColor

.
: Word.

GetMaxColor . 143.
.143. FuncGMxC.pas
program FuncGMxC;
uses Crt, Graph, IniGraph;
(
const
Colors: array[0..15] of String =
('','','','','',
'','','-','-',
'-','-','-',
'-','-','','');
begin
Graphlnit; { IniGraph ( .138)}
OutText(' - '+Colors[GetMaxColor]);
ReadKey; { - }
CloseGraph; { }
end.

GetMaxMode
.
: GetMaxMode
: Integer.

GetMaxMode . 144.
.144. FuncGMxM.pas
program FuncGMxM;
uses Crt, Graph, IniGraph;
var
S: string;
begin
Graphlnit; { IniGraph ( .138)}
Str (GetMaxMode, s) ;
OutText(' - *+s);
ReadKey; { - }
CloseGraph; { }
end.

420

, , : Graph

GetMaxX
.
: GetMaxX
: Integer.
GetMaxX . 145.
.145. FuncGMxX.pas
program FuncGMxX;
uses Crt, Graph, IniGraph;
var
S: string;
begin
Graphlnit; { IniGraph ( .138)}
Str(GetMaxX,s);
OutText(' - '+s);
ReadKey; { - }
CloseGraph; { }
end.

GetMaxY
.
: GetMaxY
: Integer.
GetMaxY . 146.
.146. FuncGMxY.pas
program FuncGMxY;
uses Crt, Graph, IniGraph;
var
S: string;
begin
Graphlnit; { IniGraph ( .138)}
Str(GetMaxY,s);

OutText(' - '+s);
ReadKey; { - }
CloseGraph; { }
end.

GetModeName
.
: GetModeName (ModeNumber)
ModeNumber Integer, .
: String.
GetModeName . 147.

"

Randomize

421

.147. FuncGMdN.pas
program FuncGMdN;
uses Crt, Graph, IniGraph;
var
i: integer;
S: string;
begin
Graphlnit; { IniGraph ( .138)}
for i := 0 to GetMaxMode do
begin
Str(i,s);
MoveTo(l,i*20);
OutText(' '+s+' - '+GetModeName(i));
end;
ReadKey; {' - }
CloseGraph; ( )
end.

GetPaletteSize
.
: GetPaletteSize
: Integer.
GetPaletteSize . 148.
. 148. FuncGPSz .pas
program FuncGPSz;
uses Crt, Graph, IniGraph;
var
i: integer;
S: string;
begin
Graphlnit; { IniGraph ( .138)}
for i := 1 to GetPaletteSize do
begin
SetColor (i);
MoveTo(l,i*10);
LineTo(100,i*10);
end;
ReadKey; { - }
CloseGraph; { }
end.

GetPixel
.
: GetPixel (X, Y)
: Word.
GetPixel .149.

422

. , : Graph

.149. FuncGPix.pas
program FuncGPix;
uses Crt, Graph, IniGraph;
const
Colors: array[0..15] of String =
( ' ' , ' ' , ' ' , ' ' , ' ' ,
'' , '' , '-' , '-' ,
'-' , '-' , '-' ,
'-' , '-' , '' , '' ) ;
procedure DetectColor (Color : Byte);
begin
ClearDevice;
SetFillStyle (SolidFill, Color) ;
_ ,,
FillEllipse(100,50,30,23) ;
OutText (Colors [GetPixel (100 , 50) ] ) ;
ReadKey; { - }
end;

begin
Graphlnit; { IniGraph ( . 138)}
DetectColor (Blue) ;
DetectColor (Red) ;
CloseGraph; { }
end.

GetX
X .
: GetX
: Integer.
GetX . 150.
.150. FuncGetX.pas
program FuncGetX;
uses Crt, Graph, IniGraph;
var

i: integer;
S: string;
begin
Graphlnit;

{ IniGraph ( .138)}

for i := 1 to 5 do

begin
Str(GetX,S);
{ X S}
OutText(S+1 '); { X}
)
ReadKey;
{ - }
end;

CloseGraph;
end.

{ }

Randomize

423

GetY
Y .
: GetY
: Integer.
GetY . 1.51.
.151. FuncGetY.pas
program FuncGetY;
uses Crt, Graph, IniGraph;
var
i: integer;
S: string;
begin
Graphlnit;
{ IniGraph ( . 138)}
for i := 1 to 5 do
begin
MoveTo(1,i*10); {
(l,i*10)J
Str(GetY,S);
{ Y S}
OutText(S+' '); { Y}
}
{ - }
ReadKey;
end;
{ }
CloseGraph;
end.

GraphErrorMsg
.
: GraphErrorMsg.
: string.
GraphErrorMsg .152.
.152. FuncGrEM.pas
program FuncGrEM;
uses Crt, Graph;
var
DriverVar, ModeVar, ErrorCode: integer;
begin
DriverVar := EGA;
ModeVar := EGAHI;
InitGraph(DriverVar,ModeVar,'\tp\bgi'); {
}
ErrorCode := GraphResult; {
}
if ErrorCode <> grOK then
begin
Writeln(GraphErrorMsg(ErrorCode));
fjalt(l); { }
end else OutText(' ');

424

. , : Graph

.152
ReadKey; , { - }
CloseGraph; { }
end.
_
_

bgi InitGraph .
. " " .

GraphResult
.
: GraphResult
: Integer.
GraphResult .152 (^
. ).

ImageSize
, .
: ImageSize (XI, Y 1 , X 2 , Y 2 )
XI, Yl, X2, Y2 Integer,
.
: Word.

>

ImageSize .153.
.153. FundmgS.pas
program FuncImgS;
uses Crt, Graph, IniGraph;
var
P: Pointer;
Size: Word;
begin
Graphlnit; { IniGraph ( . 138)}
{ }
SetFillStyle(XHatchFill, Cyan);
Bar (0, 0, GetMaxX, GetMaxY) ;
{ }
Size := ImageSize (10,20,30, 40) ;
GetMem(P, Size);
{ }
{ }
A
GetImage(10,20,30,40,P ) ; {
}
ReadKey; { - }
Clear Device; { }
{ }
Putlmage (100, 100, PA,NormalPut) ; ,
ReadKey;

Randomize

425

.153
CloseGraph; { }
end.

FuncImgS . .8.

InstallUserFont
, BGI (Borland Graphical Interface).
: InstallUserFont(FontFileName)

. .8. (1) (2)


FontFileName String,,
.
: Integer. , SetTextstyle.

426

. , : Graph

InstalluserFont . 154.
.154. FunclnUF.pas
program FuncInUF;
uses Crt, Graph, IniGraph;
var
UserFont: Integer;
begin
UserFont := InstalluserFont('user.chr');
if GraphResult <> grOk then
begin
Writeln ( DefaultFont)');
Writeln(' ...');
ReadKey;
end;
Graphlnit; { IniGraph ( .138)}
SetTextStyle(UserFont, HorizDir, 2); { }
OutText(' "Turbo Pascal 7. ".
... ""');
ReadKey; { - }
CloseGraph; { }
end.

TextHeight
.
: TextHeight (TextString)
TextString String.
: Word.
TextHeight . 155.
.155. FuncTxtH. pas
program FuncTxtH;
uses Crt, Graph, IniGraph;
const
S = '';
var
Y, Size: Integer;
begin
Graphlnit; { IniGraph ( .138)}
Y := 0;
for Size := 1 to 5 do {, }
begin
{ , }
SetTextStyle(DefaultFont, HorizDir, Size);
{ (0,Y)}
OutTextXY(0, Y, S) ;
{ Y
}
Inc(Y, TextHeight(S));
end;
ReadKey; { - }

Arc

427

.155
CloseGraph; { }
end.
FuncTxtH . .9.

TextWidth
.
: TextWidth (TextString)
TextString String.
: Word.
TextWidth .156.
.156. FuncTxtW.pas
program FuncTxtW;
uses Crt, Graph, IniGraph;
const
S = '';
var
Row, Size: Integer;
begin
Graphlnit; { IniGraph ( .138)}
Row:=0;
Size:=l;
while TextWidth(S) < GetMaxX do { }
begin
{ }
{ (0,Row)}
OutTextXY(0, Row, S);
{ Y ( Row)
' }
Inc(Row, TextHeightCM' ) ) ;
Inc(Size); { 1}
{ , }
SetTextStyle(DefaultFont, HorizDir, Size);
end;
ReadKey; { - }
- CloseGraph; ( }
end.
FuncTxtW . . 10.


Arc
.

< ' - . ' ' '

...-.,'".'"

: A r c ( X , Y, StAngle, EndAngle, Radius)


X Y Integer, .

428

. , : Graph

181.....

. .9.

. .10.
FuncTxtW

StAngle EndAngle Word, ( ).


Radius Word, .
>
Arc . 157.
.157. ProcArc.pas
program ProcArc;
uses ,Crt, Graph, IniGraph;
begin

Graphlnit; { IniGraph ( .138)}


Arc(100,100,0,90,50); ( }
Arc(300,100,0,180,50); { }
Arc(500,100,0,360,50); { }
ReadKey; { - }
CloseGraph; { }
end.

,ProcArc . .11.

. .11'. ()

.
: (XI, Yl, 2 , Y 2 )
XI, Yl, X2 Y2 Integer,
(XI, Y1) (2, Y2) .
. 158.

429

.158. ProcBar.pas
program ProcBar;
uses Crt, Graph, IniGraph;
var
i: byte;
begin
Graphlnit; { IniGraph ( .138)}
for i := 0 to 15 do
begin
{ :
- I.
. }
SetFillStyle (SolidFill, i) ; { 0 15 . .1}
(, i*(GetMaxY div 16), GetMaxX, (i+1)*(GetMaxY div 16));
end;
ReadKey; { - }
CloseGraph; { }
end.
ProcBar . . 12.

. .1 2.

.
: 3D (XI, Y l , 2, Y 2 , Depth, Top)
XI, Yl, X2 Y2 Integer,
(XI, Y1) (2, Y2) .
Depth Word, .
Boolean, ,
.
. 159.

430

. , : Graph

.159. .pas
program ;
uses Crt, Graph, IniGraph;
var
i: byte;
begin
Graphlnit; { IniGraph ( .138)}
for i := 0 to 15 do
begin
{ :
I.
. }
SetFillStyle(SolidFill,i) ; { 0 15 . .1}
BarSD(i*(GetMaxX div 16), 10, i*(GetMaxX div 16)+20, 200, 5, True);
end;
ReadKey; { - }
CloseGraph; { }
end.
. . . 13.

. .13.

Circle
.
: C i r c l e ( X , Y, Radius)
X Y Integer,
.
Radius Word, .
circle . 160.
.160. ProcCrcl.pas
program ProcCrcl;
uses Crt, Graph, IniGraph;
var
i: byte;
begin
Graphlnit; { IniGraph ( . 138)}
Randomize; { )
for i := 1 to 10 do
begin

DrawPoly

431

.160
{ }
SetColor(l+Random(15));
( 10 )
Circle(Random(GetMaxX),Random(GetMaxY),Random(100));
end;

ReadKey; ( - }
CloseGraph; ( }
end.

ProcCrcl . . 14.

. .14.
DrawPoly
.
: DrawPoly(NumPoints, PolyPoints)
NumPoints Word, , PolyPoints. X Y.
- PolyPoint PointType, :
type
PointType = Record
X, Y: Integer;
end;

DrawPoly . 161.
.161. ProcDPol.pas
program ProcDPol;
uses Crt, Graph, IniGraph;
var

i: byte;

432

. , : Graptr

.161
Poly: array[1..5] of PointType;
begin
Graphlnit; { IniGraph ( .138))
Randomize; { }
{ }
for i := 1 to 5 do
begin
Polyti].X := Random(GetMaxX);
Poly[i].Y := Random(GetMaxY);
end;
DrawPoly(5, Poly);
ReadKey; { - }
CloseGraph; { }
end.

. . 15.

ProcDPol

Ellipse
.
:
,
Ellipse(X, Y, StAngle, EndAngle,
XRadius, YRadius)
X Y
Integer,
..15.

StAngle EndAngle Word,


.
XRadius YRadius Word,
X Y.
Ellipse .162.
.162. ProcElps. pas
program ProcElps;
uses Crt, Graph, IniGraph;
begin
Graphlnit; { IniGraph ( .138)}
{}
Ellipse(100,100,0,90,20,80);
Ellipse(300,100,0,180,20,80);
Ellipse(500,100,0,360,20,80);
Ellipse(100,220,0,90,80,20);
Ellipse(300,220,0,180,80,20);
Ellipse (500,220,0,36<J, 80,20) ;
{}
Ellipse(300,300,0,360,30,21) ;
ReadKey; { - }
CloseGraph; { }
end.

FillEllipse

433

ProcElps . . 16.

. .16.
FillEllipse
.
: FillEllipse(X, Y, XRadius, Y R a d i u s )
X Y Integer,
.
XRadius YRadius Word,
X Y.
FillEllipse .163.
.163. ProcFEll .pas
program ProcFEll;
uses Crt, Graph, IniGraph;
var
i: integer;
begin
Graphlnit; { IniGraph ( .138)}
for i : = 0 to 15 do
begin
{ :
I.
. }
SetFillStyle (SolidFill, i) ; { 0 15 . .1}
FillEllipse (IMGetMaxX div 16)+20,100,20,40);
end;
!
ReadKey; { - }
CloseGraph; { }
end.
ProcFEll .. .17.

434

. , : Graph

. .17.
FHIPoly
.
.

_,

: FillPoly(NumPoints, PolyPoints)
NumPoints Word, , PolyPoints. X Y.
- PolyPoint PointType, :
type
PointType = Record
X, Y: Integer;
end;
FillPoly . 164.
.164. ProcFPol. pas
program ProcFPol;
uses Crt, Graph, IniGraph;
var
i: byte;
Poly: array[1..5] of PointType;
begin
Graphlnit; ( IniGraph ( .138)}
Randomize; { }
{ }
for := 1 to 5 do
begin
Poly[i].X := Random(GetMaxX);
Poly[i].Y := Random(GetMaxY);
end;
SetFillStyle(SolidFill,Green); {
: .
,
( 0 5 )}
FillPoly(Random(6), Poly);
ReadKey; { - }
CloseGraph; { }
end.
ProcFPol . . 18.
FloodFill
.
:
FloodFillPoly(X, Y, Border)

Getlmage

435

X Y
Integer, .
Border
Word, ,
.

FloodFill . 165.

. .18.

.165. ProcFFil.pas
program ProcFFil;
uses Crt, Graph, IniGraph;
var
i: integer;
begin
Graphlnit; { IniGraph ( .138)}
SetColor(Red); { }
Circle(100,100,50); { }
SetColor(Yellow); { }
Circle(100,100,80); { }
{ :
}
SetFillStyle(SolidFill,Green) ;
ReadKey; { - }.
FloodFill(100,100,Red); { }
ReadKey;
FloodFill(100,100,Yellow); { }
ReadKey;
CloseGraph; { }
end.
ProcFFil . . 19.

""--

'-~^

. .19. (1) (2 3)

Getlmage
.
: Getlmage(XI, Yl, X2, Y2, BitMap)
XI, Yl, X2 Y2 Integer,
.
- BitMap - .
Get Image, . 153 (<< .
, ImageSize).

436

. , : Graph

Line
.
: Line (XI, Y l , 2, Y 2 )
XI, Yl, X2 Y2 Integer,
.
Line . 166.
.166. ProcLine.pas
program ProcLine;
uses Crt, Graph, IniGraph;
var

i: integer;
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { }
for i := 1 to 20 do
begin
{ }
SetColor(l+Random(15)) ;
{ 20 }
Line(Random(GetMaxX),Random(GetmaxY),
Random(GetMaxX),Random(GetmaxY));

end;
ReadKey;
CloseGraph; { }
end.
ProcLine . .20.

. .20.
LineRel
, .
: LineRel (DX, D Y )

LineTo

437

DX DY Integer, .
LineRel . 167.
.167. ProcLnRl.pas
program ProcLnRl;
uses Crt, Graph, IniGraph;
var

c: char;
begin
Graphlnit; { IniGraph ( .138)}
while True do
begin
{ - }
:= ReadKey;
case of
#27: Break; { Esc}
#72: LineRel(0,-10); { }
#75: LineRel(-10,0); { }
#77: LineRel(10,0); { }
#80: LineRel(0,10); { }
end;
end;

CloseGraph; { }
end.

ProcLnRl . .21.

. .21. , ProcLnRl
LineTo
.
: LineTo (X, Y)
X Y Integer,
.
LineTo . 168.
.168. ProcLnTo.pas
program ProcLnTo;
uses Crt, Graph, IniGraph;
var

: char;

438

. , : Graph

.168
NextX, NextY: Integer;
begin
Graphlnit; { IniGraph ( .138)}
NextX := 0;
NextY := 0;
while True do
begin
{ - }
:= ReadKey;
case of
#27: Break; { no Esc}
#72: Dec(NextY,10); { :
Y ( NextY) 10}
#75: Dec(NextX,10) ; { }
#77: Inc(NextX,10); { :
X ( NextX) 10}
#80: Inc(NextY,10); { }
end;
LineTo(NextX,NextY);
end;
CloseGraph; { }
end.
ProcLnTo . .21. ProcLnRl (
. 167).

MoveRel
.
: MoveRel (DX, DY)
DX DY Integer, .
MoveRel . 169.
.169. ProcMvRl. pas
program ProcMvRl;
uses Crt, Graph, IniGraph;
var
c: char;
^
begin
Graphlnit; { IniGraph ( .138)}
while True do
begin
{ - }
:= ReadKey;
case of
,
#27: Break; { Esc)
#72: begin { }
MoveRel(0,-5);
LineRel(0,-10);
end;

MoveTo

439

.169
#75: begin { }
MoveRel(-5,0) ;
LineRel(-10,0);
end;
#77: begin { )
MoveRel(5,0);
LineRel(10,0);
end;
#80: begin { }
MoveRel(0,5);
LineRel(0,10);
end;
end;
end;
CloseGraph; { }
end.
ProcLnTo . .22.
ProcLnRl ( . 167 . . 21).
MoveTo
.
: MoveTo (X, Y)
X Y Integer,
.
MoveTo . 170.
.170. ProcMvTo.pas
program ProcMvTo;
uses Crt, Graph, IniGraph;
var
i: integer;
begin
Graphlnit; { IniGraph ( .138)}
for i := 1 to 15 do { 15 }
begin
SetColor(i); { }
(44 . 0 15 . .1}
MoveTo(10,i*10); { }
LineRel(100,0); ( }
end;
ReadKey; { - }
CloseGraph; { }
end.
ProcMvTo . .23.
OutText
.
: OutText (TextString)
TextString String.

440

. , : Graph

_i ti.r_ii_._|i_.r~ji ._

i_l i

_ I p I p I I I | I

ii ii .|
|-fj
i .i
i|

. .22.
ProcLnTo

. .23. ""

OutText .171.
X

.171. ProcOutT.pas
program ProcOutT;
uses Crt, Graph, IniGraph;
var
: char;
begin
Graphlnit; { IniGraph ( .138)}
while True do
begin
{ - }
:= ReadKey;
if = #27 then Break { Esc}
else begin
OutText(); { )
{ }
if GetX > GetMaxX then
MoveTo(0,GetY+15); { }
end;
end;
CloseGraph; { }
end.
OutTextXY
.

: OutTextXY(X, Y, TextString)
X Y Integer,
.
TextString String.
OutTextXY . 172.
.172. ProcOTXY. pas
program ProcOTXY;
uses Crt, Graph, IniGraph;
var
c: char;
begin

PieSlice

441

.171
Graphlnit; { IniGraph ( .138)}
while True do
begin
{ - )
:= ReadKey;
if = #27 then Break { Esc}
else begin
OutTextXY(GetX,GetY,); ( }
MoveRel(10,0); { }
{ }
if GetX > GetMaxX then
MoveTo(0,GetY+15); { }
end;
end;
CloseGraph; { }
end.
PieSlice
.
: PieSlice(X, Y, StAngle, EndAngle, Radius)
X Y Integer,
.
StAngle EndAngle Word, .
Radius Word, , .
PieSlice . 173.
.173. ProcPieS.pas
program ProcPieS;
uses Crt, Graph, IniGraph;
begin
Graphlnit; { IniGraph ( .138)}
SetFillStyle(SolidFill,Blue); {
: }
PieSlice(100,100,0,90,50); { }
PieSlice(250,100,0,180,50); { }
PieSlice(400,100,0,360,50); { }
ReadKey; { - }
CloseGraph; { }
end.
ProcPieS . .24.

. .24.

442

. , : Graph

Putlmage
.
: Putlmage (X, Y, BitMap, BitBIt)
X Y Integer, , .
BitMap ,
.
BitBIt Word, .
BitBIt
Graph: 0 (NormalPut) ; 1 (XORPut) XOR; 2 (ORPut)
OR; 3 (ANDPut) AND; 4 (NOT Put)
NOT.
Putlmage . 174.
.174. ProcPImg. pas
program ProcPImg;
uses Crt, Graph, IniGraph;
var
P: Pointer;
Size: Word;
begin
Graphlnit; { IniGraph ( .138)}
{ }
SetFillStyle(XHatchFill, Cyan); {
: }
(, , GetMaxX, GetMaxY); {
}
{ }
Size := ImageSize (10,20,30,40);
GetMem(P, Size);
{ }
{ }
Getlmage(10,20,30,40,);
ReadKey; { - }
{ }
SetFillStyle(SolidFill, Yellow); {
: }
(, , GetMaxX, GetMaxY);
{ }
Putlmage(100,100,,NormalPut);
Putlmage(150,100,,XORPut);
Putlmage(200,100,,ORPut);
Putlmage(250,100,PA,ANDPut);
A
Putlmage(300,100,P ,NOTPut);
ReadKey;
CloseGraph; { }
end.
. MaxAvail.
ProcPImg . .25.

PutPixel

443

. .25. Put Image


BitBlt ( 0 4)
>
PutPixel
.
: PutPixel(X, Y, Color)
X Y Integer, .
Color Word, . Color Crt
(. . .1).
PutPixel .175.
.175. ProcPPxl .pas
program ProcPPxl;
uses Crt, Graph, IniGraph;
var

x,y: Word;
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { )
for := 1 to GetMaxX do
for :=*= 1 to GetMaxY do
PutPixel(,,Random(16)) ;
ReadKey; { - )
CloseGraph; { )
end.

ProcPPxl . .26.

. .26.

444

. , : Graph

Rectangle
.
: Rectangle (XI, Y l , X 2 , Y 2 )
XI, Yl, X2 Y2 Integer,
(XI, Y1) (2, Y2) .
Rectangle . 176.
.176. ProcRect.pas
program ProcRect;
uses Crt, Graph, IniGraph;
var

i: Byte;
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { )
for i := 1 to 10 do { 10 }
begin
SetColor(l+Random(15)); { }
(44 . 0 15 . .1)
Rectangle(Random(GetMaxX),Random(GetMaxY),
Random(GetMaxX),Random(GetMaxY))
;
end;
ReadKey; { - }
CloseGraph; ( }
end.

ProcRect . .27.

. .27.
Sector
.
: Sector(X, Y, StAngle, End&ngle, XRadius, YRadius)
X Y Integer,
.

ClearViewPort

445

StAngle EndAngle Word, .


XRadius YRadius Word,
.
Sector .177.
.177. ProcSect.pas
program ProcSect;
.uses Crt, Graph, IniGraph;
begin
Graphlnit; ( IniGraph ( . 138)}
SetFillStyle(SolidFill,Blue); {
: }
Sector(100,100,0,90,30,40); { }
Sector(250,100,0,180,30,40); { }
Sector(400,100,0,360,30,40); { }
ReadKey; { - }
CloseGraph; { }
end.
ProcSect . .28.

. .28.


ClearViewPort
.
: ClearViewPort
ClearViewPort .178.
.178. ProcClVP, pas
program ProcClVP;
uses Crt, Graph, IniGraph;
begin
Graphlnit; { IniGraph ( .138)}
{ }
Rectangle(19,19,GetMaxX-19,GetMaXY-19);
{ }
SetViewPort(20,20,GetMaxX-20,GetMaxY-20,True);
' OutTextXY(0, 0, ' , ');
ReadKey;
ClearViewPort;
ReadKey; ( - }

446

. , : Graph

.178
CloseGraph; ( }
end.
CloseGraph
.
: CloseGraph
CloseGraph .179.
.179. ProcClsG.pas
program ProcClsG;
uses Crt, Graph, IniGraph;
begin
Writeln ( ' ');
ReadKey;
Graphlnit; { IniGraph ( . 138)}
OutTextXY(0, 0, ' ');
ReadKey;
CloseGraph; { }
Writeln ( ' ');
ReadKey; { - }
end.
DetectGraph
,
.
: DetectGraph (GraphDriver, GraphMode)
DetectGraph . 180.
.1 80. ProcDetG.pas
program ProcDetG;
uses Crt, Graph;
var
DriverVar, ModeVar: integer;
begin
DetectGraph(DriverVar,Mode Var);
InitGraph(DriverVar,ModeVar,'\tp\bgi');
OutTextXYd, 1,' - ' + GetDriverName) ;
OutTextXY(1,10,' - ' + GetModeName(ModeVar));
ReadKey; { - }
CloseGraph; { }
end.

bgi initGraph .
. " " .

GetArcCoords

447

GetArcCoords
Arc.
: GetArcCoords (ArcCoords)
- ArcCoords ArcCoordsType,
Graph :
type
ArcCoordsType = Record
X, Y: Integer;
XStart, YStart: Integer;
XEnd, YEnd: Inte^fe::;
end;

: X Y ;
XStart YStart ;
XEnd YEnd ^ .
GetArcCoords . 181.
.181. ProcGtAC.pas
program ProcGtAC;
uses Crt, Graph, IniGraph;
var

ArcCoords: ArcCoordsType;
begin
Graphlnit; { IniGraph ( .138)}
Arc(100,100,0,270,75); ( }
GetArcCoords(ArcCoords) ;
with ArcCoords do
Line(XStart,YStart,XEnd,YEnd).; ( }
ReadKey; { - }
CloseGraph; { )
end.

ProcGtAC . .29.
GetAspectRatio
,
( ).
: GetAspectRatio(XAsp, YAsp)
- XAsp YAsp Word,
XAsp/YAsp.

tio .182.

GetAspectRa-

.182. ProcGtAR.pas
program ProcGtAR;
uses Crt, Graph, IniGraph;

. .29.


GetArcCoords

448

. , : Graph

.182
var

XAsp, YAsp: Word; ,


XAspS,YAspS,S: String;
begin
Graphlnit; { IniGraph ( .138)}
GetAspectRatio(XAsp,YAsp);
Str(XAsp,XAspS);
{ XAsp, Yasp }
Str(YAsp,YAspS);
{XAsp/Yasp XAspS ,YAspS,}
Str(XAsp/YAsp:5:2,S); {S, }
OutText(' = ' + XAspS + '/'/ + YAspS + ' = ' + S);
ReadKey; { - }
CloseGraph; { }
end.

GetDefaultPalette
, .
: GetDefaultPalette(Palette)
- Palette PaletteType, Graph :
const
MaxColors = 15;
type
PaletteType = Record
Size: Byte;
Colors: array[0..MaxColors] of Shortlnt;
end;

: Size ;'
Colors .
GetDefaultPalette
.183.
.183. ProcGtDP.pas
program ProcGtDP;
uses Crt, Graph, IniGraph;
var

i: integer;
MyPal, OldPal: PaletteType;
begin
Graphlnit; { IniGraph ( .138)}
GetDefaultPalette(OldPal); { }
MyPal:=OldPal;
{ }
{ }
for i := 0 to MyPal.Size - 1 do
begin
SetColor(i); { }
(H . 0 15 . .1}
OutTextXY(10, i*10, ' ');
end;
repeat
{ }

GetFillPattern

449

.183
with MyPal do
{ }
Colors[Random(Size)] := Random(Size+l);
SetAllPalette(MyPal); { }
until KeyPressed; { }
SetAllPalette(OldPal); { }
ReadKey; { - }
CloseGraph; { }
end.

GetFillPattern
.
: GetFillPattern(FillPattern)
- FillPattern FillPatternType, . Graph :
type
'FillPatternType = array[1..8] of Byte;

GetFillPattern

. 184.
.184. ProcGtFP.pas
program ProcGtFP;
uses Crt, Graph,- IniGraph;
const
GraySO: FillPatternType = ($AA, $55, $AA, $55, $AA, $55, $AA, $55);
var
OldPattern: FillPatternType;
begin
Graphlnit; { IniGraph ( .138)}
GetFillPattern(OldPattern);
{ }
SetFillPattern(GraySO, White); {
: (50%)}
(,,100,100); { }
ReadKey; { - }
{ )
SetFillPattern(OldPattern, White);
{ ( , $FF)}
Bar (, 0,100,100). ;
ReadKey;
CloseGraph; { }
end.

GetFHISettings
.
: GetFillSettings 1 (Fillln'fo)
- F i l l l n f o FillSettingsType, Graph :

450

. , : Graph

type
FillSettingsType = Record
Pattern: Word;
Color: Word/end;
: Pattern ;
Color .
GetFillSettings

. 185.
.185. ProcGtFS .pas
program ProcGtFS;
uses Crt, Graph, IniGraph;
var
Filllnfo: FillSettingsType;
begin
Graphlnit; { IniGraph ( .138)}
GetFillSettings(Filllnfo); { )
(,,100,100); { }
SetFillStyle(XHatchFill, GetMaxColor); {
:
)}
(100,0,200,100);
with Filllnfo do SetFillStyle(Pattern, Color);
{ }
Bar(200,0,300,100);
ReadKey; { - }
CloseGraph; { }

end.

ProcGtFS . ..

. .. (1) (3),
(2)
GetLineSettings
, .
: GetLineSettings (Linelnfo)
- Linelnfo LineSettingsType, Graph :
type
LineSettingsType
Record

GetModeRange

451

LineStyle: Word;
Pattern: Word;
Thickness: Word;
end;

: LineStyle ;
Pattern , LineStyle
UserBitLn (4);
Thickness .
GetLineSettings

. 186.
.
.
.
.186. ProcGtLS. pas
program ProcGtLS;
uses Crt, Graph, IniGraph;
var

OldStyle: LineSettingsType;
begin
Graphlnit; { IniGraph ( .138)}
Line(0,0,300,0); { }
GetLineSettings(OldStyle) ;
SetLineStyle(DottedLn, 0, ThickWidth); {
: }
Line(0,10,300,10);
{ }
with OldStyle do
SetLineStyle(LineStyle,Pattern,Thickness) ;
Line(0,20,300,20);
ReadKey; { - )
CloseGraph; { }
.

end.

"

ProcGtLS . .31.

. .31. (1) (3),


(2)
GetModeRange
.
: GetModeRange(GraphDriver, LoMode, HiMode)
GraphDriver Integer, ,
Graph: -128 CurrentDriver ( ); 1 CGA; 2 MCGA; 3 EGA; 4
EGA64; 5 EGAMono; 6 IBM8514; 7 HercMono; 8 400; 9 VGA; 10
PC3270.
- LoMode HiMode Integer, GraphDriver.

452

. , : Graph

GetModeRange . 187.
.187. ProcGtMR.pas
program ProcGtMR;
uses Crt, Graph, IniGraph;
var
Lowest, Highest: Integer;
S: string;
begin
Graphlnit; { IniGraph ( .138)}
GetModeRange(CurrentDriver, Lowest, Highest);
Str(Lowest,S); ( Lowest
s}
OutTextXY(l,1,' = ' + S) ;
Str(Highest,S);
OutTextXY(1,10,' = ' + S) ;
ReadKey; { - }
CloseGraph; { }
end.
GetPalette
.
: GetPalette (Palette)
- Palette PaletteType, Graph ;
const
MaxColors = 15;
type
PaletteType = Record
Size: Byte;
Colors: array[0..MaxColors] of Shortlnt;
end;
: Size ;
Colors .
GetPalette .188.
.188. ProcGtPa.pas
program ProcGtPa;
uses Crt, Graph, IniGraph;
var
Color: Word;
Palette: PaletteType;
begin
Graphlnit; { IniGraph ( . 1 3 8 ) }
GetPalette(Palette); { }
if Palette.Size <> 1 then
{ }
for Color := 0 to Pred(Palette.Size) do
begin { }

GetViewSettings

453

.188
SetColor (Color); { (44 .
0 15 . . 1 ) }
Line(0, Color*5, 300, Color*5); { }
end

else L i n e ( 0 , 0 , 3 0 0 , 0 ) ;
ReadKey; { - }
CloseGraph; { }
end.
ProcGtPa . .32.

. .32.
1
GetViewSettings
.
: GetViewSettings(ViewPort)
- ViewPort ViewPortType,
Graph :
type
ViewPortType = Record
XI, Yl: Integer;
X2, Y2: Integer;
Clip: Boolean;
end;
XI, Yl, X2, Y2 .
Clip , , ( True), ( False).
GetViewSettings .189.
.189. ProcGtVS .pas
program ProcGtVS;
uses Crt, Graph, IniGraph;
var
ViewPort: ViewPortType;
begin
Graphlnit; { IniGraph ( .138)}
GetViewSettings(ViewPort);
.with ViewPort do
begin
Rectangle(, , 2-1, Y2-Y1);
If Clip
then OutText(' ')

454

. , : Graph

.189
else OutText(' ');
end;

ReadKey; { - }
CloseGraph; ( }
end.

GraphDefaults
(0,0) .
:

GraphDefaults.

GraphDefaults . 190.
.190. ProcGDef .pas
program ProcGDef;
uses Crt, Graph, IniGraph;
var

Viewport: ViewPortType;
begin
Graphlnit; { IniGraph ( .138)}
SetColor(l); { (44 .
0 15 . .1)}
OutText(' ');
ReadKey; { - }
ClearViewPort; { }
GraphDefaults; { }
(
OutText(' ');
ReadKey;,
CloseGraph; { }
end. /
InitGraph
.
: InitGraph(GraphDriver, GraphMode, PathToDriver)
- GraphDriver GraphMode Integer, .
PathToDriver String, , (*.bgi).
, *.bgi .

InitGraph , , : CoordSys,
.1; IniGraph, . 138.
RestoreCRTMode
.
: RestoreCRTMode

SetActivePage

.191.

RestoreCRTMode

pecfae

455

.191. ProcRCRM.pas
program ProcRCRM;
uses Crt, Graph, IniGraph;
begin
Graphlnit; { IniGraph ( .138)}
OutText(' ');
ReadKey; { - }
RestoreCrtMode; { }
WriteLn(' ');
ReadKey;
SetGraphMode(GetGraphMode); { }
OutText(' ');
ReadKey;
CloseGraph; { }
end.

SetActivePage
.
: SetActivePage (Page)
Page Word, , ( 0).
SetActivePage . 192.
.192. ProcStAP.pas
program ProcStAP;
uses Crt, Graph, IniGraph;
begin
Graphlnit; { IniGraph ( .138)}
SetVisualPage(O); { - 1- }
SetActivePage(1); { - 2- }
{ }
Rectangle(10, 20, 30, 40);
SetVisualPage(1); { - 2- }
ReadKey; { - }
CloseGraph; { }
end.
SetAIIPalette
.
: SetAIIPalette (Palette)
Palette PaletteType,
Graph :
const
MaxColors = 15;
type
PaletteType = Record
Size: Byte;

456

. , : Graph

Colors: array[0..MaxColors] of Shortlnt;


end;
: Size ;
Colors .
SetAllPalette .193.
.193. ProcSAlP.pas
program ProcSAlP;
uses Crt, Graph, IniGraph;
var
i: integer;
MyPal, OldPal: PaletteTy_pe;
begin
Graphlnit; { IniGraph ( .138)}
GetDefaultPalette(OldPal); { )
MyPal:=OldPal;
{ }
{ }
for i := 0 to MyPal.Size - 1 do
begin
SetColor(i); { }
OutTextXY(10, i*10, ' ');
end;
repeat
{ }
with MyPal do
{ }
Colors[Random(Size)] := Random(Size+1);
SetAllPalette(MyPal); { }
until KeyPressed;
{ }
SetAllPalette(OldPal); { }
ReadKey; { - }
CloseGraph; { }
end.
SetAspectRatio
.
: SetAspectRatio (XAsp, YAsp)
XAsp YAsp Word, X A s p / Y a s p .

SetAspectRatio

. 194.
.194. ProcStAR.pas
program ProcStAR;
uses Crt, Graph, IniGraph;
var
XAsp, YAsp: Word;
S: String;
begin
Graphlnit; ( IniGraph ( .138)}

SetBkColor

457

.194
GetAspectRatio(XAsp, YAsp); {
}
if XAsp = YAsp then YAsp := 5*XAsp;
\
{ }
while Xasp < Yasp do {
}
begin
ClearDevice; { }
Str(XAsp,S); { XAsp
s}
OutTextXYfl,I,'XAsp = ' + S) ; {
}
Str(YAsp,S);
OutTextXY(l,15,'YAsp = ' + S);
{ }
SetAspectRatio(XAsp, YAsp);
{ ,
while }
Circle (GetMax}( div 2, GetMaxY div 2, 50);
Inc(XAsp, 100); { 100}
if ReadKey = #27 then Break; { - Esc}
end;
CloseGraph; { }
end.
SetBkColor
, .
: SetBkColor (ColorNum)
ColorNum Word, .
SetBkColor .195.
.15. ProcStBC.pas
program ProcStBC;
uses Crt, Graph, IniGraph;
var
i: Integer;
S: String;
begin
Graphlnit; { IniGraph ('.138)}
for i := 1 to 15 do
begin
SetBkColor(i); { ( 15 ) }
( }
if i=15 then SetColor(l) else SetColor (15-i); {4* .
0 15 . .1}
Str(i,S);
{ s}
ClearDevice; { }
OutText(S); { }
if ReadKey = #27 then Bi^ak; { Esc}
e
n
d
;
g
$
-

458

. , : Graph

. 195
CloseGraph; { }
end.
'
SetColor
.
: SetColor(ColorNum)
ColorNum Word, .
Crt,
. . 1 (<< . , TextBackGround).

SetColor , , . 170 ( . , MoveTo).
SetFHIPattern
.

: SetFillPatter(Pattern, Color)

Pattern FillPatternType, Graph :


type
FillPatternType = array[l.,8} of Byte;

Color Word, .
Crt,
. .1 ( .. , TextBackGround).

SetFillPattern ,
, .185 (44 . , GetFillSettings).
SetFillStyle
.
: SetFillStyle(Pattern, Color)
Pattern Word, . :
0 (EmptyFill) ;
1 (SolidFill) ;
2 (LineFill) ;
3 (LtSlashFill) "///";
4 (SlashFill) "///";
5 (BkSlashFill) "\\\";
6 (LtBkSlashFill) "\\\";
7 (HatchFill) ;
8 (XHatchFill) ;
9 (InterleaveFill) ;

SetGraphBufSize

459

10 (WideDotFill) ;
11 (CloseDotFill) ;
12 (UserFill) , .
Color Word, .
Crt,
. .1 ( . , TextBackGround).

SetFillstyle .196.
.196. ProcStFS. pas
program ProcStFS;
uses Crt, Graph, IniGraph;
var

i: byte;
'
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { }
for i := 1 to 15 do

begin
SetFillstyle(Random(13),i); {
}
(0, (i-D* (GetMaxY div 15), GetMaxX, i* (GetMaxY div 15));
end;
ReadKey; { '- }
CloseGraph; { }
end.

ProcStFS . ..

. .. ,
SetGraphBufSize
,
.

460

. , : Graph

: SetGraphBufSize (BufSize)
BufSize Word, .
SetBufSize . 197.
'.197. ProcStGS.pas
program ProcStGS;
uses Crt, Graph, IniGraph;
var
I, R: Integer;
BigPoly: array [0..1256] of PointType;
begin
Randomize; { }
{ 8, }
SetGraphBufSize(8*1024); { 1256- }
Graphlnit; { IniGraph ( .138)}
R := GetMaxY div 2;
{
1256- R}
for I := 0 to 1256 do
with BigPoly[I] do
begin
X := GetMaxX div 2 + Round(R * Sin(1/200));
Y :=^ GetMaxY div 2 + Round(R * Cos (1/200));
end;
{ }
SetFillStyle(HatchFill,Yellow) ; {
: }
FillPoly(SizeOf(BigPoly) div SizeOf(PointType), BigPoly);
ReadKey; { - }
CloseGraph; { }
end.
ProcStGS . .34.
SetGraphMode
.
: SetGraphMode (Mode)
Mode Integer,
.
.198. ProcStGM.pas
program FuncStGM;
uses Crt, Graph-, IniGraph;
var
OldGrMode: Integer;
begin
Graphlnit; { IniGraph ( .138)}
OutText(' EGAHI');
ReadKey; { - }
{ }
OldGrMode := GetGraphMode;
SetGraphMode(0);

SetLineStyle

461

.198
OutText(' EGALO');
ReadKey;
SetGraphMode (OldGrMode) ;
OutText(' EGAHI');
ReadKey;
CloseGraph; { }
end.
SetGraphMode .198.

. .34. 1256-

SetLineStyle

'^

.
: SetLineStyle(LineStyle, Pattern, Thickness)
LineStyle Word, .
, Graph:
0 (SolidLn) ;
1 (DottedLn) ;
2 (CenterLn) - ;
3 (DashedLn) ;
4 (UserBitLn) , .
Pattern Word, 16-
, LineStyle
UserBitLn.
Thickness Word,
. 1 (NormWidth), , 3 (ThickWidth), .
SetLineStyle . 199.

462

. , : Graph

.199. ProcStLS.pas
program ProcStLS;
uses Crt, Graph, IniGraph;
var
i: Integer;
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { }
for i := 1 to 20 do { 20 }
begin
{ }
SetLineStyle(Random(4),0,NormWidth);
{ , 44 . }
SetColor(Random(16));
{ 0 15 . .1}
Line (Random(GetMaxX) , Random(GetfMaxY) ,
Random(GetMaxX),Random(GetMaxY)); { }
end;
ReadKey; { - }
CloseGraph; { }
end.
ProcStLS . .35.

SetPalette
.

: SetPalette(ColorNum, Color)
ColorNum Word, , .
Color Shortlnt, . Crt, . . 1 ( . , TextBackGround).

. .35. 20

SetRGBPalette

463

SetPalette .200.
.200. ProcSetP.pas
program ProcSetP;
uses Crt, Graph, IniGraph;
var
i: integer;
begin
Graphlnit; ( IniGraph ( . 138)}
for i := 0 to 15 do ( 15 }
begin
( : }
SetFillStyle (SolidFill, i) ; ( i. H .
0 15 . .1.)
Bar3D(i*20+10, I, (i+l)*20, 200, 3, True); ( }
end;
, .
ReadKey; ( - }
( }
for i := 1 to 14 do SetPalette(i,15-i);
ReadKey;
CloseGraph; ( }
end.
ProcSetP . ..

II 11

. .36. (1)
,
'(2)
,
SetRGBPalette
VGA IBM8514.
:
SetRGBPalette(ColorNum, RedValue, GreenValue, BlueValue)
ColorNum Integer,
, ( VGA 0 15; IBM8514
255).
RedValue, GreenValue BlueValue Integer (
63), , .
SetRGBPalette .201.

464

. , : Graph

.201. ProcSRGB.pas
program ProcSRGB;
uses Crt, Graph, IniGraph;
var

x,y: integer;
begin
Graphlnit; ( IniGraph ( .138)}
Randomize; { }
{ }
for := 1 to GetMaxX do
for := 1 to GetMaxY do
PutPixel(x,y,Random(16));
ReadKey; { - }
repeat { }
SetRGBPalette(Random(16), Random(64),Random(64),Random(64));
until KeyPressed; { }
CloseGraph; { }
end.

ProcSRGB - .
.26 ( . , PutPixel), ( repeat. . .until) , .
SetTextJustify
.
: SetTextJustify(Horiz, V e r t )
Horiz Vert Word,
.
Horiz :
0 (Lef tText) ;
1 (CenterText) ;
2 (RightText) .
Vert :
0 (BottomText) ;
1 (CenterText) ;
2 (TopText) .

.202.
.202. ProcStTJ.pas
program ProcStTJ;
uses Crt, Graph, IniGraph;
var

i,j: byte;
a: array[1..3,1..3] of string;
begin
a[1,1]:='LeftSBottom';
a[1,2]:='Left&Center';
a[l,3]:='Left&Top';

SetTextJustify

SetTextStyle

465

.202
='Center&Bottom';
[2,2] ='CenterSCenter';
[2,3] ='Center&Top';
='Right&Bottom' ;
[ 3 , 2 ] ='Rlght&Center';
[3,3] ='Right&Top';
Graphlnit; { IniGraph ( .138)}
for i:= 0 to 2 do
for j := 0 to 2 do
begin
SetTextJustify(i,j);
OutTextXY((j+1)*120,(i+1)*20,a[i+l,j+1]);
end;
ReadKey; { - }
CloseGraph; { }
end.
ProcStTJ . .37.
LeftSBotton
CenterSBotton
RightSBotton

Left&Center

Cen t er&Cen t e r

R igh t*Center

Left&Top

CenterSTop

Right&Top

. .37.
&
SetTextStyle
, .
: SetTextStyle(Font, Direction, CharSize)
Font Word, (). : 0 (DefaultFont)
8x8; 1 (TriplexFont), 2 (SmallFont), 3 (SansSerifFont), 4 (GothicFont) .
Direction Word, .
:
0 (HorizDir) ;
1 (VertDir) .
CharCase Word, .
SetTextStyle .203.
.203. ProcStTS .pas
program ProcStTS;
uses Crt, Graph, IniGraph;
var
i,h,j: byte;
begin
Graphlnit; { IniGraph ( .138)}

466

. , : Graph

.203
for j:=0 to 1 do { }
begin
for i:= 0 to 4 do '{ ()}
for h := 1 to 3 do { }
begin
SetTextStyle(i,j,h);
{ }
OutTextXY(i*(140-j*100)+1,(h-j)*(20+50*j )+j ,'Junior');
end;

ReadKey; { - }
end;

CloseGraph; { }
end. "

ProcStTS . .38 .39.


Junior

Junior

StnttOT
3fumnr

Junior

Junior
Junior
Jun 1 0 rjunior

Junior
Junior

Simmr

. .38.
. 39,
, SetTextStyle 0 (DefaultFont),
,
1 (VertDir) .

'

SetUserCharSize
.
:
SetUserCharSize(MultX, DivX, MultY, DivY)
MultX, DivX, Mul.tY DivY Word,
(MultX/DivX)
(MultY/DivY) .

Size . 204.

SetUserChar-

. .39.

.204. ProcSUCS.pas
program ProcSUCS;
uses Crt, Graph, IniGraph;
begin
Graphlnit; { IniGraph ( .138)}
{ , }
SetTextStyle(TriplexFont, HorizDir, 4);
OutTextXYfl,1,'Junior'); { }

SetViewPort

467

.204
SetUserCharSize(1,2,1,1);
OutTextXY(130,1,'Junior'); { }
SetUserCharSize(2,1,1,1);
OutTextXY(200,1,'Junior'); { }
ReadKey; { - }
CloseGraph; { }
end.
^
ProcSUCS . .40.

Junior Junior
. .40.
SetViewPort
.
: SetViewPort (XI, Y l , X 2 , Y 2 , Clip)
XI, Yl, X2 Y2 Integer,
(XI, Y1) (2, Y2) .
Clip Boolean, ,
, ( True), (
False).
SetViewPort .205.
.205. ProcStVP . pas
program ProcStVP;
uses Crt, Graph, IniGraph;
const
VPWidth = 400; { )
VPHeight = 150; { )
var
i: byte;
procedure DrawLines(Clip: Boolean);
begin
ClearDevice; { }
{ }
SetViewPort(100,100,100+VFWidth,100+VPHeight,Clip);
{ }
Rectangle(0,0,VPWidth,VPHeight);
for i := 1 to 20 do
Line(Random(GetMaxX),Random(GetMaxY),
Random(GetMaxX),Random(GetMaxY));
ReadKey; { - }
end;
begin
Graphlnit; { IniGraph ( .138)}
Randomize; { }
DrawLines(True); { }

468

. , : Graph

.203
DrawLines(False); { }
CloseGraph;
( }
end.
ProcStVP . .41.

SetVisualPage
.
: SetVisualPage(Page)
Page Word, , ( 0).
SetVisualPage .192
( . , SetActivePage).

2
. .41. , (1),
(2)

SetVisualPage

469

Strings
Turbo Pascal
PChar , #0.

StrCat
.
: StrCat(Dest, Source)
Dest PChar, , PChar, Source. Dest
, Source.
: PChar.
~

'

'

StrCat .206.
.206. FuncSCat.pas
program FuncSCat;
uses Crt, Strings;
const
Header: PChar = ' "Turbo Pascal 7. "';
Author: PChar = ' .. ';
Publisher: PChar = ' ""';
var
S: array [0..75] of Char;
begin
ClrScr; { }
StrCopy(S,Header);
( Header S}
StrCat(S,'. ');
( S }
StrCat(S,Author);
( S Author}
StrCat(S,'. ');
( S }
StrCat(S,Publisher); ( S Publisher}
WriteLn(S);
ReadKey; ( - )
end.

StrComp
.
: StrComp(Strl, Str2)
Strl Str2 PChar.
: Integer.
0, Strl < Str2.
0, Strl = Str2.
0, Strl > Str2.
StrComp .207.

470

. , ; Strings

.207. FuncSCmp.pas
program FuncSCmp;
uses Crt, Strings;
var

c: integer;
Result: PChar;
S1,S2: array [0..79] of Char;
begin
ClrScr; { }
Write(' : ');
Readln(Sl);
Write(' : ');
Readln(S2);
:= StrComp(Sl,S2);
if < 0 then Result := ' , ' else
if > 0 then Result := ' , ' else
Result := ' ';
Writeln(SI,Result,S2);
ReadKey; { - }
end.

StrCopy
.
: StrCopy(Dest, Source)
Dest PChar, .
Source PChar, .
Dest ,
Source.
: PChar.
StrCopy .206 (<< .
, StrCat).

StrECopy
.
: StrECopy(Dest, Source)
Dest PChar, .
Source PChar, .
Dest ,
Source.
: PChar.
StrECopy .208.
.208. FuncSECp.pas
program FuncSECp;
uses Crt, Strings;
Const
Header: PChar =
"Turbo Pascal 7. " ' ;

SetVisualPage
.208
Author: PChar = ' .. ';
Publisher: PChar = ' ""';
var
S: array [0..75] of Char;
begin
ClrScr; { }
StrECopy(StrECopy(StrECopy(StrECopy(StrECopy(S,Header),
'. '),Author),'. ')publisher);
Writeln(S);
ReadKey; { - }
end.

StrEnd
# 0.
: StrEnd (Str)
Str PChar.
: PChar.
StrEnd .209.
.209. FuncSEnd. pas
program FuncSEnd;
uses Crt, Strings;
var
S: array [0..79] of Char;
begin
ClrScr; { }
Write(' : ');
Readln(S);
Write (' = ', StrEnd(S) - S, '' ');
ReadKey; { - }
end.

StrlComp
.
: StrlComp(Strl, Str2)
Strl Str2 PChar.
: Integer.
0, Strl < Str2.
0, Strl = Str2.
0, Strl > Str2.
StrlComp .210.
.210. FuncSICm.pas
program FuncSICm;
uses Crt, Strings;
var
>

471

472

. , : Strings

.210
S1,S2: array [0..79] of Char;
begin
ClrScr; { }
Write(' : ');
Readln(Sl);
StrCopy(S2,S1); ( SI 32}
StrUpper(S2); ( S2 }
if StrIComp(Sl,S2) = 0
then Writeln(Sl,' = ',S2)
else Writeln(Sl,' <> ',S2);
ReadKey; ( - }
end.

StrLCat
.
: StrLCat(Dest, Source)
Dest PChar, , PChar, Source. Dest
, Source.
: PChar.

'

StrLCat .211.
.211. FuncSLCt .pas
program FuncSLCt;
uses Crt, Strings;
var
S: array [0..70] of Char;
begin
ClrScr; ( }
StrLCopy(S, ' "Turbo Pascal 7.0 "', SizeOf(S) - 1);
StrLCat(S, '. ', SizeOf(S) - 1);
StrLCat(S, ' . . ', SizeOf(S) - 1);
StrLCat(S, '. ', SizeOf(S) - 1);
StrLCat(S, ' "1", SizeOf(S) - 1);
WriteLn(S);
ReadKey; ( - }
end.
FuncSLCt :
" "Turbo Pascal 7.0 ". . . . "".
- , s 70 , 75 .
StrLComp
.
: StrLComp(Strl, Str2, MaxLen)
Strl Str2 PChar.

SetVisualPage

473

MaxLen Word, ,
.
: Integer.
0, Strl < Str2.
0, Strl = Str2.
0, Strl > Str2.
StrLComp .212.
.212. FuncSLCrn.pas
program FuncSLCm;
uses Crt, Strings;
var

Result: PChar;
S1,S2: array [0..79] of Char;
begin
ClrScr; { }
Write(' : ');
Readln(Sl);
Write(' : ');
Readln(S2);
if StrLComp(SI,S2,5) = 0 then Result:=''
else Resuit:='';
WriteIn(' ', Result, '.');
ReadKey; { - )
end.

StrLCopy
.
: StrLCopy(Dest, Source, MaxLen)
Dest PChar, .
Source PChar, .
Dest ,
Source.
MaxLen Word,
.
: PChar.
StrLCopy .213.
.213. FuncSLCp.pas
program FuncSLCp;
uses Crt, Strings;
var

S: array [0..79] of Char;


begin
ClrScr; { }
StrLCopy(S, ' "Turbo Pascal 7.0 "1, 23);
Writeln(S);
ReadKey; { - }
end.

474

. , : Strings

StrLen
.
: StrLen (Str)
Str PChar.
: Word.

StrLen .214.
.214. FuncSLen. pas
program FuncSLen;
uses Crt, Strings;
var
S: array [0..79] of Char;
begin
ClrScr; { )
Write(' : ');
Readln(S);
Writeln(' - ',StrLen(S) ,' ');
ReadKey; { - }
end.

StrLIComp
.
: StrLIComp(Strl, Str2, MaxLen)
Strl Str2 PChar.
MaxLen Word, ,
.
: Integer.
0, Strl < Str2.
0, Strl = Str2.
0, Strl > Str2.
StrLIComp .215.
.215. FuncSLIC. pas
program FuncSLIC;
uses Crt, Strings;
var
Result: PChar;
S1,S2: array [0..79] of Char;
begin
ClrScr; { }
Write(' : ');
Readln(Sl);
Write(' : ');
Readln(S2);
StrUpper (32); { S2 }
if StrLIComp(SI,S2,5) = 0 then Resuit:=''
else Result:='';
Writeln(' ', Result, '.');

SetVisualPage

475

.215
ReadKey; { - }
end.

StrLower
.
: StrLower (Str)
Str PChar.
: PChar.

StrLower .216.
.216. FuncSLow.pas
program FuncSLow;
uses Crt, Strings;
var

S: array [0..79] of Char;


begin
ClrScr; { }
Write(' : ');
Readln(S);
StrLower(S);
Writeln(' : ');
Writeln(S);
ReadKey; { - }
end.

StrMove
.
: StrMove(Dest, Source, Count)
Dest PChar, .
Source PChar, .
Count Word,
.
: PChar.
StrMove .217.
.217. FuncSMov.pas
program FuncSMov;
uses Crt, Strings;
var

S1,S2: array [0..79] of Char;


begin
ClrScr; ( }
Write(' : ');
Readln(Sl);
StrMbve(S2,SI,StrLen(SI));
Writeln(S2);
ReadKey; { - }
end.

476

. , : Strings

StrNew
.
. MaxAvail.

: StrNew(Str)
Str PChar.
: PChar.
StrNew .218.
.218. FuncSNew.pas
program FuncSNew;
uses Crt, Strings;
var

P: PChar;
S: array [0..79] of Char;
begin
ClrScr;
( }
Write(' : ');
Readln(S);
P := StrNew(S);
Writeln(P);
StrDispose(P); ( , }
ReadKey; { - }
end.

StrPas
PChar string.
: StrPas (Str)
Str PChar.
: String.
StrPas .219.
.219. FuncSPas.pas
program FuncSPas;
uses Crt, Strings;
var

A: array [0..79] of Char;


S: String[79];
begin
ClrScr; { }
Write(' : ');
Readln(A);
S := StrPas(A) ;
Writeln(S);
ReadKey; ( - )
end.

SetVisualPage

477

StrPCopy
String PChar.
: StrPCopy (Dest, Source)
Dest PChar, .
Source String, .
: PChar.
StrPCopy .220.
.220. FuncSPCp.pas
program FuncSPCp;
uses Crt, Strings;
var
A: array [0..79] of Char;
S: String[79];
begin
ClrScr; { }
Write(' : ');
Readln(S);
StrPCopy(A,S);
Writeln(A);
ReadKey; { - }
end.

StrPos
.
: StrPos (Strl, Str2)
Strl Str2 PChar.
: PChar.
StrPos .221.
.221. FuncSPos.pas
program FuncSPos;
uses Crt, Strings;
\
var
P: PChar;
S, SubStr: array [0..79] of Char;
begin
ClrScr; { }
- Write(' : ');
Readln(S);
Write(' : ');
Readln<SubStr) ;
P := StrPos(S, SubStr);
if P = nil
then WriteLn(' .')
else WriteLn(' ', - S);
ReadKey; { - }
end.

478

. , : Strings

StrRScan
.
: StrRScan(Str, Chr)
>
Str PChar.
Chr Char,
: PChar.
StrRScan .222.
.222. FuncSRSc. pas
program FuncSRSc;
uses Crt, Strings;
var
P: PChar;
S: array [0..79] of Char;
begin <
ClrScr; { }
Write(' : ');
Readln(S);
P := StrRScan(S,' ');
if P = nil
then WriteLn(' f7
else WriteLn(' - "', +1, '"');
ReadKey; ( - }
end.

StrScan
.
: StrScan (Str, Chrf
Str PChar.
Chr Char, .
: PChar.
StrScan .223.
.223. FuncSScn.pas
program FuncSScn;
uses Crt, Strings;
var
P: PChar;
S,W: array [0..79] of Char;
begin
ClrScr; ( }
Write(' : ');
Readln(S);
P := StrScan(S,' ') ;
if P = nil
theh WriteLn(' ')
else WriteLn(' - "', StrLCopy(W,S,P-S), '"')

SetVisualPage

479

.223
ReadKey; { - }
end.

StrUpper
.
: StrUpper (Str)
Str PChar.
: PChar.
StrUpper .224.
.224. FuncSUpp.pas
program FuncSUpp;
uses Crt, Strings;
var

,t

S: array [0..79] of Char;


begin
ClrScr; { }
Write(' : ');
Readin(S);
StrUpper(S);
Writeln(' : ');
Writeln(S);
ReadKey; { - }
end.

StrDispose
, .
: StrDispose (Str)
Str PChar.
StrDispose .218 (4< .
, StrNew).


,
, .

Out of memory
Identifier expected

Unknown identifier

Duplicate identifier
**

Syntax error

6
7

Error in real constant


Error in
integer constant
String constant
exceeds line
Too many nested files
Unexpected
end of file
Line too long
Type
identifier expected
Too many open files
Invalid file name

.
.

.

.
, , ,
, , ,
.

8
9
10
11
12
13
14
15
16
17
18

File not found


Disk full
Invalid compiler directive
Too many files







.




.

481

19
Undefined type

in pointer definition
20
Variable

identifier expected
21
Error in type
.

22
Structure too large
.
65535
Set
base
. 23

type out of range
0 255
256

24
File components may

not be files or objects


Invalid string length
. 25

1 255
Type mismatch

26

27
Invalid
subrange base type
Lower bound greater

28
than upper bound
. , 29
Ordinal type expected
,


30
Integer
constant expected

Constant expected
31

32
Integer or real
constant expected
Pointer type

33
identifier expected
.
34
Invalid

function result type
,
Label identifier expected
35
BEGIN expected
begin
36
END expected
end
37
Integer
Integer
38
expression expected
. Ordinal
39

expression expected

482

3.

Boolean
Boolean
40
expression expected

41
Operand types do
not match operator

Error in expression
42

Illegal assignment
43
. 44
Field
identifier expected

. Turbo Pascal
45
Object file too large
. obj
64
. 46
Undefined external
public
.
47
Invalid
. obj
object file record
.
Code
48
65520
segment too large

Data
. 49

segment too large
65520 , ,
50
DO expected
do
Invalid PUBLIC definition public
51
52
Invalid EXTRN definition extrn
53
Too many
extrn. Turbo Pascal
EXTRN definition
. obj
256 extrn
54
OF expected
of
55
INTERFACE expected

56
Invalid

relocatable reference
57
THEN expected
then
58
TO or
to downto
DOWNTO expected
59
Undefined forward

61
Invalid typecast

62
Division by zero

63
Invalid file type

64
Cannot Read or Write

variables of this type

,
\

483

65
Pointer
-
variable expected
66
String variable expected
67
String

expression expected
68
Circular unit reference
.
interface

69
.
Unit name mismatch
, . tpu,
,
uses

70

Unit version mismatch


i

71

Internal stack overflow

72

Unit file format error

73

Implementation
expected
Constant and case
types do not match
Record
variable expected
Constant out of range
File variable expected
Pointer
expression expected
Integer or real
expression expected
Label not
within current block

74
75
76
77
78
79
80

83

Label already defined


Undefined
label "m processing
statement part
Invalid @ argument

84

Unit expected

81
82

.
,

.
-

.
. tpu
. implementation
case





real integer
. goto ,


@.
unit

484

3.

";"
85
";" expected
86
":" expected
":"
","
87
"," expected
88
"("
"(" expected
")"
89
")" expected
"="
;
"=" expected
91
":=" expected
":="
92
"[" "("
"[" or "(" expected
"]" ")"
93
"]" or ")" expected
"."
94
"." expected
".."
".." expected
95

96
Too many variables
97
Invalid FOR
control variable
for. for
,

Integer

98
variable expected

99
Files are
not allowed here
String
100
. length mismatch

101
Invalid ordering of fields .
102
String constant expected
Integer or
103
integer real
real variable expected
104
Ordinal

variable expected
105
INLINE error
inline
106
Character
expression expected

107
Too many
.
relocation items
. 64
108
Overflow in
. arithmetic operation

Longint (-2147483648.. .2147483647)
109
No enclosing
for, while
FOR, WHILE or
repeat. Break ConREPEAT statement
tinue
for, while repeat

485

112

CASE
constant out of range

113

Error in statement

114

Cannot call an
interrupt procedure

116

Must be in 8087
mode tp compile this

117

Target
address not found
Include files
are not allowed here

case . case -32768 32767


.

.

8087.
{$N+}

118

119

No inherited methods
are accessible here

121
122

Invalid qualifier
Invalid
variable reference

123

Too many symbols

124

Statement
part too large

126

Files must
be var parameters
Too many
conditional symbols
Misplaced
conditional directive

127
128

129

ENDIF
directive missing

130

Error in initial
conditional defines

.

. inherited
, ,


. ,

.
64

. Turbo
Pascal
24
-

. {$ELSE} {$ENDIF} {$IFDEF}, {$IFNDEF}
{$IFOPT}
{$ENDIF}.

{$IFxxx} {$ENDIF}

486

3.

Header
131
. , does not match

previous definition
forward,
. 132
Cannot evaluate
-
this expression

(
134
Expression
). Turbo Pascal
incorrectly terminated
,
,
(
Invalid format specifier
135
).

. 136
Invalid

indirect reference
137
Structured variable are
not allowed here

System (
138
Cannot evaluate without System unit
). , . tpl System

139
Cannot
access this symbol
( ).
,
.
(, ) ,

140
Invalid floating .
point operation

141
Cannot compile
overlay to memory
. , ,

142
Procedure
or function
.
variable expected
Assigned -
143
Invalid procedure

or function reference

487

144

Cannot overlay this unit

145

Too
many nested scopes

146

File access denied

147

Object type expected

148

Local object
type are not allows
VIRTUAL expected
Method
identifier expected
Virtual constructor are
not allowed
Constructor
identifier expected
Destructor
identifier expected
Fail only allowed within
constructors
Invalid combination of
opcode and operands

149
150
151
152
153
154
155

156
157

Memory
reference expected
Cannot
add or substract
relocatable symbols

158

Invalid
register combination

159

286/287 Instructions
not allowed

160

Invalid
symbol reference


.
, ^ {$0+}
. : uses,
, ,
with
.

.

virtual

.


Fail
.
.

. ,


.
[],
[], [SI], [Dl], [BX+SI], [BX+DI], [BP+SI] [BP+DI]
286/287 .

{$G+},
,
8086 8088
.

488

3.

161

Code generation error

162

ASM expected

163

Duplicate dynamic
method index

164

Duplicate
resource identifier

165

Duplicate or
invalid export index

166

Procedure or function
identifier expected

167

Cannot
export this symbol

168

Duplicate export name

169

Executable file
header too large

.
LOOPNE, LOOPE,
LOOP JCXZ,
asm
.


(
Windows ).
,


( Windows ). , Index, 1.. 32767,

( Windows ).
export
( Windows ). ,
export
(
Windows ). , name,

( Windows ). . 64
( )

Runtime error NNN at XXXX:YYYY


NNN , YYYY . , .

489

MS-DOS

Invalid function number

File not found


Path not found
Too many open files
File access denied
Invalid file handle
Invalid file access code
Invalid driver number
Cannot remove
current directory
Cannot
rename across drives
No more files

. DOS







3
4
5
6
12
15
16
17
18

-
{$!-} -
lOResult.

100
101
102
103
104
105
106

Disk read error


Disk write error
File not assigned

File not open


File not open for input
File not open for output
Invalid numeric format

150
151
152

Disk is write protected


Unknown unit
Drive not ready
Unknown command
CRC error in data





, CRC

153
154
155

Bad drive request


structure length

'

490

3.

156
Disk seek error
157
Unknown media type
158
Sector not found
159
Printer out of paper
160
Device write fault
161
Device read fualt
162
Hardware failure

200
201

Division by zero
Range check error

202
203

Stack overflow error


Heap overflow error

204

Invalid
pointer operation
Floating point overflow

205
206
207
208
209
210
211
212
213
214
215

216

Floating
point underflow
Invalid floating
point operation
Overlay
manager not installed
Overlay file read error
Object not initialized
Call to abstract method
Stream
registration error
Collection
index out of range
Collection
overflow error
Arithmetic
overflow error
General
protection fault










TCollection

TCollection
.
{$6+}
(
)

!, ! " ". ! Turbo Pascal 7.0. Micro


, piani Pascal i
!4 !. ! , , .
Micro ! , !
i . i Pascal is
1 .


i'

.-

"

Turbo Pascal 7.0


. .

. 05.09.2003. 70 100 1/16.


! . . .
. . . 19. .-. . 22,10.
2000 . . 100903

"", , 03142, . ', . , 35-37, . 111


./.: (044) 452-82-22; e-mail: office@junior.com.ua; http://www.junior.com.ua
' ! ,
i ! ! ! , 368 20.03.2001 .

!! " -1 '1
79054, . !, . , 92

. . , . .

' !
ISBN: 966-7323-27-7; : 400 ,, 1.; : 170x240 (70x100 1/16); ',

, !
, ! ' . ! ' , ! ! "'! i !"
" ". ! ! "'! !", ! 1
!, , !,
! .
i BCIM
CBOI ! ' . ! ! ,
! !, ' i ! !! ! '! !.

. . , . .

J -


ISBN: 966-7323-29-3; : 504 ., .; : 170x240 (70x100 1/16); ,


. , .
' ,
. - , :
, , ;

.
^
, .
" " ,
. ,
, . , .

..

. .
ISBN: 966-7323-31-5; : 384 ., .; : 36 .;
: 170x240 (70x100 1/16); , ( )


. .
,

.
..
.
.. ,
" . .

, ,

.
" , ", ,
, , .
" ", . . , JCTO , .

. . , . .


ISBN: 966-7323-32-3; : 704 ., .; : 170x240 (70x100 1/16); ,
,
, . , .

.
, , , IBM PC- .
\

. .

MicrosoftWindowsXP
.
ISBN: 966-7323-25-0; : 528 ., .; : 170x240 (70x100/16); ,

,
Windows XP, Internet,
, ,
. , ,

.
, , . ,
, ,
Internet, . Internet Explorer 6, Outlook
express 6, Messenger, Media Player, Movie Maker,
Windows XP.
Windows XP. , ,
Windows.

. .

HTML 4
ISBN: 966-7323-19-6; : 296 ., .; : 170x240 (70x100/16);

" HTML 4" ,


HTML-
HTML 4.01.
HTML HTML 4
.
W3C,
HTML-

: Microsoft
Internet Explorer 5.5, Natscape Navigator 6 Opera 5.02.

. .


Turbo Pascal 7.0
ISBN: 966-7323-22-6; : 216 ., .; : 170x240 (70x100/16); ,


. , , " ". , , .

.
, ,
,
, , . , - ^^^^^^^^^^^^
.
.

. .

Delphi 7
ISBN: 966-7323-28-5; : 384 ., .; : 170x240 (70x100/16);

-
. , ,
.

Delphi 7, : ,
SQL-.
,
, , .
,
,
.
, Object
Pascal, Delphi, , HTML.

?
?
?
?

"", !

. , ,
.


""
|

'

E-mail:

,i

/\ /\ /\ /\ /\
jl ^ ^--^ ^--^ ^--^

^__

^_ _J

Turbo Pascal 7.0


! " ^J

:
03142 . , . , 35, 111. ""
""

C/C++

Visual Basic
Visual
Delphi
Visual FoxPro

Web-:
JavaScript, Perl PHP
Windows Linux
Adobe PhotoShop Adobe Illustrator
3ds max

: edit@junior.com.ua
http://www.junior.com.ua; e-mail: sale@junior.com.ua; ./: (044) 452-82-22

Turbo Pascal 7.
.
Turbo Pascal 7.0.


Turbo Pascal: , , ; ; ;
;

,
: ; ; ,


, .


, : ""; ,
;

Turbo Pascal 7.0



,
,

, -
-,
Turbo Pascal
,
BIOS/DOS, 8x86
Pascal

Turbo Pascal Turbo Pascal
Turbo Pascal


, .
"Delphi 7
". 1996

.
Turbo Pascal
1991

http://www.yshpak.net
ISBN 966-7323-30-7

-
9"78 9 6 6 7 "3 2 3 3 0 1 ">

21

<Alt+N>, N . ,
Window | List.
Turbo Pascal, , Help,
,
<Alt+F3>.


(. . 1.1). .
, .

. ,
.
- .
.


Turbo
Pascal, .


File | Save ( <F2>) File | Save As. , . 1.3.

. 1.3.
Files () ,
, Save file as ( ) (, ProgOl.pas). <Enter>.
.


Options | Directories.
, . 1.4.

22

1. Turbo Pascal

nclude

directories

nit directories
|bject directories

. 1.4. Directories
,
Turbo Pascal .
EXE & TPU directory. . , . tpu.
Include directories. ,
. ";".
Unit directories. , . tpu. Turbo Pascal . . \UNITS.
Object directories. , , ( . ob'j
> 15.

& TPU directory , .


, .pas. , Directories, .


:
program
begin
end;

ProgOl;

{ }
(* *)
(* *)

ProgOl' Pascal, .
, . {. . .} ( * . . . * ) .
' ,
. . , , ,
.
,
. , program, begin end
, ProgOl , .
, , Options | Environment | Colors.

-I.!.-

23

.-,.::

ten

oreground

Compiler

Frame active
Desktop :
Frame icons :
Scroll bar page
, Dialogs
Editor
Scroll bar icons
Normal text
Help
,,,,
Selected text
Menus
Messages
Output |
Syntax
.

round

Text text; Text


Text Text Text
Cancel ,

Help

. 1.5. Colors
, , .
Pascal,
, .. : absolute, and, array, asm, begin, case,
const, constructor, div, go to, do, downto, destructor, else, end, exports,
external, ~file, for., forward, function, if, implementation, in, inline, interrupt, interface, inherited, label, library, mod, nil", not, or, of, object, packed, procedure, program, record, repeat, set, shl, shr, string,
then, to, type, unit, until, uses, var, while, with, xor.
ProgOl , , Pascal. program
. . , .pas, . Pascal , , P'rogOl PROG01 .

";". ( "."). : .
begin end.


( ) Compile | Compile,
<Alt+F9>, .
, (. 1.6).
, . , - ? , end
. ,
, (. 1.7).
3.

24

1. Turbo Pascal

File Edit Search Run Compile Debutr Tools Cations Window


4WOHKS,BOOKS4COriPUTER\iP4flPPSNPROG0i.PflS
=11 J=
program ProgQl;
beggrin
'
end.

Hain f i l e s \...\TP\ePI>SSPROG0i.PftS
Done.
Destination: Memory
Free rcenory: 311

Line number:
Total lines:

Hel

w
:

Compile successful: Press any key

1:16
Fl Help I Compile source file

. 1.6.
File

Edit

Run Conuile Debua Tools Qutions Window


SWORK\BOOKS\COMPUTEHMP\flPPS4PROG01. PflS
Error 1: Unexpected end of flie,
begin
yid

3:1

Search

Fl Help F2 Save

F3 Open ftlt+F9 Conwile

Hel

F9 Make ftlt+Fl Local menu

. 1.7.



, . Destination
() Compile.
Memory,
.
Destination Disk,
.. Destination Compile |
Destination.
end, Compile |
Destination . ,

25

. (. . 1.4) Prog01.exe. Turbo


Pascal Run | Run <Ctrl+F9>.

, Compile | Compile
<Alt+F9>,- , .
ProgOl , . ^ ", ",
. , Prog01
. ,
1.1.

, , . Turbo Pascal
, , . , .
. " " .

1.1. ProgOl .pas


program ProgOl;
begin

' '

Writeln(', ! ' ) ;

end.

, <ctrl+F9>.
, . ,
, . , Debug | User screen
<Alt+F5>.
.
ProgOl ,
Writeln(', ! ' ) ; .
Writeln. Pascal,
.
7, . , .
. , Writeln ,
, .


Help. ,
<F1>. - Help.

26

1. Turbo Pascal

( ), <Ctrl+Fl>.
- ,
, , . ,
W r i t e l n 1.1, <Ctrl+Fl>.
, Writeln
(. 1.8).
File

Edit

Search Run

Conolle

Debtw

Tools

Options

SUOHKSBOOKSXCOIIPUTERM'PNflPPSNPROGOl. PfiS

program ProgOl;
begin
r?=ti-l=

Hriteln<'ripH
end.

Help =

JF1 Help on help ftlt+Fl Preuious topic

Window Hel

=2=

SMft+Fl Help index

Esc Close help

. 1.8.



,
\TEMP4B3B7SDISK\81SPROG81.PflS has
Turbo Pascal
been modified. Save?
,
. , , ,
Information,
. 1.9. Information
. 1.9. ,
.
Information .pas.
Yes .pas.
, . Cancel () ,
.

Turbo Pascal
Turbo Pascal , :
File | Exit <Alt+x>.
Turbo Pascal

Вам также может понравиться