unit sysutils

Various system utilities

author: Tomasz Biela (Tebe)


http://www.freepascal.org/docs-html/rtl/sysutils/index-5.html

Constants:

name:value:description:
faReadOnly$01
faHidden$02
faSysFile$04
faVolumeID$08
faDirectory$10
faArchive$20
faAnyFile$3f

Types:

name:type:description:
TSearchRecrecord
  • Attr: Byte;
  • ExcludeAttr: Byte;
  • Name: TString;
  • FindHandle: Pointer;

end;

Interface:

name:description:
Beep

procedure Beep;


Sound the system bell
    Click

    procedure Click ; assembler;


    Sound the system click
      GetTickCount

      function GetTickCount: cardinal; assembler;


      Get tick count
        returns:
      • 32bit tick count
      FindFirst

      function FindFirst(const FileMask: TString; Attributes: Byte; var SearchResult: TSearchRec): byte;


      Start a file search and return a findhandle
        parameters:
      • FileMask: string[32]
      • Attributes: Byte
      • SearchResult: TSearchRec
      • returns:
      • =0 file matching the specified criteria is found
      FindNext

      function FindNext(var f: TSearchRec): byte; assembler;


      Find the next entry in a findhandle
        parameters:
      • var f: TSearchRec
      • returns:
      • =0 record matching the criteria, successful
      FindClose

      procedure FindClose(var f: TSearchRec); assembler;


      Close a find handle
        parameters:
      • var f: TSearchRec
      RenameFile

      function RenameFile(var OldName,NewName: TString): Boolean; assembler;


      Renames a file from OldName to NewName
        parameters:
      • var OldName: string[32]
      • var NewName: string[32]
      • returns:
      • TRUE - successful
      • FALSE - I/O error
      DeleteFile

      function DeleteFile(var FileName: TString): Boolean; assembler;


      Delete a file from the filesystem
        parameters:
      • var FileName: string[32]
      • returns:
      • TRUE - the file was successfully removed
      • FALSE - I/O error
      FileExists

      function FileExists(name: PString): Boolean;


      Check whether a particular file exists in the filesystem
        parameters:
      • name: string[32]
      • returns:
      • TRUE - file exists
      • FALSE - file not exists
      ByteToStr

      function ByteToStr(a: byte): TString; assembler;


      Converts input byte to a string
      https://codebase64.org/doku.php?id=base:tiny_.a_to_ascii_routine
        parameters:
      • a: byte
      • returns:
      • pointer to string.Y = hundreds, .X = tens, .A = ones
      IntToStr

      function IntToStr(a: integer): TString; assembler; stdcall; overload;


      Convert an INTEGER value to a decimal string
        parameters:
      • a: integer
      • returns:
      • pointer to string
      IntToStr

      function IntToStr(a: cardinal): TString; assembler; stdcall; overload;


      Convert an CARDINAL value to a decimal string
        parameters:
      • a: cardinal
      • returns:
      • pointer to string
      StrToInt

      function StrToInt(const s: char): byte; assembler; overload;


      Convert a char to an byte value
        parameters:
      • s: char
      • returns:
      • byte
      StrToInt

      function StrToInt(s: PString): integer; assembler; overload;


      Convert a string to an integer value
        parameters:
      • s: string[32]
      • returns:
      • integer (32bit)
      TryStrToInt

      function TryStrToInt(s: PString; var i: integer): Boolean; assembler; overload;


      TryStrToInt tries to convert the string S to an integer, and returns True if this was successful. In that case the converted integer is returned in I. If the conversion failed, (an invalid string, or the value is out of range) then False is returned.
        parameters:
      • s: string[32]
      • returns:
      • i - integer (32bit)result - Boolean
      TryStrToInt

      function TryStrToInt(s: PString; var i: byte): Boolean; assembler; overload;


      TryStrToInt tries to convert the string S to an byte, and returns True if this was successful. In that case the converted integer is returned in I. If the conversion failed, (an invalid string, or the value is out of range) then False is returned.
        parameters:
      • s: string[32]
      • returns:
      • i - byteresult - Boolean
      IntToHex

      function IntToHex(Value: cardinal; Digits: byte): TString; register; assembler;


      Convert an integer value to a hexadecimal string
        parameters:
      • Value: cardinal (32bit)
      • Digits - number of characters
      • returns:
      • string[32]
      StrToFloat

      function StrToFloat(var s: string): real;


      Convert a string to a floating-point value
        parameters:
      • var s: string[32]
      • returns:
      • real (Q24.8)
      ExtractFileExt

      function ExtractFileExt(a: PString): TString;


      Return the extension from a filename
        parameters:
      • const a: string[255]
      • returns:
      • string[32]
      ExtractFilePath

      function ExtractFilePath(a: PString): string;


      Extract the path from a filename
        parameters:
      • const a: string[255]
      • returns:
      • string[255]
      AnsiUpperCase

      function AnsiUpperCase(a: PString): string; register;


      Return an uppercase version of a string
        parameters:
      • a: PString
      • returns:
      • string[255]
      AnsiLowerCase

      function AnsiLowerCase(a: PString): string; register;


      AnsiLowerCase converts the string S to lowercase characters and returns the resulting string.
        parameters:
      • a: PString
      • returns:
      • string[255]
      Now

      function Now: TDateTime;


      Read actual Date-Time (Sparta DOS X, R-Time 8, SIO Real-Time Clock)
        returns:
      • TDateTime
      Date

      function Date: TDateTime;


      Read actual Date
        returns:
      • TDateTime
      DateToStr

      function DateToStr(d: TDateTime): TString;


      Converts a TDateTime value to a date string.
        parameters:
      • d: TDateTime
      • returns:
      • TString
      TimeToStr

      function TimeToStr(d: TDateTime): TString;


      Converts a TDateTime value to a time string.
        parameters:
      • d: TDateTime
      • returns:
      • TString
      DecodeDate

      procedure DecodeDate(d: TDateTime; var yy,mm,dd: byte);


      Decode a TDateTime to a year,month,day triplet
        parameters:
      • d: TDateTime
      • yy: byte - year
      • mm: byte - month
      • dd: byte - day
      DecodeTime

      procedure DecodeTime(d: TDateTime; var h,m,s: byte);


      Decode a TDateTime to a hour,minute,second triplet
        parameters:
      • d: TDateTime
      • h: byte - hour
      • m: byte - minute
      • s: byte - second
      DecodeDateTime

      procedure DecodeDateTime(d: TDateTime; var yy,mm,dd,h,m,s: byte);


      Decode a TDateTime to a year,month,day, hour,minute,second
        parameters:
      • d: TDateTime
      • yy: byte - year
      • mm: byte - month
      • dd: byte - day
      • h: byte - hour
      • m: byte - minute
      • s: byte - second
      BoolToStr

      function BoolToStr(B: Boolean; UseBoolStrs: Boolean): TString;


      BoolToStr converts the boolean B to one of the strings 'TRUE' or 'FALSE'
        parameters:
      • B: Boolean
      • UseBoolStrs: Boolean
      • returns:
      • TString
      StrToBool

      function StrToBool(S: PString): Boolean;


      StrToBool will convert the string S to a boolean value. The string S can contain one of 'True', 'False' (case is ignored) or a numerical value. If it contains a numerical value, 0 is converted to False, all other values result in True.
        parameters:
      • S: TString
      • returns:
      • Boolean
      IsLeapYear

      function IsLeapYear(Year: Word): boolean;


      IsLeapYear returns True if Year is a leap year, False otherwise.
        parameters:
      • Year: Word
      • returns:
      • Boolean
      EncodeDate

      function EncodeDate(Year, Month, Day: Byte): TDateTime;


      EncodeDate encodes the Year, Month and Day variables to a date in TDateTime format. It does the opposite of the DecodeDate procedure.
        parameters:
      • Year: Byte
      • Month: Byte
      • Day: Byte
      • returns:
      • TDateTime
      EncodeTime

      function EncodeTime(Hour, Minute, Second: Byte): TDateTime;


      EncodeTime encodes the Hour, Minute and Second variables to a date in TDateTime format. It does the opposite of the DecodeTime procedure.
        parameters:
      • Hour: Byte
      • Minute: Byte
      • Second: Byte
      • returns:
      • TDateTime
      EncodeDateTime

      function EncodeDateTime(Year, Month, Day, Hour, Minute, Second: Byte): TDateTime;


      EncodeDateTime encodes the values Year, Month, Day, Hour, Minute and Second to a date/time valueand returns this value.
        parameters:
      • Year: Byte
      • Month: Byte
      • Day: Byte
      • Hour: Byte
      • Minute: Byte
      • Second: Byte
      • returns:
      • TDateTime
      Trim

      function Trim(var S: string): string;


      Trim whitespace from the ends of a string.
        parameters:
      • S: String