Constants and Varibales are declared the same way as in Turbo Pascal:
const MyConstant = 100; MyOtherConst: real = 1.0; var MyVar: integer; MySet: set of byte;
Note that (same as in Turbo Pascal) the variables are not initialized. You can however declare local typed constants (which you cannot do in standard Pascal):
procedure DoSomething; const MyLocalConstant: real= 1.0; begin //... end;
Ordinal types in Object Pascal:
Name | Range | Memory |
ShortInt | -128..127 | 1 Byte |
Byte | 0..255 | 1 Byte |
Integer | -32768..32768 | 4 Byte |
Word | 0..65535 | 2 Byte |
Cardinal | 0..65535 | 4 Byte |
Longint | -2147483648..2147483647 | 4 Byte |
Currency | +/-922337203685477.5807 | 4 Byte |
Floating-point types in Object Pascal:
Name | Range | Precision | Memory |
Real | 2.9*10^-39..1.7*10^38 | 11-12 digits | 6 Byte |
Single | 1.5*10^-45..3.4*10^38 | 7-8 digits | 4 Byte |
Double | 1.5*10^-324..1.7*10^308 | 15-16 digits | 8 Byte |
Extended | 5*10^-4932..1.1*10^4932 | 19-20 digits | 10 Byte |
Comp | -9.2*10^18..9.2*10^18 | 19-20 digits | 8 Byte |
Strings:
In 32bit Delphi (2.0 and 3.0) you also have long string instead of the old pascal string that were limited to 255 characters. The "Huge-String" compiler option is on by default. You can turn it off on the Compiler-tab in the project options.
Many Windows functions use the PChar type. It is a pointer to a string that does not have a length byte at the beginning. To indicate the end of the string the #0-byte is used. To convert a Pascal string to a PChar use PChar(MyString).
Most parts of Object Pascal are identical with normal Pascal. Please refer to a pascal documentation for this.
Third Day Fifth Day
Please e-mail me with any comments!
© 27.12.96 Sebastian Boßung
Home