TurboPascal v. 7.0

1. . .

1.1.

1.2. ()

1.3. ()

1.4. USES ( )

2.

2.1. ()

2.1.1. ()

2.1.2. CONST ( )

2.2.

2.2.1. TYPE ( )

2.2.2. VAR ( )

2.2.3.

2.2.3.1.

2.2.3.2. ( )

2.2.3.3. ()

2.2.3.4. ۻ

2.2.3.5. ߻

2.2.4.

2.2.5. .

2.3.

2.3.1.

2.3.2.

2.3.3.

3. ( )

 

4.

4.1.

4.1.1.

4.1.2.

4.2.

4.2.1.

4.2.2.

4.2.3.

4.2.4. ( )

4.2.5. ( )

4.3.

4.3.1.

4.3.2.

5.

5.1.

5.2.

6.

6.1.

6.2. ()

6.3.

6.4.

6.5.

6.6.

6.7. . .

7.

7.1

7.2.

7.2.1.

7.2.2.

8.

 

9. .

9.1. ( )

9.2.

9.3.

10.

10.1.

10.1.1. . -

10.1.2. . .

10.1.3. . .

10.1.4.

10.2.

11. DOS - BGI

11.1. (GRAPH)

11.2.

 

1. . .

1.1.

{ }

PROGRAM ;

{------- ------------}

uses .................

const .................

type .................

var .................

procedure .................

function .................

{------- ------------}

BEGIN

.......................................

.......................................

.......................................

END.

 

1.2. ()

:

: a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z.

: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

: [ _ ].

() () : abc ABC . _ . 1 127 . 63 : (!).

1.3. ()

{}. .

1.4. USES ( )

uses --1, --2, --3, ... --n;

(unit) - , , .

 

2.

2.1. ()

2.1.1. ()

10 +100 -200
10.0 +100.25 -2.5e+12
$10 $1A00 $2BC2
() A 1 #255
ABC - 850 $ 10 000
[ 1, 2, 3 ] [ a, b, c ] [ a .. z ]

 

2.1.2. CONST ( )

const - = ; [...]

 

2.2.

2.2.1. TYPE ( )

type - = -; [...]

2.2.2. VAR ( )

var --1, --2, ... --n: ; [...]

2.2.3.

2.2.3.1.

()
Integer 2 () -32768 +32767
Shortint 1 () -128 +127
Longint 4 () -2147483648 +2147483647
Byte 1 (/.) 0 255
Word 2 (/.) 0 65535

 

2.2.3.2. ( )

()
Char 1 256 ()

 

2.2.3.3. ()

()
Boolean 1 2 true, false

 

2.2.3.4. ۻ

type - = -- .. --;

2.2.3.5. ߻

type - = (1, 2, ... -n);

2.2.4.

()
Real 6 11
Single 4 7 {$N+}
Double 8 15 {$N+}
Extended 10 19 {$N+}
Comp 8 19 (.,64-bit) {$N+}

 

2.2.5. .

( )

const -: = ; [...]

2.3.

2.3.1.

- : = ;

2.3.2.

A b A + b a B a - b a b a * b a b a / b
10 20 30 20 10 10 10 20 200 20 10 2
10 -20 -10 20 -10 30 2.5 2.5 6.25 10 20 0.5

 

()
a B a div b a b a mod b a b a shl b a b a shr b
10 20 0 10 20 10 10 2 40 10 1 5
40 15 2 40 15 10 32 1 64 32 2 8

 

2.3.3.

( )

Not And or xor
A not a a b a and b a b a or b a b a xor b
False True false false False false false false false false false
true False false true False false true true false true true
    true false False true false true true false true
    true true true true true true true true false

 

( )

a = b
A <> b
a < b
A <= b ( )
a > b
A >= b ( )

 

3. ( )

()
read(-) () read(a, b, c)  
Readln(-) , readln(a, b, c)  
Write(-) () write(n = ,n:10)

write(n = ,n:p:q)

p,q: -
Writeln() , writeln(?:s+2)

writeln(:spaces)

s,spaces: -

-

Clrscr ( ) clrscr crt
Textcolor() textcolor(magenta) crt
Textbackground() textbackground(0) crt
Window(x1,y1,x2,y2) (x1,y1)-(x2,y2) window(1,1,40,10) crt
Wherex x - x := wherex crt
Wherey y - y := wherey crt
Gotoxy(x,y) (x, y);

x - [1..80];

y - [1..25];

gotoxy(40,10)

gotoxy(50,wherey)

crt

- ( crt)

( ) ( )
0 Black 8 DarkGray
1 Blue 9 LightBlue
2 Green 10 LightGreen
3 Cyan 11 LightCyan
4 Red 12 LightRed
5 Magenta 13 LightMagenta
6 Brown 14 Yellow
7 LightGray 15 White

 

4.

4.1.

4.1.1.

procedure ([var] -1, -2, ... -n: ; [...]);

{}

begin

{} ...

end;

 

4.1.2.

function ([var] -1, -2, ... -n: ; [...]): ;

{}

begin

{} ...

:= ; ...

{}

end;

 

4.2.

4.2.1.

if - then -1 [ else -2 ]

 

4.2.2.

case --integer,word,char,byte of

: ;

-1 .. -2 : ;

-1, -2 .. -3 :

[ else ]

end

 

4.2.3.

for - := -1 to -2 do

for - := -1 downto -2 do

4.2.4. ( )

while - do

 

4.2.5. ( )

repeat

-1; -2; ... -n

until -

 

4.3.

4.3.1.

sound() ; - ()
nosound

 

4.3.2.

halt()

, - ( )

exit

break

readkey

;

- ();

.

delay()

;

- ( ())

1 . = 1 / 1000 .

, ( sound(n))

( ) ( )
262 523
294 587
330 659
349 698
392 785
440 880
494 988
523 1047

 

5.

5.1.

abs() . abs(-3.5) +3.5
arctan(-) arctan(0) 0
cos() (.) cos(pi) -1
exp() exp(1) 2.718281828...
frac() frac(3.5) 0.5
int() int(3.5) 3.0
ln() . ln(2.718281828) ~1.0
odd() odd(3) True
pi pi 3.141592...
random() random(10) [0;10]
sin() (.) sin(pi) 0
sqr() sqr(2.0) 4.0
sqrt() sqrt(25.0) 5.0

 

5.2.

inc() 1 inc(n) n := n + 1
dec() 1 dec(n) n := n - 1

 

6.

6.1.

(s[0]= , 0<=s[0]<=255)

s[0] s[1] s[2] s[3] s[4] .... s[n]

var -: string; { <= 255 }

var -: string [ -- ];

 

6.2. ()

:= -1 + -2 + ... + -n;

6.3.

: a[1..n]

a[1] a[2] a[3] a[4] a[5] ... a[n]

: a[1..m,1..n]

a[1,1] a[1,2] a[1,3] a[1,4] a[1,5] ... ... ... ... a[1,n]
a[2,1] a[2,2] a[2,3] a[2,4] a[2,5] ... ... ... ... a[2,n]
a[3,1] a[3,2] a[3,3] a[3,4] a[3,5] ... ... ... ... a[3,n]
... ... ... ... ... ... ... ... ...  
a[m,1] a[m,2] a[m,3] a[m,4] a[m,5] ... ... ... ... a[m,n]

type - = array [--1,--2, ... --n]

of -;

6.4.

( <=256, 0..255)

0 1 2 3 4 ... 255
1 1 0 1 0 ... 0

type - = set of -;

 

6.5.

X A X in A A B A+B A B A-B A B A*B
0 [1,2] false [1] [1,2] [1,2] [1,2] [2] [1] [1,2] [2,3] [2]
1 [1,2] true [2] [3] [2,3] [1,2] [3] [1,2] [1,2] [3,4] [ ]

 

6.6.

R1 R2 R3 ... Rn

type - = record

: -1;

: -2

end;

 

6.7. . .

type mas_of_strings = array [1..n] of string;

var x: mas_of_strings;

x[ i ]

x[ i, j ]

 

type data = record nomer: integer; name, adres: string [20] end;

 

var x: data;

x.name

x.name[ i ]

 

type data = record nomer: integer; name, adres: string [40] end;

 

type mas_of_records = array [1..n] of data;

 

var x: mas_of_records;

x[i].name

x[i].name[j]

 

type mas_of_records = array [1..n] of byte;

 

type data = record nomer:integer; n:string; rates: mas_of_records end;

 

var x: data;

x.n[i]

x.rates[j]

 

7.

7.1

chr(--n) n (#n) chr(33) !
ord() () ord(!) 33
succ() succ(y) z
pred() pred(y) x

 

7.2.

7.2.1.

copy(s,p,n)

n s p

copy(,3,2)

concat(s1,s2,...sn)

() ()

concat(,)

length()

[.]

length()

4

pos(s1,s2)

s1 s2

( , 0)

pos(,)

3

 

7.2.2.

delete(s,p,n) n s p delete(,1,2)
insert(s1,s2,p) () s1 s2 p insert(,,1)

 

8.

()
round() n := round(3.5) 4
trunc() n := trunc(3.5) 3
str(n:p:q,s) n

s

str(3.5:3,s) s = 3.5
val(s,n,p) s () n val(+3.5,n,p) n = 3.5; p = 0

p=

 

9. .

9.1. ( )

1. ............................ var f: text;

2. ................... var f: file of -;

3. ............... var f: file;

.

- (input, output).

- lst ( printer).

 

9.2.

assign(file,)

assign(f, a:text)

assign(f, path)

close(file)

close(f)

reset(file [,-.])

reset(f)

rewrite(file [,-.])

rewrite(f, 1)

append(file)

append(f)

Text

read(file,)

read(f, mydata)

readln(file,)

,

readln(f, a, b, c)

Text

write(file,)

write(f, mydata)

writeln(file,)

,

writeln(f, a:10:2)

Text

blockread(f,,n,

)

n ,

-=

blockread(f,a,50,p)

File

blockwrite(f,,n,

)

n -=

blockwrite(f,a,50,p)

File

seek(file,)

[0;n], n=

seek(f, 0)

text

 

9.3.

eof(file) if eof(f) then ... [true; false]
eoln(file) if eoln(f) then ... [true; false]
filepos(file) if filepos(f) > 0 then ... [0;n]
filesize(file) [ ] seek(f, filesize(f)) [0;n]
ioresult - ({$I-}) if ioresult = 0 then ... [0;n]

 

10.

10.1.

10.1.1. . -

type - = ^-;

var -: -;

10.1.2. . .

- - ()
P ^ P
Q @ Q

 

10.1.3. . .

type pstring = ^string;

var a: array [1..1000] of pstring; ....

new(a[1]); readln(a[1]^);

writeln(1=, a[1]^[1]);

 

10.1.4.

new() new(s) s^
dispose() dispose(a[i]) a[i]^

 

10.2.

()

sizeof()

[]

sn := sizeof(n)

{n - integer}

sn = 2

fillchar(a,n,d)

n

a d

(d: char byte)

fillchar(a,sizeof(a),0)

{a - integer}

move(a,b,n)

n

a

b

move(a, b, sizeof(a))

{a b - }

( -

)

 

11. DOS - BGI

11.1. (GRAPH)

: uses graph, crt;

11.2.

()

d := detect

- ( )

d := detect

d = (bgi)

(integer)

initgraph(d, m, -bgi)

-

initgraph(d, m,

c:\bgi)

m = (vga) (integer)

cleardevice

cleardevice

 

setcolor()

()

setcolor(magenta)

 

setbkcolor()

()

setbkcolor(0)

 

putpixel(x,y,)

(x,y)

putpixel(5, 5, red)

 

line(x1,y1,x2,y2)

(x1,y1)-(x2,y2)

line(10,10,20,200)

 

lineto(x,y)

(x,y)

lineto(100,200)

 

moveto(x,y)

(x,y)

moveto(nx, ny)

 

circle(x,y,)

(x,y,r)

circle(x, y, 20)

 

arc(x,y,1,2,)

(x,y,r) 1 2 ()

arc(10,10,0,pi,5)

 

setfillstyle(s,-)

setfillstyle(1,green)

 

floodfill(x,y,)

()

floodfill(p,q, 10)

 

rectangle(x1,y1,x2,y2)

(x1,y1)-(x2,y2)

rectangle(2,2,5,10)

 

bar(x1,y1,x2,y2)

(x1,y1)-(x2,y2)

bar(2, 2, m, n)

 

bar3d(x1,y1,x2,y2,z,n)

3- - ()

(x1,y1)-(x2,y2)

bar3d(2,2,20,20,

10,true)

z =

n = boolean

true =

x := getmaxx

. x

mx := getmaxx

0..639 (vga)

y := getmaxy

. y

my := getmaxy

0..479 (vga)

closegraph

closegraph

 

 

( 7.0.) - , , , ..

, . .

, . , . , - 10 ! , - , .

| | |