[next] [tail] [up]

### 22.1 Constants and types

The following general-purpose types are defined:

     tfilename = string;

     tsyscharset = set of char;
     tintegerset = set of 0..sizeof(integer)*8-1;

     longrec = packed record
        lo,hi : word;
     end;

     wordrec = packed record
        lo,hi : byte;
     end;

     TMethod = packed record
       Code, Data: Pointer;
     end;

The use and meaning of these types should be clear, so no extra information will be provided here.

The following general-purpose constants are defined:

     const
        SecsPerDay = 24 * 60 * 60; // Seconds and milliseconds per day
        MSecsPerDay = SecsPerDay * 1000;
        DateDelta = 693594;        // Days between 1/1/0001 and 12/31/1899
        Eoln = #10;

The following types are used frequently in date and time functions. They are the same on all platforms.

     type
        TSystemTime = record
           Year, Month, Day: word;
           Hour, Minute, Second, MilliSecond: word;
        end ;

        TDateTime = double;

        TTimeStamp = record
           Time: integer;   { Number of milliseconds since midnight }
           Date: integer;   { One plus number of days since 1/1/0001 }
        end ;

The following type is used in the FindFirst (753),FindNext (754) and FindClose (753) functions. The win32 version differs from the other versions. If code is to be portable, that part shouldn’t be used.

     Type
       THandle = Longint;
       TSearchRec = Record
         Time,Size, Attr : Longint;
         Name : TFileName;
         ExcludeAttr : Longint;
         FindHandle : THandle;
         {$ifdef Win32}
         FindData : TWin32FindData;
         {$endif}
         end;

The following constants are file-attributes that need to be matched in the findfirst call.

     Const
       faReadOnly  = $00000001;
       faHidden    = $00000002;
       faSysFile   = $00000004;
       faVolumeId  = $00000008;
       faDirectory = $00000010;
       faArchive   = $00000020;
       faAnyFile   = $0000003f;

The following constants can be used in the FileOpen (749) call.

     Const
       fmOpenRead       = $0000;
       fmOpenWrite      = $0001;
       fmOpenReadWrite  = $0002;

The following constants can be used in the FileSeek (751) call.

     Const
       fsFromBeginning = 0;
       fsFromCurrent   = 1;
       fsFromEnd       = 2;

The following variables are used in the case translation routines.

     type
        TCaseTranslationTable = array[0..255] of char;
     var
        UpperCaseTable: TCaseTranslationTable;
        LowerCaseTable: TCaseTranslationTable;

The initialization code of the sysutils unit fills these tables with the appropriate values. For the win32 and go32v2 versions, this information is obtained from the operating system.

The following constants control the formatting of dates. For the Win32 version of the sysutils unit, these constants are set according to the internationalization settings of Windows by the initialization code of the unit.

     Const
        DateSeparator: char = '-';
        ShortDateFormat: string = 'd/m/y';
        LongDateFormat: string = 'dd" "mmmm" "yyyy';
        ShortMonthNames: array[1..12] of string[128] =
          ('Jan','Feb','Mar','Apr','May','Jun',
           'Jul','Aug','Sep','Oct','Nov','Dec');
        LongMonthNames: array[1..12] of string[128] =
          ('January','February','March','April',
           'May','June','July','August',
           'September','October','November','December');
        ShortDayNames: array[1..7] of string[128] =
          ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
        LongDayNames: array[1..7] of string[128] =
          ('Sunday','Monday','Tuesday','Wednesday',
            'Thursday','Friday','Saturday');

The following constants control the formatting of times. For the Win32 version of the sysutils unit, these constants are set according to the internationalization settings of Windows by the initialization code of the unit.

     Const
        ShortTimeFormat: string = 'hh:nn';
        LongTimeFormat: string = 'hh:nn:ss';
        TimeSeparator: char = ':';
        TimeAMString: string[7] = 'AM';
        TimePMString: string[7] = 'PM';

The following constants control the formatting of currencies and numbers. For the Win32 version of the sysutils unit, these constants are set according to the internationalization settings of Windows by the initialization code of the unit.

     Const
       DecimalSeparator : Char = '.';
       ThousandSeparator : Char = ',';
       CurrencyDecimals : Byte = 2;
       CurrencyString : String[7] = '$';
       { Format to use when formatting currency :
         0 = $1        1 = 1$         2 = $ 1      3 = 1 $
         4 = Currency string replaces decimal indicator.
             e.g. 1$50
        }
       CurrencyFormat : Byte = 1;
       { Same as above, only for negative currencies:
         0 = ($1)
         1 = -$1
         2 = $-1
         3 = $1-
         4 = (1$)
         5 = -1$
         6 = 1-$
         7 = 1$-
         8 = -1 $
         9 = -$ 1
         10 = $ 1-
        }
       NegCurrFormat : Byte = 5;

The following types are used in various string functions.

     type
        PString = ^String;
        TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);

The following constants are used in the file name handling routines. Do not use a slash of backslash character directly as a path separator; instead use the OsDirSeparator character.

     Const
       DirSeparators : set of char = ['/','\'];
     {$ifdef unix}
       OSDirSeparator = '/';
     {$else}
       OsDirSeparator = '\';
     {$endif}

[next] [front] [up]