(Integer, Boolean,Char...) - , Succ Pred. Real - .
. Type . "" .
: .
Type
Month = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
Var
M: Month;
- 256 , Byte.
, - , : Write(Ord(M)).
:
If (M > FEB) And (M < JUN) Then
Write (' ');
, . , - .
.
- , .
- , , .
- .
, . . . - , .
:
Type
Mas = Array [1..3] Of Array [1..5] Of Integer;
Var
A, B: Mas;
C: Array [1..3, 1..5] Of Integer;
{ }
Packed Array [0..N] of Char .
- , Char . 6 , .
- String Packed Array of Char.
Char:
'5' < '25' {, }
'Var' = 'Var' {}
Var
Age: String [3];
Begin
Age:=""; { "" }
.
:
Type
Symbolset = Set Of ' '.. '_';
Color = (White, Blue, Red);
Colorset = Set Of Color;
T1= Set Of 0..9;
Var
C: Color;
Colset: Colorset;
T: Integer;
Tset: T1;
- , - . -. - 256.
|
|
, , .
:
< > = Set Of < >, < > Word, Integer, Longint. (((:: =))). , ; [ ]. , - :
Type
Digitchar = Set Of '0'..'9';
Digit =Set Of 0..9;
Var
S1, S2, S3: Digitchar;
S4, S5, S6: Digit;
begin
................
S1: = ['1', '2', '3'];
S2: = ['3', '2', '1'];
S3: = ['2', '3'];
S4: = [0..3, 6];
S5: = [4, 5];
S6: = [3..9];
, :
(+)
(*)
(-) ( 1-, 2-).
in - , .
- .
, , . , (), .
:
Type
Date = Record
Year: Integer;
Month: 1..12;
Day: 1..31;
End;
Book = Record
Title: String [40];
Author: String [50];
Entry: Date;
End;
Var
D1: Date;
B: Book;
54. .
: <>: <> = < >
. ( ), , , . , . -, . -.
:
1. String:
Type
Colors = (White, Red, Black);
Const
{ }
Cyrrcol: Colrs = Red;
Name: String = '-';
Year: Word = 1989;
X: Real = 0.1;
Min: Integer = 0;
Max: Integer = 10;
Days: 1..31 = 1;
Answer: Char = 'Y';
2. -
, , :
Type
Colors = (White, Red, Black);
Const
Colstr: Arrray [Colors] Of String [5] = ('White', 'Red', 'Black');
Vector: Array [1..5] Of Byte = (0, 0, 0, 0, 0);
, - ,. - Char :
Const
Digit: Array [0..9] Of Char = ('0','1','2','3','4','5','6','7','8','9');
Digchr: Aray [0..9] Of Char = ('0123456789');
3. -.
<>:<> = (< >)
<> - .
< > - : , ; .
|
|
:
Type
Point = Record
X,Y: Real;
End;
Vect = Array [0..1] Of Point;
Month = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
Date = Record
D: 1..31;
M: Month;
Y: 1900..1999;
End;
Const
Orign: Point = (X: 0; Y: -1);
Line: Vector = ((X: -3.1; Y: 1.5), (X: 5.9; Y: 3.0));
Someday: Date = (D: 16; M: Mar; Y: 1989);
4. .
:
Type
Days = Set Of 1..31;
Dige = Set Of '0'..'9';
Error = Set Of 1..24;
Const
Workdays: Days = [1..5, 8..12, 15..19, 22..26, 29, 30];
Evendigits: Dige = ['0', '2', '4', '6', '8'];
Errorflag: Error = [ ];
5. .
Nil:
Const
Pr: ^Real = Nil;
P: POINTER = Nil;
55. .
,
.
- .
- .
, - .
( -), .
- , .
Ord, Trunc, Round, Chr, Ptr ( -).
() , , ( ). , :
Type Mytype = (A, B, C, D);
.................
Mytype (2);
Integer (D);
Pointer (Longint (A) + $FF);
Char (127 Mod C);
Byte (K);
( ).
- : , , , . , :
Type
Byt = Array [1..2] Of Byte;
Int = Array [1..2] Of Integer;
Rec = Record
X: Integer;
Y: Integer;
End;
Var
VByt: Byt;
VInt: Int;
VRec: Rec;
Begin
Byt (VInt[1])[2]:= 0;
Int (VRec)[1]:= 256;
End.
:
, .
, , , ( Absolute - , ).
- , - - , - .
:
B: Byte Absolute $0000:$0055;
W: Longint Absolute 128:0;
Absolute , , :
Var
X: Real;
Y: Array [1..3] Of Integer Absolute X;
|
|
56. . .
- -, .
. , , . () , .
: .
:
Procedure InCorrect (Var A: Array [1..10] of Byte);
:
Type
MyArray = Array [1..10] of Byte;
Procedure Correct (Var A: MyArray);
:
a. , Var ;
b. , Var ;
c. Var .
a - ; b - ; c - (b, c - -).
- .
. - . . .
- .
. , . Var - . ( ) , :
Procedure Swap (Var X,Y: Real);
Var
T: Real;
Begin
T:= X;
X:= Y;
Y:= T;
End;
- .
.
Var Ident, Ident - .
, , ( ).
.
57. .
- , . , ( , , ).
{$F+}
Var
P: Procedure;
. :
Type
Func = Function(X,Y: Integer): Integer;
Var
F1,F2: Func;
, :
Function Add(A,B: Integer): Integer;
Begin
Add:= A + B;
End;
F1:= Add, F1 Add , . :
Write (Add (1,2)) Write (F1 (1,2));.
{$F+} , , , , .
, , . ( ).
|
|
F1:= F2;
, .
:
Var
Oper: Function(X, Y: Real): Real;
Function Add(A,B: Real): Real;
Begin
Add:= A + B;
End;
Function Sub (A,B: Real): Real;
Begin
Sub:= A - B;
End;
, , , . , .
. , :
Type
Proc = Procedure(T: Real);
Notice = Record
Next: Integer;
Time: Real;
Action: Proc;
End;
Var
New_Notices: Array[1..10] of Proc;
Notices: Notice;
.
- , .
, , . :
, , .
- , , (interrupt inline).
, . , , - . .
, , .
F () FFF :
If @F = @FFF then....
:
@@F
.
:
Type
Func:= Function(X: Integer): Integer;
Function MyFunc(X: Integer): Integer;
Begin
MyFunc:= X;
End;
Var
F: Func;
P: Pointer;
N: Integer;
:
F:= MyFunc | { F MyFunc} |
N:= F(N) | { MyFunc F} |
P:= @F | {P MyFunc} |
N:= Func (P)(N) | { MyFunc P} |
F:= Func (P) | { P F} |
Func(P):= F | { F P} |
@F:= P | { P F} |
58. .
:
Unit < >;
Interface
< >
Implementation
< >
[ Begin < > ]
End.
:
Unit - (. ); ;
<> - ( );
Interface - , ;
Implementation - (. ); ;
Begin - , ;
( Begin < > );
End. - .