This chapter is separate from Chapter 5, to make
it easier to find the information you need. Instead of cluttering
Chapter 5 with all the individual identifiers,
this chapter organizes the system constants logically. All the
constant literals described in this chapter are defined in the
System
unit, so they are available at all times.
The
VarType
function returns the type code of a
Variant
. The type code is a small integer that
contains a type identifier with the optional modifiers
varArray
and varByRef
. Any type
except varEmpty
and varNull
can
have the varArray
modifier. Delphi automatically
takes care of the varByRef
modifier. For more
information, see the discussion of the Variant
type in Chapter 5. Table 6-1
lists the type identifiers, and Table 6-2 lists
the optional modifiers.
When
a subroutine parameter is a variant open array
(array
of
const
), Delphi passes the array argument by
converting each array element to a TVarRec
record.
Each record’s VType
member identifies the
member’s type. For more information, see the discussion of the
array
keyword in Chapter 5.
Table 6-3 lists the VType
values for a TVarRec
record.
Chapter 3, describes the format of a class’s
virtual method table (VMT). Delphi does not provide a convenient
record for accessing a VMT, but it does define the offsets (in bytes)
of the various parts of a VMT. The offsets are relative to the class
reference (TClass
). Note that the offsets change
from one version of Delphi to the next. Table 6-4
lists the offset names and values.
Delphi does
not export literals for its runtime errors. Instead, it defines a
number of literals in the implementation section of the
System
and SysInit
units, and
other error codes are defined implicitly in the
System
code. For your convenience, the following
tables list all the runtime error numbers that are built into
Delphi’s System
unit.
The internal error codes are used internally to the
System
unit. If you implement an
ErrorProc
procedure, these are the error codes you
must interpret.
The ErrorProc
procedure in the
SysUtils
unit maps internal error codes to
exceptions. Table 6-5 lists the internal error
codes and the exception class that the SysUtils
unit uses for each error.
If
you do not use the SysUtils
unit, or if an error
arises before the SysUtils
unit is initialized or
after it is finalized, the ErrorProc
procedures in
the System
unit maps internal error codes to
external error codes. Some memory and pointer errors do not produce
immediate access violations, but instead corrupt memory in a way that
does not let Delphi shut down cleanly. These errors often manifest
themselves as runtime errors when the program exits. Table 6-6 lists the external error codes.
Table 6-7 lists the I/O error codes, which are
reported with an internal error code of zero. Note that any Windows
error code can also be an I/O error code.
(SysUtils
raises EInOutError
for all I/O errors.)
Error Number |
Description |
SysUtils Exception Class |
0 |
I/O error; see Table 6-7 |
EInOutError |
1 |
Out of memory |
EOutOfMemory |
2 |
Invalid pointer |
EInvalidPointer |
3 |
Integer divide by zero |
EDivByZero |
4 |
Array bounds error |
ERangeError |
5 |
Integer or enumerated range error |
EIntOverflow |
6 |
Invalid floating-point operation |
EInvalidOp |
7 |
Floating-point divide by zero |
EZeroDivide |
8 |
Floating-point overflow |
EOverflow |
9 |
Floating-point underflow |
EUnderflow |
10 |
Invalid object type cast |
EInvalidCast |
11 |
Access violation |
EAccessViolation |
12 |
Stack overflow |
EPrivilege |
13 |
Control+Break interrupt |
EControlC |
14 |
Privileged instruction |
EStackOverflow |
15 |
Invalid |
EVariantError |
16 |
Invalid |
EVariantError |
17 |
No |
EVariantError |
18 |
Unable to create |
EVariantError |
19 |
Array operation on a non-array |
EVariantError |
20 |
|
EVariantError |
21 |
Assertion failed |
EAssertionFailed |
22 |
|
EExternalException |
23 |
Invalid interface type cast |
EIntfCastError |
24 |
Error in |
ESafeCallException |
Error Number |
Description |
200 |
Divide by zero |
201 |
Array bounds error |
202 |
Stack overflow |
203 |
Out of memory |
204 |
Invalid pointer |
205 |
Floating-point overflow |
206 |
Floating-point underflow |
207 |
Invalid floating-point operation |
210 |
Call to an abstract method |
215 |
Integer or enumerated bounds error |
216 |
Access violation |
217 |
Unhandled exception |
218 |
Privileged instruction |
219 |
Invalid class type cast |
220 |
Invalid |
221 |
Invalid |
222 |
No |
223 |
Unable to create |
224 |
Array operation on a non-array |
225 |
|
226 |
Cannot initialize thread local storage |
227 |
Assertion failed |
228 |
Invalid interface type cast |
229 |
Error from a |