Please enable JavaScript to view this site.

KOL/MCK - User Guide

function Int2Hex( Value: DWord; Digits: Integer ): KOLString;

Converts integer Value into string with hex number. Digits parameter determines minimal number of digits (will be completed by adding necessary number of leading zeroes).

 

function Int2Str( Value: Integer ): KOLString;

Converts an integer to a string.

 

procedure Int2PChar( s: PAnsiChar; Value: Integer );

Converts Value to string and puts it into buffer s. Buffer must have enough size to store the number converted: buffer overflow does not checked anyway!

 

function UInt2Str( Value: DWORD ): AnsiString;

The same as Int2Str, but for unsigned integer value.

 

function Int2StrEx( Value, MinWidth: Integer ): KOLString;

Like Int2Str, but resulting string filled with leading spaces to provide at least MinWidth characters.

 

function Int2Rome( Value: Integer ): KOLString;

Represents number 1..8999 to Rome number.

 

function Int2Ths( I: Integer ): KOLString;

Converts integer into string, separating every three digits from each other by character ThsSeparator. (Convert to thousands).

 

function Int2Digs( Value, Digits: Integer ): KOLString;

Converts integer to string, inserting necessary number of leading zeroes to provide desired length of string, given by Digits parameter. If resulting string is greater then Digits, string is not truncated anyway.

 

function Num2Bytes( Value: Double ): KOLString;

Converts double float to string, considering it as a bytes count. If Value is sufficiently large, number is represented in kilobytes (with following letter K), or in megabytes (M), gigabytes (G) or terabytes (T). Resulting string number is truncated to two decimals (.XX) or to one (.X), if the second is 0.

 

function S2Int( S: PKOLChar ): Integer;

Converts null-terminated string to Integer. Scanning stopped when any non-digit character found. Even empty string or string not containing valid integer number silently converted to 0.

 

function Str2Int( const Value: KOLString ): Integer;

Converts string to integer. First character, which can not be recognized as a part of number, regards as a separator. Even empty string or string without number silently converted to 0.

 

function Hex2Int( const Value: KOLString ): Integer;

Converts hexadecimal number to integer. Scanning is stopped when first non-hexadicimal character is found. Leading dollar ('$') character is skept (if present). Minus ('-') is not concerning as a sign of number and also stops scanning.

 

function cHex2Int( const Value: KOLString ): Integer;

As Hex2Int, but also checks for leading '0x' and skips it.

 

function Octal2Int( const Value: AnsiString ): Integer;

Converts octal number to integer. Scanning is stopped on first non-octal digit (any char except 0..7). There are no checking if there octal numer in the parameter. If the first char is not octal digit, 0 is returned.

 

function Binary2Int( const Value: AnsiString ): Integer;

Converts binary number to integer. Like Octal2Int, but only digits 0 and 1 are allowed.

 

function ToRadix( number: Radix_int; radix, min_digits: Integer ): KOLString;

Converts unsigned number to string representing it literally in a numeric base given by radix parameter.

 

function FromRadixStr( var Rslt: Radix_int; s: PKOLChar; radix: Integer ): PKOLChar;

Converts unsigned number from string representation in a numeric base given by a radix parameter. Returns a pointer to a character next to the last digit of the number.

 

function FromRadix( const s: AnsiString; radix: Integer ): Radix_int;

Converts unsigned number from string representation in a numeric base given by a radix parameter. See also: FromRadixStr function.

 

function InsertSeparators( const s: KOLString; chars_between: Integer; Separator: KOLChar ): KOLString;

Inserts given Separator between symbols in s, separating each portion of chars_between characters with a Separator starting from right side. See also: Int2Ths function.

 

function oem2char( const s: AnsiString ): AnsiString;

Converts string from OEM to ANSI.

 

function ansi2oem( const s: AnsiString ): AnsiString;

Converts ANSI string to OEM.

 

function smartOem2ansiRus( const s: AnsiString ): AnsiString;

Smartly converts string from OEM to ANSI (only Russian!). See code.

 

function StrComp( const Str1, Str2: PAnsiChar ): Integer;

Compares two strings fast. -1: Str1<Str2; 0: Str1=Str2; +1: Str1>Str2

 

function StrLComp_NoCase( const Str1, Str2: PAnsiChar; MaxLen: Cardinal ): Integer;

Compare two strings fast without case sensitivity. Terminating 0 is not considered, so if strings are equal, comparing is continued up to MaxLen bytes. Since this, pass minimum of lengths as MaxLen.

 

function StrComp_NoCase( const Str1, Str2: PAnsiChar ): Integer;

Compares two strings fast without case sensitivity. Returns: -1 when Str1<Str2; 0 when Str1=Str2; +1 when Str1>Str2

 

function StrLComp( const Str1, Str2: PAnsiChar; MaxLen: Cardinal ): Integer;

Compare two strings (fast). Terminating 0 is not considered, so if strings are equal, comparing is continued up to MaxLen bytes. Since this, pass minimum of lengths as MaxLen.

 

function StrCopy( Dest, Source: PAnsiChar ): PAnsiChar;

Copy source string to destination (fast). Pointer to Dest is returned.

 

function StrCat( Dest, Source: PAnsiChar ): PAnsiChar;

Append source string to destination (fast). Pointer to Dest is returned.

 

function StrLen( const Str: PAnsiChar ): Cardinal;

StrLen returns the number of characters in Str, not counting the null terminator.

 

function StrScanLen( Str: PAnsiChar; Chr: AnsiChar; Len: Integer ): PAnsiChar;

Fast scans string Str of length Len searching character Chr. Pointer to a character next to found or to Str[Len] (if no one found) is returned.

 

function StrScan( Str: PAnsiChar; Chr: AnsiChar ): PAnsiChar;

Fast search of given character in a string. Pointer to found character (or nil) is returned.

 

function StrRScan( Str: PAnsiChar; Chr: AnsiChar ): PAnsiChar;

StrRScan returns a pointer to the last occurrence of Chr in Str. If Chr does not occur in Str, StrRScan returns NIL. The null terminator is considered to be part of the string.

 

function StrIsStartingFrom( Str, Pattern: PKOLChar ): Boolean;

Returns True, if string Str is starting from Pattern, i.e. if Copy( Str, 1, StrLen( Pattern ) ) = Pattern. Str must not be nil!

 

function StrIsStartingFromNoCase( Str, Pattern: PAnsiChar ): Boolean;

Like StrIsStartingFrom above, but without case sensitivity.

 

function TrimLeft( const S: KOLString ): KOLString;

Removes spaces, tabulations and control characters from the starting of string S.

 

function TrimRight( const S: KOLString ): KOLString;

Removes spaces, tabulates and other control characters from the end of string S.

 

function Trim( const S: KOLString ): KOLString;

Makes TrimLeft and TrimRight for given string.

 

function RemoveSpaces( const S: KOLString ): KOLString;

Removes all characters less or equal to ' ' in S and returns it.

 

procedure Str2LowerCase( S: PAnsiChar );

Converts null-terminated string to lowercase (inplace).

 

function LowerCase( const S: Ansistring ): Ansistring;

Converts Ansistring to lowercase.

 

function UpperCase( const S: Ansistring ): Ansistring;

Converts Ansistring to uppercase.

 

function AnsiUpperCase( const S: Ansistring ): Ansistring;

Converts Ansistring to uppercase.

 

function AnsiLowerCase( const S: Ansistring ): Ansistring;

Converts Ansistring to lowercase.

 

function KOLUpperCase( const S: KOLString ): KOLString;

Converts KOLstring to uppercase.

 

function KOLLowerCase( const S: KOLString ): KOLString;

Converts KOLstring to lowercase.

 

function WUpperCase( const S: KOLWideString ): KOLWideString;

Converts KOLwidestring to uppercase.

 

function WLowerCase( const S: KOLWideString ): KOLWideString;

Converts KOLWidestring to lowercase.

 

function WAnsiUpperCase( const S: KOLWideString ): KOLWideString;

Converts KOLwideansistring to uppercase.

 

function WAnsiLowerCase( const S: KOLWideString ): KOLWideString;

Converts KOLwideansistring to lowercase.

 

function WStrComp( const S1, S2: KOLWideString ): Integer;

Compare two KOLwidestrings (fast). Terminating 0 is not considered, so if strings are equal, comparing is continued up to MaxLen bytes. Since this, pass minimum of lengths as MaxLen.

 

function _WStrComp( S1, S2: PWideChar ): Integer;

 

function _WStrLComp( S1, S2: PWideChar; Len: Integer ): Integer;

 

function WStrScan( Str: PWideChar; Chr: WideChar ): PWideChar;

Fast search of given character in a string. Pointer to found character (or nil) is returned.

 

function WStrRScan( Str: PWideChar; Chr: WideChar ): PWideChar;

StrRScan returns a pointer to the last occurrence of Chr in Str. If Chr does not occur in Str, StrRScan returns NIL. The null terminator is considered to be part of the string.

 

function AnsiCompareStr( const S1, S2: KOLString ): Integer;

AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

 

function _AnsiCompareStr( S1, S2: PKOLChar ): Integer;

The same, but for PChar ANSI strings

 

function AnsiCompareStrNoCase( const S1, S2: KOLString ): Integer;

AnsiCompareStrNoCase compares S1 to S2, without case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

 

function _AnsiCompareStrNoCase( S1, S2: PKOLChar ): Integer;

The same, but for PChar ANSI strings

 

function AnsiCompareText( const S1, S2: KOLString ): Integer;

 

function AnsiEq( const S1, S2: KOLString ): Boolean;

Returns True, if AnsiLowerCase(S1) = AnsiLowerCase(S2). I.e., if ANSI stringsare equal to each other without caring of characters case sensitivity.

 

function AnsiCompareStrA( const S1, S2: AnsiString ): Integer;

AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

 

function _AnsiCompareStrA( S1, S2: PAnsiChar ): Integer;

The same, but for PChar ANSI strings.

 

function AnsiCompareStrNoCaseA( const S1, S2: AnsiString ): Integer;

AnsiCompareStr compares S1 to S2, with case-sensitivity. The compare operation is controlled by the current Windows locale. The return value is the same as for CompareStr.

 

function _AnsiCompareStrNoCaseA( S1, S2: PAnsiChar ): Integer;

The same, but for PChar ANSI strings.

 

function AnsiCompareTextA( const S1, S2: AnsiString ): Integer;

 

function LStrFromPWCharLen( Source: PWideChar; Length: Integer ): AnsiString;

from Delphi5 - because D2 does not contain it.

 

function LStrFromPWChar( Source: PWideChar ): AnsiString;

from Delphi5 - because D2 does not contain it.

 

function CopyEnd( const S: KOLString; Idx: Integer ): KOLString;

Returns copy of source string S starting from Idx up to the end of string S. Works correctly for case, when Idx > Length( S ) (returns empty string for such case).

 

function CopyTail( const S: KOLString; Len: Integer ): KOLString;

Returns last Len characters of the source string. If Len > Length( S ), entire string S is returned.

 

procedure DeleteTail( var S: KOLString; Len: Integer );

Deletes last Len characters from string.

 

function IndexOfChar( const S: KOLString; Chr: KOLChar ): Integer;

Returns index of given character (1..Length(S)), or -1 if a character not found.

 

function IndexOfCharsMin( const S, Chars: KOLString ): Integer;

Returns index (in string S) of those character, what is taking place in Chars string and located nearest to start of S. If no such characters in string S found, -1 is returned.

 

function IndexOfWideCharsMin( const S, Chars: KOLWideString ): Integer;

Returns index (in wide string S) of those wide character, what is taking place in Chars wide string and located nearest to start of S. If no such characters in string S found, -1 is returned.

 

function IndexOfStr( const S, Sub: KOLString ): Integer;

Returns index of given substring in source string S. If found, 1..Length(S)-Length(Sub), if not found, -1.

 

function Parse( var S: KOLString; const Separators: KOLString ): KOLString;

Returns first characters of string S, separated from others by one of characters, taking place in Separators string, assigning a tail of string (after found separator) to source string. If no separator characters found, source string S is returned, and source string itself becomes empty.

 

function WParse( var S: KOLWideString; const Separators: KOLWideString ): KOLWideString;

Returns first wide characters of wide string S, separated from others by one of wide characters, taking place in Separators wide string, assigning a tail of wide string (following found separator) to the source one. If there are no separator characters found, source wide string S is returned, and source wide

string itself becomes empty.

 

function ParsePascalString( var S: KOLString; const Separators: KOLString ): KOLString;

Returns first characters of string S, separated from others by one of characters, taking place in Separators string, assigning a tail of string (after the found separator) to source string. If there are no separator characters found, the source string S is returned, and the source string itself becomes empty. Additionally: if the first (after a blank space) is the quote "'" or '#', pascal string is assumung first and is converted to usual string (without quotas) before analizing of other separators.

 

function String2PascalStrExpr( const S: KOLString ): KOLString;

Converts string to Pascal-like string expression (concatenation of strings with quotas and characters with leading '#').

 

function StrEq( const S1, S2: AnsiString ): Boolean;

Returns True, if LowerCase(S1) = LowerCase(S2). I.e., if strings are equal to each other without caring of characters case sensitivity (ASCII only).

 

function WAnsiEq( const S1, S2: KOLWideString ): Boolean;

Returns True, if AnsiLowerCase(S1) = AnsiLowerCase(S2). I.e., if ANSI stringsare equal to each other without caring of characters case sensitivity.

 

function StrIn( const S: AnsiString; const A: array of AnsiString ): Boolean;

Returns True, if S is "equal" to one of strings, taking place in A array. To check equality, StrEq function is used, i.e. comaprison is taking place without case sensitivity.

 

function WStrIn( const S: KOLWideString; const A: array of KOLWideString ): Boolean;

Returns True, if S is "equal" to one of strings, taking place in A array. To check equality, WAnsiEq function is used, i.e. comaprison is taking place without case sensitivity.

 

function CharIn( C: KOLChar; const A: TSetOfChar ): Boolean;

To replace expressions like S[1] in [ '0'..'z' ] to CharIn( S[ 1 ], [ '0'..'z' ] ) (and to avoid problems with Unicode version of code).

 

function StrIs( const S: AnsiString; const A: Array of AnsiString; var Idx: Integer ): Boolean;

Returns True, if S is "equal" to one of strings, taking place in A array, and in such Case Idx also is assigned to an index of A element equal to S. To check equality, StrEq function is used, i.e. comaprison is taking place without case sensitivity.

 

function IntIn( Value: Integer; const List: array of Integer ): Boolean;

Returns TRUE, if Value is found in a List.

 

function _StrSatisfy( S, Mask: PKOLChar ): Boolean;

 

function _2StrSatisfy( S, Mask: PKOLChar ): Boolean;

 

function StrSatisfy( const S, Mask: KOLString ): Boolean;

Returns True, if S is satisfying to a given Mask (which can contain wildcard symbols '*' and '?' interpeted correspondently as 'any set of characters' and 'single any character'. If there are no such wildcard symbols in a Mask, result is True only if S is maching to Mask string.)

 

function StrReplace( var S: KOLString; const From, ReplTo: KOLString ): Boolean;

Replaces first occurance of From to ReplTo in S, returns True, if pattern From was found and replaced.

 

function KOLStrReplace( var S: KOLString; const From, ReplTo: KOLString ): Boolean;

Replaces first occurance of From to ReplTo in S, returns True, if pattern From was found and replaced.

 

function WStrReplace( var S: KOLWideString; const From, ReplTo: KOLWideString ): Boolean;

Replaces first occurance of From to ReplTo in S, returns True, if pattern From was found and replaced. See also function StrReplace. This function is not available in Delphi2 (this version of Delphi does not support KOLWideString type).

 

function StrRepeat( const S: KOLString; Count: Integer ): KOLString;

Repeats given string Count times. E.g., StrRepeat( 'A', 5 ) gives 'AAAAA'.

 

function WStrRepeat( const S: KOLWideString; Count: Integer ): KOLWideString;

Repeats given wide string Count times. E.g., StrRepeat( 'A', 5 ) gives 'AAAAA'.

 

procedure NormalizeUnixText( var S: AnsiString );

In the string S, replaces all occurances of character #10 (without leading #13) to the character #13.

 

procedure Koi8ToAnsi( s: PAnsiChar );

Converts Koi8 text to Ansi (in place)

 

function StrPCopy( Dest: PAnsiChar; const Source: Ansistring ): PAnsiChar;

Copy string into null-terminated.

 

function StrLCopy( Dest: PAnsiChar; const Source: PAnsiChar; MaxLen: Cardinal ): PAnsiChar;

Copy first MaxLen characters of the Source string into null-terminated Dest.

 

function DelimiterLast( const Str, Delimiters: KOLString ): Integer;

Returns index of the last of delimiters given by same named parameter among characters of Str. If there are no delimiters found, length of Str is returned. This function is intended mainly to use in filename parsing functions.

 

function __DelimiterLast( Str, Delimiters: PKOLChar ): PKOLChar;

Returns address of the last of delimiters given by Delimiters parameter among characters of Str. If there are no delimeters found, position of the null terminator in Str is returned. This function is intended mainly to use in filename parsing functions.

 

function W__DelimiterLast( Str, Delimiters: PWideChar ): PWideChar;

 

function SkipSpaces( P: PKOLChar ): PKOLChar;

Skips all characters ' ' in a string.

 

function CompareMem( P1, P2: Pointer; Length: Integer ): Boolean;

Fast compare of two memory blocks.

 

function AllocMem( Size: Integer ): Pointer;

Allocates global memory and unlocks it.

 

procedure DisposeMem( var Addr: Pointer );

Locks global memory block given by pointer, and frees it. Does nothing, if the pointer is nil.

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC