Constants

The following constants define the maximum values that can be used with various types:
   MaxSIntValue = High(ValSInt);
   MaxUIntValue = High(ValUInt);
   maxint   = maxsmallint;
   maxLongint  = $7fffffff;
   maxSmallint = 32767;
The following constants for file-handling are defined in the system unit:
 Const
   fmclosed = $D7B0;
   fminput  = $D7B1;
   fmoutput = $D7B2;
   fminout  = $D7B3;
   fmappend = $D7B4;
   filemode : byte = 2;

The filemode variable is used when a non-text file is opened using Reset. It indicates how the file will be opened. filemode can have one of the following values:

0
The file is opened for reading.
1
The file is opened for writing.
2
The file is opened for reading and writing.

The default value is 2. Other values are possible but are operating system specific.

Further, the following non processor specific general-purpose constants are also defined:

 const
   erroraddr : pointer = nil;
   errorcode : word = 0;
  { max level in dumping on error }
   max_frame_dump : word = 20;

Remark: Processor specific global constants are named Testxxxx where xxxx represents the processor number (such as Test8086, Test68000), and are used to determine on what generation of processor the program is running on. The following constants are defined to access VMT entries:

    vmtInstanceSize         = 0;
    vmtParent               = 8;
    vmtClassName            = 12;
    vmtDynamicTable         = 16;
    vmtMethodTable          = 20;
    vmtFieldTable           = 24;
    vmtTypeInfo             = 28;
    vmtInitTable            = 32;
    vmtAutoTable            = 36;
    vmtIntfTable            = 40;
    vmtMsgStrPtr            = 44;
    vmtMethodStart          = 48;
    vmtDestroy              = vmtMethodStart;
    vmtNewInstance          = vmtMethodStart+4;
    vmtFreeInstance         = vmtMethodStart+8;
    vmtSafeCallException    = vmtMethodStart+12;
    vmtDefaultHandler       = vmtMethodStart+16;
    vmtAfterConstruction    = vmtMethodStart+20;
    vmtBeforeDestruction    = vmtMethodStart+24;
    vmtDefaultHandlerStr    = vmtMethodStart+28;
The constant names should be used, and never their values, because the VMT table can change, breaking code that uses direct values.

The following constants will be used for the planned variant support:

   varEmpty     = $0000;
   varNull      = $0001;
   varSmallint  = $0002;
   varInteger   = $0003;
   varSingle    = $0004;
   varDouble    = $0005;
   varCurrency  = $0006;
   varDate      = $0007;
   varOleStr    = $0008;
   varDispatch  = $0009;
   varError     = $000A;
   varBoolean   = $000B;
   varVariant   = $000C;
   varUnknown   = $000D;
   varByte      = $0011;
   varString    = $0100;
   varAny       = $0101;
   varTypeMask  = $0FFF;
   varArray     = $2000;
   varByRef     = $4000;
The following constants are used in the TVarRec record:
 vtInteger    = 0;
 vtBoolean    = 1;
 vtChar       = 2;
 vtExtended   = 3;
 vtString     = 4;
 vtPointer    = 5;
 vtPChar      = 6;
 vtObject     = 7;
 vtClass      = 8;
 vtWideChar   = 9;
 vtPWideChar  = 10;
 vtAnsiString = 11;
 vtCurrency   = 12;
 vtVariant    = 13;
 vtInterface  = 14;
 vtWideString = 15;
 vtInt64      = 16;
 vtQWord      = 17;
The ExceptProc is called when an unhandled exception occurs:
 Const
   ExceptProc : TExceptProc = Nil;
It is set in the objpas unit, but it can be set by the programmer to change the default exception handling.

The following constants are defined to describe the operating system’s file system:

 LineEnding = #10;
 LFNSupport = true;
 DirectorySeparator = '/';
 DriveSeparator = ':';
 PathSeparator = ':';
 FileNameCaseSensitive : Boolean = True;
(the shown values are for UNIX platforms, but will be different on other platforms) The meaning of the constants is the following:
LineEnding
End of line marker. This constant is used when writing end of lines to text files.
LFNSupport
This is True if the system supports long file names, i.e. filenames that are not restricted to 8.3 characters.
DirectorySeparator
The character that is used as a directory separator, i.e. it appears between various parts of a path to a file.
DriveSeparator
On systems that support drive letters, this character separates the drive indication from the rest of a filename.
PathSeparator
This character can be found between elements in a series of paths (such as the contents of the PATH environment variable.
FileNameCaseSensitive
Indicates whether filenames are case sensitive.

When programming cross-platform, use these constants instead of hard-coded characters. This will enhance portability of an application.