13
. Pascal. . .
.. 1
Pascal 2
System.. 2
Crt 2
Wincrt 2
Printer 2
Winprn. 2
Dos. 3
Windos. 3
Strings. 3
Graph. 3
Overlay. 3
Winapi 3
. 3
.. 4
. 4
. 4
. 4
. 6
. 8
. 8
. 9
. 9
. 10
- , . .
, . , - . , .
, ( ), " ". , . , ! , , , .
, , . , Pascal , .
Pascal
, Pascal. .
System
System : , , .. : .
, :
(dec, inc, odd, pred, succ);
;
(chr, ord, round, trunc);
(break, continue, exit, halt);
|
|
(concat, copy, delete, insert, length, pos, str, val);
;
(dispose, freemem, getmem, new);
(addr);
(, exclude, include, random, randomize, upcase).
Crt
Crt "" . .
Wincrt
WinCrt , .
Printer
Printer , ( DOS).
Winprn
WinPrn Printer Windows.
Dos
Dos . , , , , - Dos.
Windos
WinDos Dos Windows.
Strings
Strings Pascal , . , 255 , 65 535 , #0.
Graph
Graph , . , .
Overlay
Overlay ( ).
Winapi
WinApi . Pascal (, Turbo Pascal 7.0).
- , :
uses <_>;
, :
uses <__1>,...,<__N>;
, , . , . , , - . .
, , , , - , ( ) ( ) .
, abs(), , System, Pascal. , crt clrscr (. 14).
|
|
.
( , ):
unit <_>;
interface { }
implementation { }
begin { }
end.
.
(program <_>;), , (unit <_>;) .
, . , modul_1 modul_1.pas, ..
, , , .., .
- , , :
interface
[uses <__>;]
[const <__>;]
[type <___>;]
[var <__>;]
[procedure <__>;]
[function <__>;]
, : mod_const, , mod1, ( ):
unit mod_const;
interface
const sto = 100;
type one_to_sto = 1..sto;
...
unit mod1;
interface
uses mod_const;
const dvesti = 2*sto;
type massiv = array[1..dvesti] of byte;
var a: massiv;
b: one_to_sto;
function min(x,y:one_to_sto):one_to_sto;
...
. 13.1.
, -
uses mod1;
( ) massiv, a b, min. , sto ,
uses mod_const;
, , : :
<_>.<>
, . , .
, , . 13.1, :
program prg | uses A,B,C; | p | a.p | b.p | c.p | ||
unit A; | uses C,D,F; | p | c.p | d.p | f.p | ||
unit B; | uses F; | p | f.p | ||||
unit C; | ‑ | p | |||||
unit D; | ‑ | p | |||||
unit F; | ‑ |
: . ,
unit mod_1;
interface
|
|
uses mod_2;
...
unit mod_2;
interface
uses mod_1;
...
, . (. 9), . forward .
, ( ) , , , .
implementation
[uses <__>;]
[const <__>;]
[type <___>;]
[var <__>;]
[procedure <__>;]
[function <__>;]
[procedure <____>;]
[function <____>;]
, . , , , :
unit mod_1;
interface
...
implementation
uses mod_2;
...
unit mod_2;
interface
...
implementation
uses mod_1;
...
(, , ) .. .. " 7.0. . ". ( ) .
, message, mod_1, , ( _error mod_2) message - .
unit mod_1;
interface
procedure message(x,y: byte; msg: string);
implementation
uses mod_2, crt;
procedure message;
begin
if(x in [1..80-length(msg)] and (y in [1..25]) then begin
gotoxy(x,y); { }
write(msg)
end
else _error(' ')
{ mod_2}
end;
end.
unit mod_2;
interface
procedure _error(msg:string);
implementation
uses mod_1;
procedure _error;
begin message(1,25,msg); { mod_1}
end;
end.
, :
begin
<_>
end.
, :
( , ), , , .
( ), , uses.
: (. 12).
, . 13.1, , : C, D, F, A, B. , :
uses B,A,C;
|
|
: F, B, C, D, A.
: ( ), begin . end. .
, , .., , , . .
. 13.2.
.pas, - .tpu.
.
- ; , Compile | Compile ALT+F9. - ( .tpu ), . - , ( .pas, .tpu ), .
- Compile | Make ( F9) , , . , , , ( ).
- , Compile | Build, , .
, min max , . System.
unit my_arifm;
interface
function min(a,b: longint): longint;
function max(a,b: longint): longint;
function deg(a,b: double): double;
implementation
function min;
begin if a>b then min:= b
else min:= a;
end;
function max;
begin if a<b then max:= b
else max:= a;
end;
function deg;
begin deg:= exp(b*ln(a))
end;
end.
, , . (, tg, ctg, sec, arcsin, arcos, arctg, arcctg, arcsec) .
, , (, , ..), , , . " ".