Object Pascal Borland Pascal .
, Borland scal, Delphi . , Pascal. , .
: Integer, Cardinal, ShortInt, SmallInt, LongInt, Int64, Byte, Word, LongWord, Real, Real48, Single, Double, Extended, Comp, Currency. Integer Real .
Char. AnsiChar WideChar ANSI Unicode.
Delphi 4 . Boolean ByteBool, WordBool, LongBool. Windows .
. AnsiString , . WideString . Unicode. (. 1 ).
, . Delphi .
, :
Var a: Array [1..5] Of Real;
:
Function Prim (a: Array Of Real): Real
, .
Object Pascal . a1: Array Of Real;, , . SetLength:
SetLength(a, 5);
0. , (^) .
:
Var aa: Array Of Array Of Real;
SetLength , : SetLength(aa, 10, 5).
, . Delphi Variant. , , . - , . , . - : ; ; ; / ; OLE-; . .
|
|
Var V1, V2, V3, V4, V5: Variant;
i: Integer; s: String;
Begin
V1:= 1; V2:= 1234.5678; V3:= ; V4:= 1000;
V5:= V1 + V2 + V3 // 2235.5678
i:= V1; // i = 1
s:= V3; // s =
i:= V4; // i = 1000
s:= V5; // s = 2235.5678
End;
- TDateTime . - 8 : , . , , . -. :
Date ;
DateToStr (d: TDateTime) ;
DateTimeToStr(d: TDateTime) ;
Time ;
TimeToStr(T: TDateTime) .
, , . . : , , ..
, . .
Delphi , . Object Pascal , .
, . , , , . Object Pascal .
Exception.
Exception , /, . . Exception , Ҕ. Exception Ŕ.
, :
EOutOfMemory ;
EOutOfResources ;
EInvalidPointer ;
|
|
EDivByZero ;
ERangeError ;
EIntError ;
EInvalidOp ;
EZeroDivide ;
EOverflow ;
EonvertError StrToInt StrToFloat;
, Delphi.
Object Pascal :
Try
<>
Except
< >
Else
<>
End;
:
1) Try Except;
2) , , End;
3) Try , Except, , Else.
Else.
:
Try
Z:= X/Y;
Except
Z:= 1.1e+38;
End;
Except :
On < > Do <>;
On, Do ; < > ; <> Object Pascal, Goto Except. , , Do. On < > Do <>,
, , . , , Else, , .
Try
...
Except
On ERangeError Do...;
On EDivByZero Do...;
On EIntError Do...;
End;
Delphi . Tools/Environment Options, Preference Break on exception.
, Except End Else, :
Try
...
Except
ShowMessage(!);
...
End;
, , . , . Delphi IS AS.
IS , .
AnObject IS TMyClass
True, AnObject TMyClass .
IS . . AS:
With AnObject AS TMyClass Do...
AS IS. , . , AS .