home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vp21beta.zip / ARTLSRC.RAR / SYSUTILS.PAS < prev    next >
Pascal/Delphi Source File  |  2000-08-15  |  70KB  |  1,678 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       System Utilities Unit                           }
  6. {                                                       }
  7. {       Copyright (C) 1995,96 Borland International     }
  8. {                                                       }
  9. {       Virtual Pascal v2.1                             }
  10. {       Copyright (C) 1996-2000 vpascal.com             }
  11. {                                                       }
  12. {*******************************************************}
  13.  
  14. unit SysUtils;
  15.  
  16. {$H+,J+,P+,S-,T-,W-,R-,Z-,X+}
  17. {&Delphi+,PureInt+,AlignRec-,AlignData+,CDecl-,Use32-,Open32-}
  18.  
  19. interface
  20.  
  21. uses
  22. {$IFDEF Win32}
  23.   Windows,
  24. {$ENDIF}
  25.   VpSysLow;
  26.  
  27. type
  28.   Integer = Longint;
  29.  
  30. const
  31.   MaxInt = MaxLongint;
  32.  
  33. { File open modes }
  34.  
  35.   fmOpenRead       = open_access_readOnly;
  36.   fmOpenWrite      = open_access_writeOnly;
  37.   fmOpenReadWrite  = open_access_ReadWrite;
  38.   fmShareCompat    = open_share_denyNone;
  39.   fmShareExclusive = open_share_denyReadWrite;
  40.   fmShareDenyWrite = open_share_denyWrite;
  41.   fmShareDenyRead  = open_share_denyRead;
  42.   fmShareDenyNone  = open_share_denyNone;
  43.  
  44. { File attribute constants }
  45.  
  46.   faReadOnly  = $00000001;
  47.   faHidden    = $00000002;
  48.   faSysFile   = $00000004;
  49.   faVolumeID  = $00000008;      { Not used by OS/2 }
  50.   faDirectory = $00000010;
  51.   faArchive   = $00000020;
  52.   faAnyFile   = $00000037;
  53.  
  54. { File mode magic numbers }
  55.  
  56.   fmClosed = $A55AD7B0;
  57.   fmInput  = $A55AD7B1;
  58.   fmOutput = $A55AD7B2;
  59.   fmInOut  = $A55AD7B3;
  60.  
  61. { Seconds and milliseconds per day }
  62.  
  63.   SecsPerDay = 24 * 60 * 60;
  64.   MSecsPerDay = SecsPerDay * 1000;
  65.  
  66. { Days between 1/1/0001 and 12/31/1899 }
  67.  
  68.   DateDelta = 693594;
  69.  
  70. type
  71.  
  72. { Type conversion records }
  73.  
  74.   WordRec = packed record
  75.     Lo, Hi: Byte;
  76.   end;
  77.  
  78.   LongRec = packed record
  79.     Lo, Hi: Word;
  80.   end;
  81.  
  82.   PtrRec = record
  83.     Ofs: Longint;
  84.   end;
  85.  
  86.   TMethod = record
  87.     Code, Data: Pointer;
  88.   end;
  89.  
  90. { General arrays }
  91.  
  92.   PByteArray = ^TByteArray;
  93.   TByteArray = array[0..512*1024*1024-1] of Byte;
  94.  
  95.   PWordArray = ^TWordArray;
  96.   TWordArray = array[0..256*1024*1024-1] of Word;
  97.  
  98. { Generic procedure pointer }
  99.  
  100.   TProcedure = procedure;
  101.  
  102. { Generic filename type }
  103.  
  104.   TFileName = string;
  105.  
  106. { Search record used by FindFirst, FindNext, and FindClose }
  107.  
  108.   TSearchRec = packed record
  109.     FindHandle: Longint;
  110.     NameLStr: Pointer;
  111.     Attr: Byte;
  112.     Time: Longint;
  113.     Size: Longint;
  114.     Name: ShortString;
  115.     Filler: array[0..3] of Char;
  116. {$IFDEF LINUX}
  117.     // Placed here to make patch work with full version as
  118.     // well as with pure interface version of SysUtils.
  119.     Private_data: array[1..sizeof(TOSSearchRec)-4-4-1-4-4-256-4] of Byte;
  120. {$ENDIF}
  121. {$IFDEF WIN32}
  122.     ExcludeAttr: Longint;
  123.     FindData: TWin32FindData;
  124. {$ENDIF}
  125. {$IFDEF DPMI32}
  126.     Private_data: array[1..sizeof(TOSSearchRec)-4-4-1-4-4-256-4] of Byte;
  127. {$ENDIF}
  128.   end;
  129.  
  130. { Typed-file and untyped-file record }
  131.  
  132.   TFileRec = record
  133.     Handle: Integer;
  134.     Mode: Integer;
  135.     RecSize: Cardinal;
  136.     Private: array[1..28] of Byte;
  137.     UserData: array[1..32] of Byte;
  138.     Name: array[0..259] of Char;
  139.   end;
  140.  
  141. { Text file record structure used for Text files }
  142.  
  143.   PTextBuf = ^TTextBuf;
  144.   TTextBuf = array[0..127] of Char;
  145.   TTextRec = record
  146.     Handle: Integer;
  147.     Mode: Integer;
  148.     BufSize: Cardinal;
  149.     BufPos: Cardinal;
  150.     BufEnd: Cardinal;
  151.     BufPtr: PChar;
  152.     OpenFunc: Pointer;
  153.     InOutFunc: Pointer;
  154.     FlushFunc: Pointer;
  155.     CloseFunc: Pointer;
  156.     UserData: array[1..32] of Byte;
  157.     Name: array[0..259] of Char;
  158.     Buffer: TTextBuf;
  159.   end;
  160.  
  161. { FloatToText, FloatToTextFmt, TextToFloat, and FloatToDecimal type codes }
  162.  
  163.   TFloatValue = (fvExtended, fvCurrency);
  164.  
  165. { FloatToText format codes }
  166.  
  167.   TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);
  168.  
  169. { FloatToDecimal result record }
  170.  
  171.   TFloatRec = packed record
  172.     Exponent: Smallint;
  173.     Negative: Boolean;
  174.     Digits: array[0..20] of Char;
  175.   end;
  176.  
  177. { Date and time record }
  178.  
  179.   TTimeStamp = record
  180.     Time: Integer;      { Number of milliseconds since midnight }
  181.     Date: Integer;      { One plus number of days since 1/1/0001 }
  182.   end;
  183.  
  184. { Exceptions }
  185.  
  186.   Exception = class(TObject)
  187.   private
  188.     FMessage: String;
  189.     FHelpContext: Integer;
  190.   public
  191.     constructor Create(const Msg: string);
  192.     constructor CreateFmt(const Msg: string; const Args: array of const);
  193.     constructor CreateRes(Ident: Integer);
  194.     constructor CreateResFmt(Ident: Integer; const Args: array of const);
  195.     constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  196.     constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  197.       AHelpContext: Integer);
  198.     constructor CreateResHelp(Ident: Integer; AHelpContext: Integer);
  199.     constructor CreateResFmtHelp(Ident: Integer; const Args: array of const;
  200.       AHelpContext: Integer);
  201.     property HelpContext: Integer read FHelpContext write FHelpContext;
  202.     property Message: string read FMessage write FMessage;
  203.   end;
  204.  
  205.   ExceptClass = class of Exception;
  206.  
  207.   EAbort = class(Exception);
  208.  
  209.   EOutOfMemory = class(Exception)
  210.   private
  211.     AllowFree: Boolean;
  212.   public
  213.     destructor Destroy; override;
  214.     procedure FreeInstance; override;
  215.   end;
  216.  
  217.   EInOutError = class(Exception)
  218.   public
  219.     ErrorCode: Integer;
  220.   end;
  221.  
  222.   EIntError = class(Exception);
  223.   EDivByZero = class(EIntError);
  224.   ERangeError = class(EIntError);
  225.   EIntOverflow = class(EIntError);
  226.  
  227.   EMathError = class(Exception);
  228.   EInvalidOp = class(EMathError);
  229.   EZeroDivide = class(EMathError);
  230.   EOverflow = class(EMathError);
  231.   EUnderflow = class(EMathError);
  232.  
  233.   EInvalidPointer = class(Exception);
  234.  
  235.   EInvalidCast = class(Exception);
  236.  
  237.   EConvertError = class(Exception);
  238.  
  239.   EAccessViolation = class(Exception);
  240.   EPrivilege = class(Exception);
  241.   EStackOverflow = class(Exception);
  242.   EControlC = class(Exception);
  243.  
  244.   EPropReadOnly = class(Exception);
  245.   EPropWriteOnly = class(Exception);
  246.  
  247.   EExternalException = class(Exception)
  248.   public
  249.     ExceptionRecord: POSExceptionRecord;
  250.   end;
  251.  
  252. const
  253.  
  254. { Empty string and null string pointer. These constants are provided for
  255.   backwards compatibility only. }
  256.  
  257.   EmptyStr: string = '';
  258.   NullStr: PString = @EmptyStr;
  259.  
  260. { Win32 platform identifier.  This will be one of the following values:
  261.  
  262.     0 : Win32s      VER_PLATFORM_WIN32s
  263.     1 : Windows 95  VER_PLATFORM_WIN32_WINDOWS
  264.     2 : Windows NT  VER_PLATFORM_WIN32_NT
  265.     -1: OS/2 }
  266.  
  267.   Win32Platform: Integer = -1;
  268.  
  269. { Currency and date/time formatting options }
  270.  
  271. { CurrencyString - Defines the currency symbol used in floating-point to
  272.   decimal conversions. Fetched using SysGetCurrencyFormat.
  273.  
  274.   CurrencyFormat - Defines the currency symbol placement and separation
  275.   used in floating-point to decimal conversions. Possible values are:
  276.  
  277.     0 = '$1'
  278.     1 = '1$'
  279.     2 = '$ 1'
  280.     3 = '1 $'
  281.  
  282.   The initial value is fetched using SysGetCurrencyFormat.
  283.  
  284.   NegCurrFormat - Defines the currency format for used in floating-point to
  285.   decimal conversions of negative numbers. Possible values are:
  286.  
  287.     0 = '($1)'      4 = '(1$)'      8 = '-1 $'      12 = '$ -1'
  288.     1 = '-$1'       5 = '-1$'       9 = '-$ 1'      13 = '1- $'
  289.     2 = '$-1'       6 = '1-$'      10 = '1 $-'      14 = '($ 1)'
  290.     3 = '$1-'       7 = '1$-'      11 = '$ 1-'      15 = '(1 $)'
  291.  
  292.   The initial value is fetched using SysGetCurrencyFormat.
  293.  
  294.   ThousandSeparator - The character used to separate thousands in numbers
  295.   with more than three digits to the left of the decimal separator.
  296.   The initial value is fetched using SysGetCurrencyFormat.
  297.  
  298.   DecimalSeparator - The character used to separate the integer part from
  299.   the fractional part of a number. The initial value is fetched using
  300.   SysGetCurrencyFormat.
  301.  
  302.   CurrencyDecimals - The number of digits to the right of the decimal point
  303.   in a currency amount. The initial value is fetched using
  304.   SysGetCurrencyFormat.
  305.  
  306.   DateSeparator - The character used to separate the year, month, and day
  307.   parts of a date value. The initial value is fetched using SysGetDateFormat.
  308.  
  309.   ShortDateFormat - The format string used to convert a date value to a
  310.   short string suitable for editing. For a complete description of date and
  311.   time format strings, refer to the documentation for the FormatDate
  312.   function. The short date format should only use the date separator
  313.   character and the  m, mm, d, dd, yy, and yyyy format specifiers. The
  314.   initial value is fetched using SysGetDateFormat.
  315.  
  316.   LongDateFormat - The format string used to convert a date value to a long
  317.   string suitable for display but not for editing. For a complete description
  318.   of date and time format strings, refer to the documentation for the
  319.   FormatDate function. The initial value is fetched using SysGetDateFormat.
  320.  
  321.   TimeSeparator - The character used to separate the hour, minute, and
  322.   second parts of a time value. The initial value is fetched using
  323.   SysGetTimeFormat.
  324.  
  325.   TimeAMString - The suffix string used for time values between 00:00 and
  326.   11:59 in 12-hour clock format. The initial value is fetched using
  327.   SysGetTimeFormat.
  328.  
  329.   TimePMString - The suffix string used for time values between 12:00 and
  330.   23:59 in 12-hour clock format. The initial value is fetched using
  331.   SysGetTimeFormat.
  332.  
  333.   ShortTimeFormat - The format string used to convert a time value to a
  334.   short string with only hours and minutes. The default value is computed
  335.   by SysGetTimeFormat.
  336.  
  337.   LongTimeFormat - The format string used to convert a time value to a long
  338.   string with hours, minutes, and seconds. The default value is computed
  339.   by SysGetTimeFormat.
  340.  
  341.   ShortMonthNames - Array of strings containing short month names. The mmm
  342.   format specifier in a format string passed to FormatDate causes a short
  343.   month name to be substituted.
  344.  
  345.   LongMonthNames - Array of strings containing long month names. The mmmm
  346.   format specifier in a format string passed to FormatDate causes a long
  347.   month name to be substituted.
  348.  
  349.   ShortDayNames - Array of strings containing short day names. The ddd
  350.   format specifier in a format string passed to FormatDate causes a short
  351.   day name to be substituted.
  352.  
  353.   LongDayNames - Array of strings containing long day names. The dddd
  354.   format specifier in a format string passed to FormatDate causes a long
  355.   day name to be substituted. }
  356.  
  357. var
  358.   CurrencyString: string;
  359.   CurrencyFormat: Byte;
  360.   NegCurrFormat: Byte;
  361.   ThousandSeparator: Char;
  362.   DecimalSeparator: Char;
  363.   CurrencyDecimals: Byte;
  364.   DateSeparator: Char;
  365.   ShortDateFormat: string;
  366.   LongDateFormat: string;
  367.   TimeSeparator: Char;
  368.   TimeAMString: string;
  369.   TimePMString: string;
  370.   ShortTimeFormat: string;
  371.   LongTimeFormat: string;
  372.   ShortMonthNames: array[1..12] of string;
  373.   LongMonthNames: array[1..12] of string;
  374.   ShortDayNames: array[1..7] of string;
  375.   LongDayNames: array[1..7] of string;
  376.  
  377. { Memory management routines }
  378.  
  379. { AllocMem allocates a block of the given size on the heap. Each byte in
  380.   the allocated buffer is set to zero. To dispose the buffer, use the
  381.   FreeMem standard procedure. }
  382.  
  383. function AllocMem(Size: Cardinal): Pointer;
  384.  
  385. { String handling routines }
  386.  
  387. { NewStr allocates a copy of the given string on the heap. The size of the
  388.   allocated heap block is Length(S) + 1. If the string is empty, NewStr
  389.   returns NullStr and doesn't allocate any heap space. To dispose the
  390.   string, use DisposeStr. }
  391.  
  392. function NewStr(const S: String): PString;
  393.  
  394. { DisposeStr disposes a string pointer that was previously allocated using
  395.   NewStr. If the given pointer is NIL or points to an empty string,
  396.   StrDispose does nothing. }
  397.  
  398. procedure DisposeStr(P: PString);
  399.  
  400. { AssignStr assigns a new dynamically allocated string to the given string
  401.   pointer. AssignStr corresponds to the statement "DisposeStr(P)" followed
  402.   by the statement "P := NewStr(S)". Note that P must be NIL or contain a
  403.   valid string pointer before calling AssignStr. In other words, AssignStr
  404.   cannot be used to initialize a string pointer variable. }
  405.  
  406. procedure AssignStr(var P: PString; const S: string);
  407.  
  408. { AppendStr appends S to the end of Dest. AppendStr corresponds to the
  409.   statement "Dest := Dest + S", which is more efficient. }
  410.  
  411. procedure AppendStr(var Dest: string; const S: string);
  412.  
  413. { UpperCase converts all ASCII characters in the given string to upper case.
  414.   The conversion affects only 7-bit ASCII characters between 'a' and 'z'. To
  415.   convert 8-bit international characters, use AnsiUpperCase. }
  416.  
  417. function UpperCase(const S: string): string;
  418.  
  419. { LowerCase converts all ASCII characters in the given string to lower case.
  420.   The conversion affects only 7-bit ASCII characters between 'A' and 'Z'. To
  421.   convert 8-bit international characters, use AnsiLowerCase. }
  422.  
  423. function LowerCase(const S: string): string;
  424.  
  425. { CompareStr compares S1 to S2, with case-sensitivity. The return value is
  426.   less than 0 if S1 < S2, 0 if S1 = S2, or greater than 0 if S1 > S2. The
  427.   compare operation is based on the 8-bit ordinal value of each character
  428.   and is not affected by the current code page. }
  429.  
  430. function CompareStr(const S1, S2: string): Integer;
  431.  
  432. { CompareMem performs a binary compare of Length bytes of memory referenced
  433.   by P1 to that of P2.  CompareMem returns True if the memory referenced by
  434.   P1 is identical to that of P2. }
  435.  
  436. function CompareMem(P1, P2: Pointer; Length: Integer): Boolean;
  437.  
  438. { CompareText compares S1 to S2, without case-sensitivity. The return value
  439.   is the same as for CompareStr. The compare operation is based on the 8-bit
  440.   ordinal value of each character, after converting 'a'..'z' to 'A'..'Z',
  441.   and is not affected by the current code page. }
  442.  
  443. function CompareText(const S1, S2: string): Integer;
  444.  
  445. { SameText compares S1 to S2, without case-sensitivity. Returns true if
  446.   S1 and S2 are the equal, that is, if CompareText would return 0. SameText
  447.   has the same 8-bit limitations as CompareText }
  448.  
  449. function SameText(const S1, S2: string): Boolean;
  450.  
  451. { AnsiUpperCase converts all characters in the given string to upper case.
  452.   The conversion uses the current Windows locale. }
  453.  
  454. function AnsiUpperCase(const S: string): string;
  455.  
  456. { AnsiLowerCase converts all characters in the given string to lower case.
  457.   The conversion uses the current code page. }
  458.  
  459. function AnsiLowerCase(const S: string): string;
  460.  
  461. { AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare
  462.   operation is controlled by the current code page. The return value is the
  463.   same as for CompareStr. }
  464.  
  465. function AnsiCompareStr(const S1, S2: string): Integer;
  466.  
  467. { AnsiSameStr compares S1 to S2, with case-sensitivity. The compare
  468.   operation is controlled by the current Windows locale. The return value
  469.   is True if AnsiCompareStr would have returned 0. }
  470.  
  471. function AnsiSameStr(const S1, S2: string): Boolean;
  472.  
  473. { AnsiCompareText compares S1 to S2, without case-sensitivity. The compare
  474.   operation is controlled by the current Windows locale. The return value
  475.   is the same as for CompareStr. }
  476.  
  477. function AnsiCompareText(const S1, S2: string): Integer;
  478.  
  479. { AnsiSameText compares S1 to S2, without case-sensitivity. The compare
  480.   operation is controlled by the current Windows locale. The return value
  481.   is True if AnsiCompareText would have returned 0. }
  482.  
  483. function AnsiSameText(const S1, S2: string): Boolean;
  484.  
  485. { AnsiStrComp compares S1 to S2, with case-sensitivity. The compare
  486.   operation is controlled by the current Windows locale. The return value
  487.   is the same as for CompareStr. }
  488.  
  489. function AnsiStrComp(S1, S2: PChar): Integer;
  490.  
  491. { AnsiStrIComp compares S1 to S2, without case-sensitivity. The compare
  492.   operation is controlled by the current code page. The return value
  493.   is the same as for CompareStr. }
  494.  
  495. function AnsiStrIComp(S1, S2: PChar): Integer;
  496.  
  497. { AnsiStrLComp compares S1 to S2, with case-sensitivity, up to a maximum
  498.   length of MaxLen bytes. The compare operation is controlled by the
  499.   current code page. The return value is the same as for CompareStr. }
  500.  
  501. function AnsiStrLComp(S1, S2: PChar; MaxLen: Cardinal): Integer;
  502.  
  503. { AnsiStrLIComp compares S1 to S2, without case-sensitivity, up to a maximum
  504.   length of MaxLen bytes. The compare operation is controlled by the
  505.   current code page. The return value is the same as for CompareStr. }
  506.  
  507. function AnsiStrLIComp(S1, S2: PChar; MaxLen: Cardinal): Integer;
  508.  
  509. { AnsiStrLower converts all characters in the given string to lower case.
  510.   The conversion uses the current code page. }
  511.  
  512. function AnsiStrLower(Str: PChar): PChar;
  513.  
  514. { AnsiStrUpper converts all characters in the given string to upper case.
  515.   The conversion uses the current code page. }
  516.  
  517. function AnsiStrUpper(Str: PChar): PChar;
  518.  
  519. { Trim trims leading and trailing spaces and control characters from the
  520.   given string. }
  521.  
  522. function Trim(const S: string): string;
  523.  
  524. { TrimLeft trims leading spaces and control characters from the given
  525.   string. }
  526.  
  527. function TrimLeft(const S: string): string;
  528.  
  529. { TrimRight trims trailing spaces and control characters from the given
  530.   string. }
  531.  
  532. function TrimRight(const S: string): string;
  533.  
  534. { QuotedStr returns the given string as a quoted string. A single quote
  535.   character is inserted at the beginning and the end of the string, and
  536.   for each single quote character in the string, another one is added. }
  537.  
  538. function QuotedStr(const S: string): string;
  539.  
  540. { AdjustLineBreaks adjusts all line breaks in the given string to be true
  541.   CR/LF sequences. The function changes any CR characters not followed by
  542.   a LF and any LF characters not preceded by a CR into CR/LF pairs. }
  543.  
  544. function AdjustLineBreaks(const S: string): string;
  545.  
  546. { IsValidIdent returns true if the given string is a valid identifier. An
  547.   identifier is defined as a character from the set ['A'..'Z', 'a'..'z', '_']
  548.   followed by zero or more characters from the set ['A'..'Z', 'a'..'z',
  549.   '0..'9', '_']. }
  550.  
  551. function IsValidIdent(const Ident: string): Boolean;
  552.  
  553. { IntToStr converts the given value to its decimal string representation. }
  554.  
  555. function IntToStr(Value: Integer): string;
  556.  
  557. { IntToHex converts the given value to a hexadecimal string representation
  558.   with the minimum number of digits specified. }
  559.  
  560. function IntToHex(Value: Integer; Digits: Integer): string;
  561.  
  562. { StrToInt converts the given string to an integer value. If the string
  563.   doesn't contain a valid value, an EConvertError exception is raised. }
  564.  
  565. function StrToInt(const S: string): Integer;
  566.  
  567. { StrToIntDef converts the given string to an integer value. If the string
  568.   doesn't contain a valid value, the value given by Default is returned. }
  569.  
  570. function StrToIntDef(const S: string; Default: Integer): Integer;
  571.  
  572. { LoadStr loads the string resource given by Ident from the application's
  573.   executable file. If the string resource does not exist, an empty string
  574.   is returned. }
  575.  
  576. function LoadStr(Ident: Integer): string;
  577.  
  578. { LoadStr loads the string resource given by Ident from the application's
  579.   executable file, and uses it as the format string in a call to the
  580.   Format function with the given arguments. }
  581.  
  582. function FmtLoadStr(Ident: Integer; const Args: array of const): string;
  583.  
  584. { File management routines }
  585.  
  586. { FileOpen opens the specified file using the specified access mode. The
  587.   access mode value is constructed by OR-ing one of the fmOpenXXXX constants
  588.   with one of the fmShareXXXX constants. If the return value is positive,
  589.   the function was successful and the value is the file handle of the opened
  590.   file. If the return value is negative, an error occurred and the value is
  591.   a negative OS/2 error code. }
  592.  
  593. function FileOpen(const FileName: string; Mode: Integer): Integer;
  594.  
  595. { FileCreate creates a new file by the specified name. If the return value
  596.   is positive, the function was successful and the value is the file handle
  597.   of the new file. If the return value is negative, an error occurred and
  598.   the value is a negative OS/2 error code. }
  599.  
  600. function FileCreate(const FileName: string): Integer;
  601.  
  602. { FileRead reads Count bytes from the file given by Handle into the buffer
  603.   specified by Buffer. The return value is the number of bytes actually
  604.   read; it is less than Count if the end of the file was reached. The return
  605.   value is -1 if an error occurred. }
  606.  
  607. function FileRead(Handle: Integer; var Buffer; Count: Integer): Integer;
  608.  
  609. { FileWrite writes Count bytes to the file given by Handle from the buffer
  610.   specified by Buffer. The return value is the number of bytes actually
  611.   written, or -1 if an error occurred. }
  612.  
  613. function FileWrite(Handle: Integer; const Buffer; Count: Integer): Integer;
  614.  
  615. { FileSeek changes the current position of the file given by Handle to be
  616.   Offset bytes relative to the point given by Origin. Origin = 0 means that
  617.   Offset is relative to the beginning of the file, Origin = 1 means that
  618.   Offset is relative to the current position, and Origin = 2 means that
  619.   Offset is relative to the end of the file. The return value is the new
  620.   current position, relative to the beginning of the file, or -1 if an error
  621.   occurred. }
  622.  
  623. function FileSeek(Handle, Offset, Origin: Integer): Integer;
  624.  
  625. { FileClose closes the specified file. }
  626.  
  627. procedure FileClose(Handle: Integer);
  628.  
  629. { FileAge returns the date-and-time stamp of the specified file. The return
  630.   value can be converted to a TDateTime value using the FileDateToDateTime
  631.   function. The return value is -1 if the file does not exist. }
  632.  
  633. function FileAge(const FileName: string): Integer;
  634.  
  635. { FileExists returns a boolean value that indicates whether the specified
  636.   file exists. }
  637.  
  638. function FileExists(const FileName: string): Boolean;
  639.  
  640. { FindFirst searches the directory given by Path for the first entry that
  641.   matches the filename given by Path and the attributes given by Attr. The
  642.   result is returned in the search record given by SearchRec. The return
  643.   value is zero if the function was successful. Otherwise the return value
  644.   is an OS/2 error code; a value of 18 indicates that no files were
  645.   found. FindFirst is typically used in conjunction with FindNext and
  646.   FindClose as follows:
  647.  
  648.     Result := FindFirst(Path, Attr, SearchRec);
  649.     while Result = 0 do
  650.     begin
  651.       ProcessSearchRec(SearchRec);
  652.       Result := FindNext(SearchRec);
  653.     end;
  654.     FindClose(SearchRec);
  655.  
  656.   where ProcessSearchRec represents user-defined code that processes the
  657.   information in a search record. }
  658.  
  659. function FindFirst(const Path: string; Attr: Integer;
  660.   var F: TSearchRec): Integer;
  661.  
  662. { FindNext returs the next entry that matches the name and attributes
  663.   specified in a previous call to FindFirst. The search record must be one
  664.   that was passed to FindFirst. The return value is zero if the function was
  665.   successful. Otherwise the return value is an OS/2 error code; a
  666.   value of 18 indicates that there are no more files matching the search
  667.   criteria. }
  668.  
  669. function FindNext(var F: TSearchRec): Integer;
  670.  
  671. { FindClose terminates a FindFirst/FindNext sequence. FindClose does nothing
  672.   in the 16-bit version of Windows, but is required in the 32-bit version,
  673.   so for maximum portability every FindFirst/FindNext sequence should end
  674.   with a call to FindClose. }
  675.  
  676. procedure FindClose(var F: TSearchRec);
  677.  
  678. { FileGetDate returns the DOS date-and-time stamp of the file given by
  679.   Handle. The return value is -1 if the handle is invalid. The
  680.   FileDateToDateTime function can be used to convert the returned value to
  681.   a TDateTime value. }
  682.  
  683. function FileGetDate(Handle: Integer): Integer;
  684.  
  685. { FileSetDate sets the DOS date-and-time stamp of the file given by Handle
  686.   to the value given by Age. The DateTimeToFileDate function can be used to
  687.   convert a TDateTime value to a DOS date-and-time stamp. The return value
  688.   is zero if the function was successful. Otherwise the return value is an
  689.   OS/2 error code. }
  690.  
  691. function FileSetDate(Handle, Age: Integer): Integer;
  692.  
  693. { FileGetAttr returns the file attributes of the file given by FileName. The
  694.   attributes can be examined by AND-ing with the faXXXX constants defined
  695.   above. A return value of -1 indicates that an error occurred. }
  696.  
  697. function FileGetAttr(const FileName: string): Integer;
  698.  
  699. { FileSetAttr sets the file attributes of the file given by FileName to the
  700.   value given by Attr. The attribute value is formed by OR-ing the
  701.   appropriate faXXXX constants. The return value is zero if the function was
  702.   successful. Otherwise the return value is an OS/2 error code. }
  703.  
  704. function FileSetAttr(const FileName: string; Attr: Integer): Integer;
  705.  
  706. { DeleteFile deletes the file given by FileName. The return value is True if
  707.   the file was successfully deleted, or False if an error occurred. }
  708.  
  709. function DeleteFile(const FileName: string): Boolean;
  710.  
  711. { RenameFile renames the file given by OldName to the name given by NewName.
  712.   The return value is True if the file was successfully renamed, or False if
  713.   an error occurred. }
  714.  
  715. function RenameFile(const OldName, NewName: string): Boolean;
  716.  
  717. { ChangeFileExt changes the extension of a filename. FileName specifies a
  718.   filename with or without an extension, and Extension specifies the new
  719.   extension for the filename. The new extension can be a an empty string or
  720.   a period followed by up to three characters. }
  721.  
  722. function ChangeFileExt(const FileName, Extension: string): string;
  723.  
  724. { ExtractFilePath extracts the drive and directory parts of the given
  725.   filename. The resulting string is the leftmost characters of FileName,
  726.   up to and including the colon or backslash that separates the path
  727.   information from the name and extension. The resulting string is empty
  728.   if FileName contains no drive and directory parts. }
  729.  
  730. function ExtractFilePath(const FileName: string): string;
  731.  
  732. { ExtractFileDir extracts the drive and directory parts of the given
  733.   filename. The resulting string is a directory name suitable for passing
  734.   to SetCurrentDir, CreateDir, etc. The resulting string is empty if
  735.   FileName contains no drive and directory parts. }
  736.  
  737. function ExtractFileDir(const FileName: string): string;
  738.  
  739. { ExtractFileDrive extracts the drive part of the given filename.  For
  740.   filenames with drive letters, the resulting string is '<drive>:'.
  741.   For filenames with a UNC path, the resulting string is in the form
  742.   '\\<servername>\<sharename>'.  If the given path contains neither
  743.   style of filename, the result is an empty string. }
  744.  
  745. function ExtractFileDrive(const FileName: string): string;
  746.  
  747. { ExtractFileName extracts the name and extension parts of the given
  748.   filename. The resulting string is the leftmost characters of FileName,
  749.   starting with the first character after the colon or backslash that
  750.   separates the path information from the name and extension. The resulting
  751.   string is equal to FileName if FileName contains no drive and directory
  752.   parts. }
  753.  
  754. function ExtractFileName(const FileName: string): string;
  755.  
  756. { ExtractFileExt extracts the extension part of the given filename. The
  757.   resulting string includes the period character that separates the name
  758.   and extension parts. The resulting string is empty if the given filename
  759.   has no extension. }
  760.  
  761. function ExtractFileExt(const FileName: string): string;
  762.  
  763. { ExpandFileName expands the given filename to a fully qualified filename.
  764.   The resulting string consists of a drive letter, a colon, a root relative
  765.   directory path, and a filename. Embedded '.' and '..' directory references
  766.   are removed. }
  767.  
  768. function ExpandFileName(const FileName: string): string;
  769.  
  770. { ExpandUNCFileName expands the given filename to a fully qualified filename.
  771.   This function is the same as ExpandFileName except that it will return the
  772.   drive portion of the filename in the format '\\<servername>\<sharename> if
  773.   that drive is actually a network resource instead of a local resource.
  774.   Like ExpandFileName, embedded '.' and '..' directory references are
  775.   removed. }
  776.  
  777. function ExpandUNCFileName(const FileName: string): string;
  778.  
  779. {  ExtractRelativePath will return a file path name relative to the given
  780.    BaseName.  It strips the common path dirs and adds '..\' for each level
  781.    up from the BaseName path. }
  782.  
  783. function ExtractRelativePath(const BaseName, DestName: string): string;
  784.  
  785. { FileSearch searches for the file given by Name in the list of directories
  786.   given by DirList. The directory paths in DirList must be separated by
  787.   semicolons. The search always starts with the current directory of the
  788.   current drive. The returned value is a concatenation of one of the
  789.   directory paths and the filename, or an empty string if the file could not
  790.   be located. }
  791.  
  792. function FileSearch(const Name, DirList: string): string;
  793.  
  794. { DiskFree returns the number of free bytes on the specified drive number,
  795.   where 0 = Current, 1 = A, 2 = B, etc. DiskFree returns -1 if the drive
  796.   number is invalid. }
  797.  
  798. function DiskFree(Drive: Byte): Integer;
  799.  
  800. { DiskSize returns the size in bytes of the specified drive number, where
  801.   0 = Current, 1 = A, 2 = B, etc. DiskSize returns -1 if the drive number
  802.   is invalid. }
  803.  
  804. function DiskSize(Drive: Byte): Integer;
  805.  
  806. { FileDateToDateTime converts a DOS date-and-time value to a TDateTime
  807.   value. The FileAge, FileGetDate, and FileSetDate routines operate on DOS
  808.   date-and-time values, and the Time field of a TSearchRec used by the
  809.   FindFirst and FindNext functions contains a DOS date-and-time value. }
  810.  
  811. function FileDateToDateTime(FileDate: Integer): TDateTime;
  812.  
  813. { DateTimeToFileDate converts a TDateTime value to a DOS date-and-time
  814.   value. The FileAge, FileGetDate, and FileSetDate routines operate on DOS
  815.   date-and-time values, and the Time field of a TSearchRec used by the
  816.   FindFirst and FindNext functions contains a DOS date-and-time value. }
  817.  
  818. function DateTimeToFileDate(DateTime: TDateTime): Integer;
  819.  
  820. { GetCurrentDir returns the current directory. }
  821.  
  822. function GetCurrentDir: string;
  823.  
  824. { SetCurrentDir sets the current directory. The return value is True if
  825.   the current directory was successfully changed, or False if an error
  826.   occurred. }
  827.  
  828. function SetCurrentDir(const Dir: string): Boolean;
  829.  
  830. { CreateDir creates a new directory. The return value is True if a new
  831.   directory was successfully created, or False if an error occurred. }
  832.  
  833. function CreateDir(const Dir: string): Boolean;
  834.  
  835. { RemoveDir deletes an existing empty directory. The return value is
  836.   True if the directory was successfully deleted, or False if an error
  837.   occurred. }
  838.  
  839. function RemoveDir(const Dir: string): Boolean;
  840.  
  841. { PChar routines }
  842.  
  843. { StrLen returns the number of characters in Str, not counting the null
  844.   terminator. }
  845.  
  846. function StrLen(Str: PChar): Cardinal;
  847.  
  848. { StrEnd returns a pointer to the null character that terminates Str. }
  849.  
  850. function StrEnd(Str: PChar): PChar;
  851.  
  852. { StrMove copies exactly Count characters from Source to Dest and returns
  853.   Dest. Source and Dest may overlap. }
  854.  
  855. function StrMove(Dest, Source: PChar; Count: Cardinal): PChar;
  856.  
  857. { StrCopy copies Source to Dest and returns Dest. }
  858.  
  859. function StrCopy(Dest, Source: PChar): PChar;
  860.  
  861. { StrECopy copies Source to Dest and returns StrEnd(Dest). }
  862.  
  863. function StrECopy(Dest, Source: PChar): PChar;
  864.  
  865. { StrLCopy copies at most MaxLen characters from Source to Dest and
  866.   returns Dest. }
  867.  
  868. function StrLCopy(Dest, Source: PChar; MaxLen: Cardinal): PChar;
  869.  
  870. { StrPCopy copies the Pascal style string Source into Dest and
  871.   returns Dest. }
  872.  
  873. function StrPCopy(Dest: PChar; const Source: String): PChar;
  874.  
  875. { StrPLCopy copies at most MaxLen characters from the Pascal style string
  876.   Source into Dest and returns Dest. }
  877.  
  878. function StrPLCopy(Dest: PChar; const Source: string; MaxLen: Cardinal): PChar;
  879.  
  880. { StrCat appends a copy of Source to the end of Dest and returns Dest. }
  881.  
  882. function StrCat(Dest, Source: PChar): PChar;
  883.  
  884. { StrLCat appends at most MaxLen - StrLen(Dest) characters from Source to
  885.   the end of Dest, and returns Dest. }
  886.  
  887. function StrLCat(Dest, Source: PChar; MaxLen: Cardinal): PChar;
  888.  
  889. { StrComp compares Str1 to Str2. The return value is less than 0 if
  890.   Str1 < Str2, 0 if Str1 = Str2, or greater than 0 if Str1 > Str2. }
  891.  
  892. function StrComp(Str1, Str2: PChar): Integer;
  893.  
  894. { StrIComp compares Str1 to Str2, without case sensitivity. The return
  895.   value is the same as StrComp. }
  896.  
  897. function StrIComp(Str1, Str2: PChar): Integer;
  898.  
  899. { StrLComp compares Str1 to Str2, for a maximum length of MaxLen
  900.   characters. The return value is the same as StrComp. }
  901.  
  902. function StrLComp(Str1, Str2: PChar; MaxLen: Cardinal): Integer;
  903.  
  904. { StrLIComp compares Str1 to Str2, for a maximum length of MaxLen
  905.   characters, without case sensitivity. The return value is the same
  906.   as StrComp. }
  907.  
  908. function StrLIComp(Str1, Str2: PChar; MaxLen: Cardinal): Integer;
  909.  
  910. { StrScan returns a pointer to the first occurrence of Chr in Str. If Chr
  911.   does not occur in Str, StrScan returns NIL. The null terminator is
  912.   considered to be part of the string. }
  913.  
  914. function StrScan(Str: PChar; Chr: Char): PChar;
  915.  
  916. { StrRScan returns a pointer to the last occurrence of Chr in Str. If Chr
  917.   does not occur in Str, StrRScan returns NIL. The null terminator is
  918.   considered to be part of the string. }
  919.  
  920. function StrRScan(Str: PChar; Chr: Char): PChar;
  921.  
  922. { StrPos returns a pointer to the first occurrence of Str2 in Str1. If
  923.   Str2 does not occur in Str1, StrPos returns NIL. }
  924.  
  925. function StrPos(Str1, Str2: PChar): PChar;
  926.  
  927. { StrUpper converts Str to upper case and returns Str. }
  928.  
  929. function StrUpper(Str: PChar): PChar;
  930.  
  931. { StrLower converts Str to lower case and returns Str. }
  932.  
  933. function StrLower(Str: PChar): PChar;
  934.  
  935. { StrPas converts Str to a Pascal style string. }
  936.  
  937. function StrPas(Str: PChar): String;
  938.  
  939. { StrAlloc allocates a buffer of the given size on the heap. The size of
  940.   the allocated buffer is encoded in a four byte header that immediately
  941.   preceeds the buffer. To dispose the buffer, use StrDispose. }
  942.  
  943. function StrAlloc(Size: Cardinal): PChar;
  944.  
  945. { StrBufSize returns the allocated size of the given buffer, not including
  946.   the two byte header. }
  947.  
  948. function StrBufSize(Str: PChar): Cardinal;
  949.  
  950. { StrNew allocates a copy of Str on the heap. If Str is NIL, StrNew returns
  951.   NIL and doesn't allocate any heap space. Otherwise, StrNew makes a
  952.   duplicate of Str, obtaining space with a call to the StrAlloc function,
  953.   and returns a pointer to the duplicated string. To dispose the string,
  954.   use StrDispose. }
  955.  
  956. function StrNew(Str: PChar): PChar;
  957.  
  958. { StrPNew allocates a copy of Str on the heap. If Str is empty, StrNew returns
  959.   NIL and doesn't allocate any heap space. Otherwise, StrNew makes a
  960.   duplicate of Str, obtaining space with a call to the StrAlloc function,
  961.   and returns a pointer to the duplicated string. To dispose the string,
  962.   use StrDispose. }
  963.  
  964. function StrPNew(Str: String): PChar;
  965.  
  966. { StrDispose disposes a string that was previously allocated with StrAlloc
  967.   or StrNew. If Str is NIL, StrDispose does nothing. }
  968.  
  969. procedure StrDispose(Str: PChar);
  970.  
  971. { String formatting routines }
  972.  
  973. { The Format routine formats the argument list given by the Args parameter
  974.   using the format string given by the Format parameter.
  975.  
  976.   Format strings contain two types of objects--plain characters and format
  977.   specifiers. Plain characters are copied verbatim to the resulting string.
  978.   Format specifiers fetch arguments from the argument list and apply
  979.   formatting to them.
  980.  
  981.   Format specifiers have the following form:
  982.  
  983.     "%" [index ":"] ["-"] [width] ["." prec] type
  984.  
  985.   A format specifier begins with a % character. After the % come the
  986.   following, in this order:
  987.  
  988.   -  an optional argument index specifier, [index ":"]
  989.   -  an optional left-justification indicator, ["-"]
  990.   -  an optional width specifier, [width]
  991.   -  an optional precision specifier, ["." prec]
  992.   -  the conversion type character, type
  993.  
  994.   The following conversion characters are supported:
  995.  
  996.   d  Decimal. The argument must be an integer value. The value is converted
  997.      to a string of decimal digits. If the format string contains a precision
  998.      specifier, it indicates that the resulting string must contain at least
  999.      the specified number of digits; if the value has less digits, the
  1000.      resulting string is left-padded with zeros.
  1001.  
  1002.   e  Scientific. The argument must be a floating-point value. The value is
  1003.      converted to a string of the form "-d.ddd...E+ddd". The resulting
  1004.      string starts with a minus sign if the number is negative, and one digit
  1005.      always precedes the decimal point. The total number of digits in the
  1006.      resulting string (including the one before the decimal point) is given
  1007.      by the precision specifer in the format string--a default precision of
  1008.      15 is assumed if no precision specifer is present. The "E" exponent
  1009.      character in the resulting string is always followed by a plus or minus
  1010.      sign and at least three digits.
  1011.  
  1012.   f  Fixed. The argument must be a floating-point value. The value is
  1013.      converted to a string of the form "-ddd.ddd...". The resulting string
  1014.      starts with a minus sign if the number is negative. The number of digits
  1015.      after the decimal point is given by the precision specifier in the
  1016.      format string--a default of 2 decimal digits is assumed if no precision
  1017.      specifier is present.
  1018.  
  1019.   g  General. The argument must be a floating-point value. The value is
  1020.      converted to the shortest possible decimal string using fixed or
  1021.      scientific format. The number of significant digits in the resulting
  1022.      string is given by the precision specifier in the format string--a
  1023.      default precision of 15 is assumed if no precision specifier is present.
  1024.      Trailing zeros are removed from the resulting string, and a decimal
  1025.      point appears only if necessary. The resulting string uses fixed point
  1026.      format if the number of digits to the left of the decimal point in the
  1027.      value is less than or equal to the specified precision, and if the
  1028.      value is greater than or equal to 0.00001. Otherwise the resulting
  1029.      string uses scientific format.
  1030.  
  1031.   n  Number. The argument must be a floating-point value. The value is
  1032.      converted to a string of the form "-d,ddd,ddd.ddd...". The "n" format
  1033.      corresponds to the "f" format, except that the resulting string
  1034.      contains thousand separators.
  1035.  
  1036.   m  Money. The argument must be a floating-point value. The value is
  1037.      converted to a string that represents a currency amount. The conversion
  1038.      is controlled by the CurrencyString, CurrencyFormat, NegCurrFormat,
  1039.      ThousandSeparator, DecimalSeparator, and CurrencyDecimals global
  1040.      variables, all of which are initialized from the Currency Format in
  1041.      the International section of the Windows Control Panel. If the format
  1042.      string contains a precision specifier, it overrides the value given
  1043.      by the CurrencyDecimals global variable.
  1044.  
  1045.   p  Pointer. The argument must be a pointer value. The value is converted
  1046.      to a string of the form "XXXX:YYYY" where XXXX and YYYY are the
  1047.      segment and offset parts of the pointer expressed as four hexadecimal
  1048.      digits.
  1049.  
  1050.   s  String. The argument must be a character, a string, or a PChar value.
  1051.      The string or character is inserted in place of the format specifier.
  1052.      The precision specifier, if present in the format string, specifies the
  1053.      maximum length of the resulting string. If the argument is a string
  1054.      that is longer than this maximum, the string is truncated.
  1055.  
  1056.   x  Hexadecimal. The argument must be an integer value. The value is
  1057.      converted to a string of hexadecimal digits. If the format string
  1058.      contains a precision specifier, it indicates that the resulting string
  1059.      must contain at least the specified number of digits; if the value has
  1060.      less digits, the resulting string is left-padded with zeros.
  1061.  
  1062.   Conversion characters may be specified in upper case as well as in lower
  1063.   case--both produce the same results.
  1064.  
  1065.   For all floating-point formats, the actual characters used as decimal and
  1066.   thousand separators are obtained from the DecimalSeparator and
  1067.   ThousandSeparator global variables.
  1068.  
  1069.   Index, width, and precision specifiers can be specified directly using
  1070.   decimal digit string (for example "%10d"), or indirectly using an asterisk
  1071.   charcater (for example "%*.*f"). When using an asterisk, the next argument
  1072.   in the argument list (which must be an integer value) becomes the value
  1073.   that is actually used. For example "Format('%*.*f', [8, 2, 123.456])" is
  1074.   the same as "Format('%8.2f', [123.456])".
  1075.  
  1076.   A width specifier sets the minimum field width for a conversion. If the
  1077.   resulting string is shorter than the minimum field width, it is padded
  1078.   with blanks to increase the field width. The default is to right-justify
  1079.   the result by adding blanks in front of the value, but if the format
  1080.   specifier contains a left-justification indicator (a "-" character
  1081.   preceding the width specifier), the result is left-justified by adding
  1082.   blanks after the value.
  1083.  
  1084.   An index specifier sets the current argument list index to the specified
  1085.   value. The index of the first argument in the argument list is 0. Using
  1086.   index specifiers, it is possible to format the same argument multiple
  1087.   times. For example "Format('%d %d %0:d %d', [10, 20])" produces the string
  1088.   '10 20 10 20'.
  1089.  
  1090.   The Format function can be combined with other formatting functions. For
  1091.   example
  1092.  
  1093.     S := Format('Your total was %s on %s', [
  1094.       FormatFloat('$#,##0.00;;zero', Total),
  1095.       FormatDateTime('mm/dd/yy', Date)]);
  1096.  
  1097.   which uses the FormatFloat and FormatDateTime functions to customize the
  1098.   format beyond what is possible with Format. }
  1099.  
  1100. function Format(const Format: string; const Args: array of const): string;
  1101.  
  1102. { FmtStr formats the argument list given by Args using the format string
  1103.   given by Format into the string variable given by Result. For further
  1104.   details, see the description of the Format function. }
  1105.  
  1106. procedure FmtStr(var Result: string; const Format: string;
  1107.   const Args: array of const);
  1108.  
  1109. { StrFmt formats the argument list given by Args using the format string
  1110.   given by Format into the buffer given by Buffer. It is up to the caller to
  1111.   ensure that Buffer is large enough for the resulting string. The returned
  1112.   value is Buffer. For further details, see the description of the Format
  1113.   function. }
  1114.  
  1115. function StrFmt(Buffer, Format: PChar; const Args: array of const): PChar;
  1116.  
  1117. { StrLFmt formats the argument list given by Args using the format string
  1118.   given by Format into the buffer given by Buffer. The resulting string will
  1119.   contain no more than MaxLen characters, not including the null terminator.
  1120.   The returned value is Buffer. For further details, see the description of
  1121.   the Format function. }
  1122.  
  1123. function StrLFmt(Buffer: PChar; MaxLen: Cardinal; Format: PChar;
  1124.   const Args: array of const): PChar;
  1125.  
  1126. { FormatBuf formats the argument list given by Args using the format string
  1127.   given by Format and FmtLen into the buffer given by Buffer and BufLen.
  1128.   The Format parameter is a reference to a buffer containing FmtLen
  1129.   characters, and the Buffer parameter is a reference to a buffer of BufLen
  1130.   characters. The returned value is the number of characters actually stored
  1131.   in Buffer. The returned value is always less than or equal to BufLen. For
  1132.   further details, see the description of the Format function. }
  1133.  
  1134. function FormatBuf(var Buffer; BufLen: Cardinal; const Format;
  1135.   FmtLen: Cardinal; const Args: array of const): Cardinal;
  1136.  
  1137. { Floating point conversion routines }
  1138.  
  1139. { FloatToStr converts the floating-point value given by Value to its string
  1140.   representation. The conversion uses general number format with 15
  1141.   significant digits. For further details, see the description of the
  1142.   FloatToStrF function. }
  1143.  
  1144. function FloatToStr(Value: Extended): string;
  1145.  
  1146. { CurrToStr converts the currency value given by Value to its string
  1147.   representation. The conversion uses general number format. For further
  1148.   details, see the description of the CurrToStrF function. }
  1149.  
  1150. function CurrToStr(Value: Currency): string;
  1151.  
  1152. { FloatToStrF converts the floating-point value given by Value to its string
  1153.   representation. The Format parameter controls the format of the resulting
  1154.   string. The Precision parameter specifies the precision of the given value.
  1155.   It should be 7 or less for values of type Single, 15 or less for values of
  1156.   type Double, and 18 or less for values of type Extended. The meaning of the
  1157.   Digits parameter depends on the particular format selected.
  1158.  
  1159.   The possible values of the Format parameter, and the meaning of each, are
  1160.   described below.
  1161.  
  1162.   ffGeneral - General number format. The value is converted to the shortest
  1163.   possible decimal string using fixed or scientific format. Trailing zeros
  1164.   are removed from the resulting string, and a decimal point appears only
  1165.   if necessary. The resulting string uses fixed point format if the number
  1166.   of digits to the left of the decimal point in the value is less than or
  1167.   equal to the specified precision, and if the value is greater than or
  1168.   equal to 0.00001. Otherwise the resulting string uses scientific format,
  1169.   and the Digits parameter specifies the minimum number of digits in the
  1170.   exponent (between 0 and 4).
  1171.  
  1172.   ffExponent - Scientific format. The value is converted to a string of the
  1173.   form "-d.ddd...E+dddd". The resulting string starts with a minus sign if
  1174.   the number is negative, and one digit always precedes the decimal point.
  1175.   The total number of digits in the resulting string (including the one
  1176.   before the decimal point) is given by the Precision parameter. The "E"
  1177.   exponent character in the resulting string is always followed by a plus
  1178.   or minus sign and up to four digits. The Digits parameter specifies the
  1179.   minimum number of digits in the exponent (between 0 and 4).
  1180.  
  1181.   ffFixed - Fixed point format. The value is converted to a string of the
  1182.   form "-ddd.ddd...". The resulting string starts with a minus sign if the
  1183.   number is negative, and at least one digit always precedes the decimal
  1184.   point. The number of digits after the decimal point is given by the Digits
  1185.   parameter--it must be between 0 and 18. If the number of digits to the
  1186.   left of the decimal point is greater than the specified precision, the
  1187.   resulting value will use scientific format.
  1188.  
  1189.   ffNumber - Number format. The value is converted to a string of the form
  1190.   "-d,ddd,ddd.ddd...". The ffNumber format corresponds to the ffFixed format,
  1191.   except that the resulting string contains thousand separators.
  1192.  
  1193.   ffCurrency - Currency format. The value is converted to a string that
  1194.   represents a currency amount. The conversion is controlled by the
  1195.   CurrencyString, CurrencyFormat, NegCurrFormat, ThousandSeparator, and
  1196.   DecimalSeparator global variables, all of which are initialized from the
  1197.   Currency Format in the International section of the Windows Control Panel.
  1198.   The number of digits after the decimal point is given by the Digits
  1199.   parameter--it must be between 0 and 18.
  1200.  
  1201.   For all formats, the actual characters used as decimal and thousand
  1202.   separators are obtained from the DecimalSeparator and ThousandSeparator
  1203.   global variables.
  1204.  
  1205.   If the given value is a NAN (not-a-number), the resulting string is 'NAN'.
  1206.   If the given value is positive infinity, the resulting string is 'INF'. If
  1207.   the given value is negative infinity, the resulting string is '-INF'. }
  1208.  
  1209. function FloatToStrF(Value: Extended; Format: TFloatFormat;
  1210.   Precision, Digits: Integer): string;
  1211.  
  1212. { CurrToStrF converts the currency value given by Value to its string
  1213.   representation. A call to CurrToStrF corresponds to a call to
  1214.   FloatToStrF with an implied precision of 19 digits. }
  1215.  
  1216. function CurrToStrF(Value: Currency; Format: TFloatFormat;
  1217.   Digits: Integer): string;
  1218.  
  1219. { FloatToText converts the given floating-point value to its decimal
  1220.   representation using the specified format, precision, and digits. The
  1221.   Value parameter must be a variable of type Extended or Currency, as
  1222.   indicated by the ValueType parameter. The resulting string of characters
  1223.   is stored in the given buffer, and the returned value is the number of
  1224.   characters stored. The resulting string is not null-terminated. For
  1225.   further details, see the description of the FloatToStrF function. }
  1226.  
  1227. function FloatToText(Buffer: PChar; const Value; ValueType: TFloatValue;
  1228.   Format: TFloatFormat; Precision, Digits: Integer): Integer;
  1229.  
  1230. { FormatFloat formats the floating-point value given by Value using the
  1231.   format string given by Format. The following format specifiers are
  1232.   supported in the format string:
  1233.  
  1234.   0     Digit placeholder. If the value being formatted has a digit in the
  1235.         position where the '0' appears in the format string, then that digit
  1236.         is copied to the output string. Otherwise, a '0' is stored in that
  1237.         position in the output string.
  1238.  
  1239.   #     Digit placeholder. If the value being formatted has a digit in the
  1240.         position where the '#' appears in the format string, then that digit
  1241.         is copied to the output string. Otherwise, nothing is stored in that
  1242.         position in the output string.
  1243.  
  1244.   .     Decimal point. The first '.' character in the format string
  1245.         determines the location of the decimal separator in the formatted
  1246.         value; any additional '.' characters are ignored. The actual
  1247.         character used as a the decimal separator in the output string is
  1248.         determined by the DecimalSeparator global variable. The default value
  1249.         of DecimalSeparator is specified in the Number Format of the
  1250.         International section in the Windows Control Panel.
  1251.  
  1252.   ,     Thousand separator. If the format string contains one or more ','
  1253.         characters, the output will have thousand separators inserted between
  1254.         each group of three digits to the left of the decimal point. The
  1255.         placement and number of ',' characters in the format string does not
  1256.         affect the output, except to indicate that thousand separators are
  1257.         wanted. The actual character used as a the thousand separator in the
  1258.         output is determined by the ThousandSeparator global variable. The
  1259.         default value of ThousandSeparator is specified in the Number Format
  1260.         of the International section in the Windows Control Panel.
  1261.  
  1262.   E+    Scientific notation. If any of the strings 'E+', 'E-', 'e+', or 'e-'
  1263.   E-    are contained in the format string, the number is formatted using
  1264.   e+    scientific notation. A group of up to four '0' characters can
  1265.   e-    immediately follow the 'E+', 'E-', 'e+', or 'e-' to determine the
  1266.         minimum number of digits in the exponent. The 'E+' and 'e+' formats
  1267.         cause a plus sign to be output for positive exponents and a minus
  1268.         sign to be output for negative exponents. The 'E-' and 'e-' formats
  1269.         output a sign character only for negative exponents.
  1270.  
  1271.   'xx'  Characters enclosed in single or double quotes are output as-is, and
  1272.   "xx"  do not affect formatting.
  1273.  
  1274.   ;     Separates sections for positive, negative, and zero numbers in the
  1275.         format string.
  1276.  
  1277.   The locations of the leftmost '0' before the decimal point in the format
  1278.   string and the rightmost '0' after the decimal point in the format string
  1279.   determine the range of digits that are always present in the output string.
  1280.  
  1281.   The number being formatted is always rounded to as many decimal places as
  1282.   there are digit placeholders ('0' or '#') to the right of the decimal
  1283.   point. If the format string contains no decimal point, the value being
  1284.   formatted is rounded to the nearest whole number.
  1285.  
  1286.   If the number being formatted has more digits to the left of the decimal
  1287.   separator than there are digit placeholders to the left of the '.'
  1288.   character in the format string, the extra digits are output before the
  1289.   first digit placeholder.
  1290.  
  1291.   To allow different formats for positive, negative, and zero values, the
  1292.   format string can contain between one and three sections separated by
  1293.   semicolons.
  1294.  
  1295.   One section - The format string applies to all values.
  1296.  
  1297.   Two sections - The first section applies to positive values and zeros, and
  1298.   the second section applies to negative values.
  1299.  
  1300.   Three sections - The first section applies to positive values, the second
  1301.   applies to negative values, and the third applies to zeros.
  1302.  
  1303.   If the section for negative values or the section for zero values is empty,
  1304.   that is if there is nothing between the semicolons that delimit the
  1305.   section, the section for positive values is used instead.
  1306.  
  1307.   If the section for positive values is empty, or if the entire format string
  1308.   is empty, the value is formatted using general floating-point formatting
  1309.   with 15 significant digits, corresponding to a call to FloatToStrF with
  1310.   the ffGeneral format. General floating-point formatting is also used if
  1311.   the value has more than 18 digits to the left of the decimal point and
  1312.   the format string does not specify scientific notation.
  1313.  
  1314.   The table below shows some sample formats and the results produced when
  1315.   the formats are applied to different values:
  1316.  
  1317.   Format string          1234        -1234       0.5         0
  1318.   -----------------------------------------------------------------------
  1319.                          1234        -1234       0.5         0
  1320.   0                      1234        -1234       1           0
  1321.   0.00                   1234.00     -1234.00    0.50        0.00
  1322.   #.##                   1234        -1234       .5
  1323.   #,##0.00               1,234.00    -1,234.00   0.50        0.00
  1324.   #,##0.00;(#,##0.00)    1,234.00    (1,234.00)  0.50        0.00
  1325.   #,##0.00;;Zero         1,234.00    -1,234.00   0.50        Zero
  1326.   0.000E+00              1.234E+03   -1.234E+03  5.000E-01   0.000E+00
  1327.   #.###E-0               1.234E3     -1.234E3    5E-1        0E0
  1328.   ----------------------------------------------------------------------- }
  1329.  
  1330. function FormatFloat(const Format: string; Value: Extended): string;
  1331.  
  1332. { FormatCurr formats the currency value given by Value using the format
  1333.   string given by Format. For further details, see the description of the
  1334.   FormatFloat function. }
  1335.  
  1336. function FormatCurr(const Format: string; Value: Currency): string;
  1337.  
  1338. { FloatToTextFmt converts the given floating-point value to its decimal
  1339.   representation using the specified format. The Value parameter must be a
  1340.   variable of type Extended or Currency, as indicated by the ValueType
  1341.   parameter. The resulting string of characters is stored in the given
  1342.   buffer, and the returned value is the number of characters stored. The
  1343.   resulting string is not null-terminated. For further details, see the
  1344.   description of the FormatFloat function. }
  1345.  
  1346. function FloatToTextFmt(Buffer: PChar; const Value; ValueType: TFloatValue;
  1347.   Format: PChar): Integer;
  1348.  
  1349. { StrToFloat converts the given string to a floating-point value. The string
  1350.   must consist of an optional sign (+ or -), a string of digits with an
  1351.   optional decimal point, and an optional 'E' or 'e' followed by a signed
  1352.   integer. Leading and trailing blanks in the string are ignored. The
  1353.   DecimalSeparator global variable defines the character that must be used
  1354.   as a decimal point. Thousand separators and currency symbols are not
  1355.   allowed in the string. If the string doesn't contain a valid value, an
  1356.   EConvertError exception is raised. }
  1357.  
  1358. function StrToFloat(const S: string): Extended;
  1359.  
  1360. { StrToCurr converts the given string to a currency value. For further
  1361.   details, see the description of the StrToFloat function. }
  1362.  
  1363. function StrToCurr(const S: string): Currency;
  1364.  
  1365. { TextToFloat converts the null-terminated string given by Buffer to a
  1366.   floating-point value which is returned in the variable given by Value.
  1367.   The Value parameter must be a variable of type Extended or Currency, as
  1368.   indicated by the ValueType parameter. The return value is True if the
  1369.   conversion was successful, or False if the string is not a valid
  1370.   floating-point value. For further details, see the description of the
  1371.   StrToFloat function. }
  1372.  
  1373. function TextToFloat(Buffer: PChar; var Value; ValueType: TFloatValue): Boolean;
  1374.  
  1375. { FloatToDecimal converts a floating-point value to a decimal representation
  1376.   that is suited for further formatting. The Value parameter must be a
  1377.   variable of type Extended or Currency, as indicated by the ValueType
  1378.   parameter. For values of type Extended, the Precision parameter specifies
  1379.   the requested number of significant digits in the result--the allowed range
  1380.   is 1..18. For values of type Currency, the Precision parameter is ignored,
  1381.   and the implied precision of the conversion is 19 digits. The Decimals
  1382.   parameter specifies the requested maximum number of digits to the left of
  1383.   the decimal point in the result. Precision and Decimals together control
  1384.   how the result is rounded. To produce a result that always has a given
  1385.   number of significant digits regardless of the magnitude of the number,
  1386.   specify 9999 for the Decimals parameter. The result of the conversion is
  1387.   stored in the specified TFloatRec record as follows:
  1388.  
  1389.   Exponent - Contains the magnitude of the number, i.e. the number of
  1390.   significant digits to the right of the decimal point. The Exponent field
  1391.   is negative if the absolute value of the number is less than one. If the
  1392.   number is a NAN (not-a-number), Exponent is set to -32768. If the number
  1393.   is INF or -INF (positive or negative infinity), Exponent is set to 32767.
  1394.  
  1395.   Negative - True if the number is negative, False if the number is zero
  1396.   or positive.
  1397.  
  1398.   Digits - Contains up to 18 (for type Extended) or 19 (for type Currency)
  1399.   significant digits followed by a null terminator. The implied decimal
  1400.   point (if any) is not stored in Digits. Trailing zeros are removed, and
  1401.   if the resulting number is zero, NAN, or INF, Digits contains nothing but
  1402.   the null terminator. }
  1403.  
  1404. procedure FloatToDecimal(var Result: TFloatRec; const Value;
  1405.   ValueType: TFloatValue; Precision, Decimals: Integer);
  1406.  
  1407. { Date/time support routines }
  1408.  
  1409. function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
  1410.  
  1411. function TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;
  1412. function MSecsToTimeStamp(MSecs: Comp): TTimeStamp;
  1413. function TimeStampToMSecs(const TimeStamp: TTimeStamp): Comp;
  1414.  
  1415. { EncodeDate encodes the given year, month, and day into a TDateTime value.
  1416.   The year must be between 1 and 9999, the month must be between 1 and 12,
  1417.   and the day must be between 1 and N, where N is the number of days in the
  1418.   specified month. If the specified values are not within range, an
  1419.   EConvertError exception is raised. The resulting value is the number of
  1420.   days between 12/30/1899 and the given date. }
  1421.  
  1422. function EncodeDate(Year, Month, Day: Word): TDateTime;
  1423.  
  1424. { EncodeTime encodes the given hour, minute, second, and millisecond into a
  1425.   TDateTime value. The hour must be between 0 and 23, the minute must be
  1426.   between 0 and 59, the second must be between 0 and 59, and the millisecond
  1427.   must be between 0 and 999. If the specified values are not within range, an
  1428.   EConvertError exception is raised. The resulting value is a number between
  1429.   0 (inclusive) and 1 (not inclusive) that indicates the fractional part of
  1430.   a day given by the specified time. The value 0 corresponds to midnight,
  1431.   0.5 corresponds to noon, 0.75 corresponds to 6:00 pm, etc. }
  1432.  
  1433. function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;
  1434.  
  1435. { DecodeDate decodes the integral (date) part of the given TDateTime value
  1436.   into its corresponding year, month, and day. If the given TDateTime value
  1437.   is less than or equal to zero, the year, month, and day return parameters
  1438.   are all set to zero. }
  1439.  
  1440. procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
  1441.  
  1442. { DecodeTime decodes the fractional (time) part of the given TDateTime value
  1443.   into its corresponding hour, minute, second, and millisecond. }
  1444.  
  1445. procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);
  1446.  
  1447. { DayOfWeek returns the day of the week of the given date. The result is an
  1448.   integer between 1 and 7, corresponding to Sunday through Saturday. }
  1449.  
  1450. function DayOfWeek(Date: TDateTime): Integer;
  1451.  
  1452. { Date returns the current date. }
  1453.  
  1454. function Date: TDateTime;
  1455.  
  1456. { Time returns the current time. }
  1457.  
  1458. function Time: TDateTime;
  1459.  
  1460. { Now returns the current date and time, corresponding to Date + Time. }
  1461.  
  1462. function Now: TDateTime;
  1463.  
  1464. { DateToStr converts the date part of the given TDateTime value to a string.
  1465.   The conversion uses the format specified by the ShortDateFormat global
  1466.   variable. }
  1467.  
  1468. { IncMonth returns Date shifted by the specified number of months.
  1469.   NumberOfMonths parameter can be negative, to return a date N months ago.
  1470.   If the input day of month is greater than the last day of the resulting
  1471.   month, the day is set to the last day of the resulting month.
  1472.   Input time of day is copied to the DateTime result.  }
  1473.  
  1474. function IncMonth(const Date: TDateTime; NumberOfMonths: Integer): TDateTime;
  1475.  
  1476. { IsLeapYear determines whether the given year is a leap year. }
  1477.  
  1478. function IsLeapYear(Year: Word): Boolean;
  1479.  
  1480. { DateToStr converts the date part of the given TDateTime value to a string.
  1481.   The conversion uses the format specified by the ShortDateFormat global
  1482.   variable. }
  1483.  
  1484. function DateToStr(Date: TDateTime): string;
  1485.  
  1486. { TimeToStr converts the time part of the given TDateTime value to a string.
  1487.   The conversion uses the format specified by the LongTimeFormat global
  1488.   variable. }
  1489.  
  1490. function TimeToStr(Time: TDateTime): string;
  1491.  
  1492. { DateTimeToStr converts the given date and time to a string. The resulting
  1493.   string consists of a date and time formatted using the ShortDateFormat and
  1494.   LongTimeFormat global variables. Time information is included in the
  1495.   resulting string only if the fractional part of the given date and time
  1496.   value is non-zero. }
  1497.  
  1498. function DateTimeToStr(DateTime: TDateTime): string;
  1499.  
  1500. { StrToDate converts the given string to a date value. The string must
  1501.   consist of two or three numbers, separated by the character defined by
  1502.   the DateSeparator global variable. The order for month, day, and year is
  1503.   determined by the ShortDateFormat global variable--possible combinations
  1504.   are m/d/y, d/m/y, and y/m/d. If the string contains only two numbers, it
  1505.   is interpreted as a date (m/d or d/m) in the current year. Year values
  1506.   between 0 and 99 are assumed to be in the current century. If the given
  1507.   string does not contain a valid date, an EConvertError exception is
  1508.   raised. }
  1509.  
  1510. function StrToDate(const S: string): TDateTime;
  1511.  
  1512. { StrToTime converts the given string to a time value. The string must
  1513.   consist of two or three numbers, separated by the character defined by
  1514.   the TimeSeparator global variable, optionally followed by an AM or PM
  1515.   indicator. The numbers represent hour, minute, and (optionally) second,
  1516.   in that order. If the time is followed by AM or PM, it is assumed to be
  1517.   in 12-hour clock format. If no AM or PM indicator is included, the time
  1518.   is assumed to be in 24-hour clock format. If the given string does not
  1519.   contain a valid time, an EConvertError exception is raised. }
  1520.  
  1521. function StrToTime(const S: string): TDateTime;
  1522.  
  1523. { StrToDateTime converts the given string to a date and time value. The
  1524.   string must contain a date optionally followed by a time. The date and
  1525.   time parts of the string must follow the formats described for the
  1526.   StrToDate and StrToTime functions. }
  1527.  
  1528. function StrToDateTime(const S: string): TDateTime;
  1529.  
  1530. { FormatDateTime formats the date-and-time value given by DateTime using the
  1531.   format given by Format. The following format specifiers are supported:
  1532.  
  1533.   c       Displays the date using the format given by the ShortDateFormat
  1534.           global variable, followed by the time using the format given by
  1535.           the LongTimeFormat global variable. The time is not displayed if
  1536.           the fractional part of the DateTime value is zero.
  1537.  
  1538.   d       Displays the day as a number without a leading zero (1-31).
  1539.  
  1540.   dd      Displays the day as a number with a leading zero (01-31).
  1541.  
  1542.   ddd     Displays the day as an abbreviation (Sun-Sat) using the strings
  1543.           given by the ShortDayNames global variable.
  1544.  
  1545.   dddd    Displays the day as a full name (Sunday-Saturday) using the strings
  1546.           given by the LongDayNames global variable.
  1547.  
  1548.   ddddd   Displays the date using the format given by the ShortDateFormat
  1549.           global variable.
  1550.  
  1551.   dddddd  Displays the date using the format given by the LongDateFormat
  1552.           global variable.
  1553.  
  1554.   m       Displays the month as a number without a leading zero (1-12). If
  1555.           the m specifier immediately follows an h or hh specifier, the
  1556.           minute rather than the month is displayed.
  1557.  
  1558.   mm      Displays the month as a number with a leading zero (01-12). If
  1559.           the mm specifier immediately follows an h or hh specifier, the
  1560.           minute rather than the month is displayed.
  1561.  
  1562.   mmm     Displays the month as an abbreviation (Jan-Dec) using the strings
  1563.           given by the ShortMonthNames global variable.
  1564.  
  1565.   mmmm    Displays the month as a full name (January-December) using the
  1566.           strings given by the LongMonthNames global variable.
  1567.  
  1568.   yy      Displays the year as a two-digit number (00-99).
  1569.  
  1570.   yyyy    Displays the year as a four-digit number (0000-9999).
  1571.  
  1572.   h       Displays the hour without a leading zero (0-23).
  1573.  
  1574.   hh      Displays the hour with a leading zero (00-23).
  1575.  
  1576.   n       Displays the minute without a leading zero (0-59).
  1577.  
  1578.   nn      Displays the minute with a leading zero (00-59).
  1579.  
  1580.   s       Displays the second without a leading zero (0-59).
  1581.  
  1582.   ss      Displays the second with a leading zero (00-59).
  1583.  
  1584.   t       Displays the time using the format given by the ShortTimeFormat
  1585.           global variable.
  1586.  
  1587.   tt      Displays the time using the format given by the LongTimeFormat
  1588.           global variable.
  1589.  
  1590.   am/pm   Uses the 12-hour clock for the preceding h or hh specifier, and
  1591.           displays 'am' for any hour before noon, and 'pm' for any hour
  1592.           after noon. The am/pm specifier can use lower, upper, or mixed
  1593.           case, and the result is displayed accordingly.
  1594.  
  1595.   a/p     Uses the 12-hour clock for the preceding h or hh specifier, and
  1596.           displays 'a' for any hour before noon, and 'p' for any hour after
  1597.           noon. The a/p specifier can use lower, upper, or mixed case, and
  1598.           the result is displayed accordingly.
  1599.  
  1600.   ampm    Uses the 12-hour clock for the preceding h or hh specifier, and
  1601.           displays the contents of the TimeAMString global variable for any
  1602.           hour before noon, and the contents of the TimePMString global
  1603.           variable for any hour after noon.
  1604.  
  1605.   /       Displays the date separator character given by the DateSeparator
  1606.           global variable.
  1607.  
  1608.   :       Displays the time separator character given by the TimeSeparator
  1609.           global variable.
  1610.  
  1611.   'xx'    Characters enclosed in single or double quotes are displayed as-is,
  1612.   "xx"    and do not affect formatting.
  1613.  
  1614.   Format specifiers may be written in upper case as well as in lower case
  1615.   letters--both produce the same result.
  1616.  
  1617.   If the string given by the Format parameter is empty, the date and time
  1618.   value is formatted as if a 'c' format specifier had been given.
  1619.  
  1620.   The following example:
  1621.  
  1622.     S := FormatDateTime('"The meeting is on" dddd, mmmm d, yyyy, ' +
  1623.       '"at" hh:mm AM/PM', StrToDateTime('2/15/95 10:30am'));
  1624.  
  1625.   assigns 'The meeting is on Wednesday, February 15, 1995 at 10:30 AM' to
  1626.   the string variable S. }
  1627.  
  1628. function FormatDateTime(const Format: string; DateTime: TDateTime): string;
  1629.  
  1630. { DateTimeToString converts the date and time value given by DateTime using
  1631.   the format string given by Format into the string variable given by Result.
  1632.   For further details, see the description of the FormatDateTime function. }
  1633.  
  1634. procedure DateTimeToString(var Result: string; const Format: string;
  1635.   DateTime: TDateTime);
  1636.  
  1637. { System error messages }
  1638.  
  1639. function SysErrorMessage(ErrorCode: Integer): string;
  1640.  
  1641. { GetFormatSettings resets all date and number format variables to their
  1642.   default values. }
  1643.  
  1644. procedure GetFormatSettings;
  1645.  
  1646. { FreeAndNil frees the given TObject instance and sets the variable reference
  1647.   to nil.  Be careful to only pass TObjects to this routine. }
  1648.  
  1649. procedure FreeAndNil(var Obj);
  1650.  
  1651. { Exception handling routines }
  1652.  
  1653. function ExceptObject: TObject;
  1654. function ExceptAddr: Pointer;
  1655.  
  1656. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  1657.  
  1658. procedure Abort;
  1659.  
  1660. procedure OutOfMemoryError;
  1661.  
  1662. procedure Beep;
  1663.  
  1664. { For console applications only. Specifies whether error messages
  1665.   should be displayed in a popup window or not }
  1666.  
  1667. const
  1668.   PopupErrors: Boolean = False;
  1669.   IsLibrary: Boolean = False;   // Delphi 32: Declared in the System unit
  1670.   InitProc: Pointer = nil;      // Delphi 32: Declared in the System unit
  1671.  
  1672. {$R SYSUTILS.RES}
  1673.  
  1674. implementation
  1675.  
  1676. begin
  1677. end.
  1678.