Unit
StrUtils
Constants:
Digit Chars
WaitCursor
Type
TFillDirection
TVertAlignment
Routine
ActivatePrevInstance
ActivateWindow
AllocMemo
AnsiUpperFirstChar
AssignBitmapCell
CenterControl
CenterWindow
ChangeBitmapColor
CompareMem
CopyParentImage
CreateBitmapFromIcon
CreateTwoColorsBrushPattern
DefineCursor
Delay
DialogUnitsToPixelsX
DialogUnitsToPixelsY
DrawBitmapRectTransparent
DrawBitmapTransparent
DrawCellBitmap
DrawCellText
DrawInvertFrame
FreeMemo
FreeUnusedOLE
GetEnvVar
GetMemoSize
GradientFillRect
HeightOf
HugeDec
HugeInc
HugeMove
HugeOffset
KillMessage
LoadAniCursor
LoadDLL
MakeBitmap
MakeBitmapID
MakeIcon
MakeIconID
MakeModuleBitmap
MakeModuleIcon
MergeForm
MinimizeText
MsgBox
NotImplemented
PaintInverseRect
PixelsToDialogUnitsX
PixelsToDialogUnitsY
PointInPolyRgn
PointInRect
RegisterServer
ResourceNotFound
ShadeRect
SplitCommandLine
StartWait
StopWait
WidthOf
Win32Check
Const DigitChars
Declaration: DigitChars = ['0'..'9'];;
Digits constant.
Type TCharSet
Declaration: TCharSet = set of Char;
TCharSet is used to specify symbols arrays in procedures and functions of StrUtils unit.
Routine AddChar
Declaration: function AddChar(C: Char; const S: string; N: Integer): string;
AddChar return a string left-padded to length N with characters C.
AddChar example:
__S
:= 'Let It Be';
__S
:= AddChar(' ', S, 10);
__{
here S = ' Let It Be' }
Routine AddCharR
Declaration: function AddCharR(C: Char; const S: string; N: Integer): string;
AddCharR return a string right-padded to length N with characters C.
AddCharR example:
__S
:= 'Let It Be';
__S
:= AddChar(' ', S, 10);
__{
here S = 'Let It Be ' }
Routine
AnsiProperCase
Declaration: function AnsiProperCase(const S: string; const WordDelims:
TCharSet): string;
Returns string, with the first letter of each word in uppercase, all other letters in lowercase. Words are delimited by WordDelims.
AnsiProperCase example:
__S :=
AnsiProperCase('let him go');
__{
here S = 'Let Him Go' }
Routine CenterStr
Declaration: function CenterStr(const S: string; Len: Integer):string;
CenterStr centers the characters in the string based upon the Len specified.
CenterStr example:
S := 'Let It Be';
S := CenterStr(S, 13);
{ here S = ' Let It Be ' }
Routine CompStr
Declaration: function CompStr(const S1, S2: string): Integer;
CompStr compares S1 to S2, with case-sensitivity. The return value is -1 if S1 < S2, 0 if S1 = S2, or 1 if S1 > S2.
CompStr example:
var I: Integer;
begin
__I
:= CompStr(S1, S2);
__if
I = 0 then
__begin
____{
S1 = S2 }
__end
else
____if
I < 0 then
____begin
______{ S1 < S2 }
____end
else begin
______{ S1 > S2 }
__end;
end;
Routine Copy2Space
Declaration: function Copy2Space(const S: string): string;
Copy2Space returns a substring of a string S from begining to first white space.
Copy2Space example:
S := 'Let it be';
S := Copy2Space(S);
{ here S = 'Let' }
Routine
Copy2SpaceDel
Declaration: function Copy2SpaceDel(var S: string): string;
Copy2SpaceDel returns a substring of a string S from begining to first white space and removes this substring from S.
Copy2SpaceDel example:
S := 'Let it be';
S1 := Copy2SpaceDel(S);
{ here S1 = 'Let', S = 'it be' }
Routine Copy2Symb
Declaration: function Copy2Symb(const S: string; Symb: Char): string;
Copy2Symb returns a substring of a string S from begining to first character Symb.
Copy2Symb example:
S := 'Let-it-be';
S := Copy2Symb(S, '-');
{ here S = 'Let' }
Routine Copy2SymbDel
Declaration: function Copy2SymbDel(var S: string; Symb: Char): string;
Copy2SymbDel returns a substring of a string S from begining to first character Symb and removes this substring from S.
Copy2SymbDel example:
S := 'Let-it-be';
S1 := Copy2SymbDel(S, '-');
{ here S1 = 'Let', S = 'it-be' }
Routine Dec2Hex
Declaration: function Dec2Hex(N: Longint; A: Byte): string;
Dec2Hex converts the given value to a hexadecimal string representation with the minimum number of digits (A) specified.
Dec2Hex example:
S := Dec2Hex(10, 2);
{ here S = '0A' }
Routine Dec2Numb
Declaration: function Dec2Numb(N: Longint; A, B: Byte): string;
Dec2Numb converts the given value to a string representation with the base equal to B and with the minimum number of digits (A) specified.
Dec2Numb example:
S := Dec2Numb(10, 8, 2);
{ here S = '00001010' }
Routine DelBSpace
Declaration: function DelBSpace(const S: string): string;
DelBSpace trims leading spaces from the given string.
DelBSpace example:
var S: string;
begin
__S
:= ' Let It Be';
__S
:= DelSpace(S);
__ShowMessage(S);
{ here S = 'Let It Be' }
end;
Routine DelChars
Declaration: function DelChars(const S: string; Chr: Char): string;
DelChars return a string with all Chr characters removed.
DelChars example:
var S: string;
begin
__S
:= 'Let It Be';
__S
:= DelChars(S, 'e');
__ShowMessage(S);
{ here S = 'Lt It B' }
end;
Routine DelESpace
Declaration: function DelESpace(const S: string): string;
DelESpace trims trailing spaces from the given string.
DelESpace example:
var S: string;
begin
__S
:= 'Let It Be ';
__S
:= DelSpace(S);
__ShowMessage(S);
{ here S = 'Let It Be' }
end;
Routine DelRSpace
Declaration: function DelRSpace(const S: string): string;
DelRSpace trims leading and trailing spaces from the given string.
DelRSpace example:
var S: string;
begin
__S
:= ' Let It Be ';
__S
:= DelSpace(S);
__ShowMessage(S);
{ here S = 'Let It Be' }
end;
Routine DelSpace
Declaration: function DelSpace(const S: string): string;
DelSpace return a string with all white spaces removed.
> DelSpace example:
var S: string;
begin
__S
:= 'Let It Be';
__S
:= DelSpace(S);
__ShowMessage(S);
{ here S = 'LetItBe' }
end;
Routine DelSpace1
Declaration: function DelSpace1(const S: string): string;
DelSpace1 return a string with all non-single white spaces removed.
> DelSpace1 example:
var S: string;
begin
__S
:= 'Let It Be';
__S
:= DelSpace1(S);
__ShowMessage(S);
{ here S = 'Let It Be' }
end;
Routine
ExtractDelimited
Declaration: function ExtractDelimited(N: Integer; const S: string; const
Delims: TCharSet): string;
ExtractWord, ExtractWordPos and ExtractDelimited given a set of word delimiters, return the N'th word in S.
ExtractDelimited example:
S := 'Let him go';
S1 := ExtractDelimited(2, S, [' ']);
{ here S1 = '' }
Routine
ExtractSubstr
Declaration: function ExtractSubstr(const S: string; var Pos: Integer; const
Delims: TCharSet): string;
ExtractSubstr given a set of word delimiters, return the substring from S, that started from position Pos.
ExtractSubstr example:
var
__Pos:
Integer; List: TStringList; S: string;
begin
__{
... }
__Pos
:= 1;
__while
Pos <= Length(S) do
____List.Add(ExtractFieldName(S,
Pos, [',',';']));
__{
... }
end;
Routine ExtractWord
Declaration: function ExtractWord(N: Integer; const S: string; const
WordDelims: TCharSet): string;
ExtractWord, ExtractWordPos and ExtractDelimited given a set of word delimiters, return the N'th word in S.
> ExtractWord example:
S := 'Let him go';
S1 := ExtractWord(2, S, [' ']);
{ here S1 = 'him' }
Routine
ExtractWordPos
Declaration: function ExtractWordPos(N: Integer; const S: string; const
WordDelims: TCharSet; var Pos: Integer): string;
ExtractWord, ExtractWordPos and ExtractDelimited given a set of word delimiters, return the N'th word in S.
> ExtractWordPos example:
S := 'Let him go';
S1 := ExtractWordPos(2, S, [' '], P);
{ here S1 = 'him', P = 6 }
Routine FindPart
Declaration: function FindPart(const HelpWilds, InputStr: string): Integer;
FindPart compares a string with '?' and another, returns the position of HelpWilds in InputStr.
FindPart example:
var P: Integer; Wild: string;
begin
__Wild
:= '?im';
__P
:= FindPart(Wild, 'Let him go');
__{
here P = 5 }
end;
Routine Hex2Dec
Declaration: function Hex2Dec(const S: string): Longint;
Hex2Dec converts the given hexadecimal string to the corresponding integer value.
Hex2Dec example:
I := Hex2Dec('1A');
{ here I = 26 }
Routine IntToRoman
Declaration: function IntToRoman(Value: Longint): string;
IntToRoman converts the given value to a roman numeric string representation.
IntToRoman example:
S := IntToRoman(1996);
Routine IsEmptyStr
Declaration: function IsEmptyStr(const S: string; const EmptyChars:
TCharSet): Boolean;
EmptyStr returns True if the given string contains only character from the EmptyChars.
IsEmptyStr example:
if IsEmptyStr(S, [#0,' ']) then
begin
__ShowMessage('S
contains only while spaces');
end;
Routine IsWild
Declaration: function IsWild(InputStr, Wilds: string; IgnoreCase: Boolean):
Boolean;
IsWild compare InputString with WildCard string and return True if corresponds.
IsWild example:
There are possible masks and corresponding strings:
* : >= 0 letters;
*A : words with >= 1 letters and A at the end;
A*A : words with >= 2 letters and A at the begin and end;
A* : words with >= 1 letters and A at the begin;
? : one letter.
Routine
IsWordPresent
Declaration: function IsWordPresent(const W, S: string; const WordDelims:
TCharSet): Boolean;
IsWordPresent given a set of word delimiters, return True if word W is present in string S.
IsWordPresent example:
if IsWordPresent('him', 'Let him go', [' ', ',']) then
__ShowMessage('String
contsins word "him"');
Routine LeftStr
Declaration: function LeftStr(const S: string; N: Integer): string;
LeftStr return a string right-padded to length N with blanks.
LeftStr example:
S := 'Let It Be';
S := LeftStr(S, 10);
{ here S = 'Let It Be ' }
Routine MakeStr
Declaration: function MakeStr(C: Char; N: Integer): string;
MakeStr return a string of length N filled with character C.
MakeStr example:
__S
:= MakeStr(' ', 10);
Routine MS
Declaration: function MS(C: Char; N: Integer): string;
MS return a string of length N filled with character C.
MS example:
__S
:= MS(' ', 10);
Routine NPos
Declaration: function NPos(const C: string; S: string; N: Integer): Integer;
NPos searches for a N-th position of substring C in a given string S.
> NPos example:
var
__S:
string; I: Integer;
begin
__S
:= 'Let It Be';
__I
:= NPos(' ', S, 2);
__{
I = 7 }
end;
Routine Numb2Dec
Declaration: function Numb2Dec(S: string; B: Byte): Longint;
Numb2Dec converts the given B-based numeric string to the corresponding integer value.
Numb2Dec example:
__I := Numb2Dec('1010', 2);
__{
here I = 10 }
Routine Numb2USA
Declaration: function Numb2USA(const S: string): string;
Numb2USA converts numeric string S to USA-format.
Numb2USA example:
__S := Numb2USA('12365412');
__{
here S = '12,365,412' }
Routine OemToAnsiStr
Declaration: function OemToAnsiStr(const OemStr: string): string;
OemToAnsiStr translates a string from the OEM character set into the Windows character set.
> OemToAnsiStr example:
S := OemToAnsiStr(S);
Routine ReplaceStr
Declaration: function ReplaceStr(const S, Srch, Replace: string): string;
Returns string with every occurrence of Srch string replaced with Replace string.
ReplaceStr example:
__S := ReplaceStr(ReplaceStr(Condition, '*', '%'), '?', '_');
Routine RightStr
Declaration: function RightStr(const S: string; N: Integer): string;
RightStr return a string left-padded to length N with blanks.
RightStr example:
__S := 'Let It Be';
__S
:= RightStr(S, 10);
__{
here S = ' Let It Be' }
Routine RomanToInt
Declaration: function RomanToInt(const S: string): Longint;
RomanToInt converts the given string to an integer value. If the string doesn't contain a valid roman numeric value, the 0 value is returned.
RomanToInt example:
__I := RomanToInt('MCMXVI');
Routine StrToOem
Declaration: function StrToOem(const AnsiStr: string): string;
StrToOem translates a string from the Windows character set into the OEM character set.
StrToOem example:
__S := StrToOem(S);
Routine Tab2Space
Declaration: function Tab2Space(const S: string; Numb: Byte): string;
Tab2Space converts any tabulation character in the given string to the Numb spaces characters.
Tab2Space example:__
__S := Tab2Space(S, 8);
Routine WordCount
Declaration: function WordCount(const S: string; const WordDelims: TCharSet):
Integer;
WordCount given a set of word delimiters, return number of words in S.
WordCount example:
I := WordCount('Let him go', [' ', ',']);
{ here I = 3 }
Routine WordPosition
Declaration: function WordPosition(const N: Integer; const S: string; const
WordDelims: TCharSet): Integer;
Given a set of word delimiters, return start position of N'th word in S.
WordPosition example:
I := WordPosition(2, 'Let him go', [' ', ',']);
{ here I = 5 }
Index Page | About | Download
Creation Date: 4 Feb 1998 | Last Update: 16 Mar 2000