home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
delphi
/
tstrclas.lzh
/
TESTBED.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1995-11-18
|
61KB
|
2,168 lines
unit Testbed;
interface
uses
SysUtils,
WinTypes,
WinProcs,
Messages,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
ExtCtrls,
SafeStr,
StrClass,
ContainR, Console, Buttons;
type
TSCTestBed = class(TForm)
FuncLb : TListbox;
GroupBox1 : TGroupBox;
Label4: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FuncLbClick(Sender: TObject);
private
TheFuncList : TRecordContainer;
{ Private declarations }
PROCEDURE RunTest(fid : WORD);
PROCEDURE SetupFuncLb;
public
{ Public declarations }
OutConsole: TConsole;
end;
var
SCTestBed: TSCTestBed;
implementation
{$R *.DFM}
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
CONST
id_Create = 1;
id_CreateSize = 2;
id_CreateString =3;
id_CreateStringNL = 4;
id_CreateBoolean = 5;
id_Destroy = 6;
id_Copy = 7;
id_CopyFrom = 8;
id_Clear = 9;
id_Empty = 10;
id_Assign = 11;
id_AssignFrom = 12;
id_AssignLen = 13;
id_AssignMid = 14;
id_AssignNL = 15;
id_AssignPad = 16;
id_AssignRight = 17;
id_AssignTrim = 18;
id_Append = 19;
id_AppendBoolean = 20;
id_AppendByte = 21;
id_AppendCh = 22;
id_AppendDIC = 23;
id_AppendDouble = 24;
id_AppendDoubleTrim = 25;
id_AppendExt = 26;
id_AppendExtTrim = 27;
id_AppendLen = 28;
id_AppendLong = 29;
id_AppendMid = 30;
id_AppendNL = 31;
id_AppendPad = 32;
id_AppendPtr = 33;
id_AppendReal = 34;
id_AppendRight = 35;
id_AppendSIC = 36;
id_AppendTrim = 37;
id_AppendWithTab = 38;
id_NLAppend = 39;
id_Prepend = 40;
id_FirstNonSpaceCh = 41;
id_HasCh = 42;
id_isCh = 43;
id_IsFirstCh = 44;
id_IsLastCh = 45;
id_LastNonSpaceCh = 46;
id_RemoveLastCh = 47;
id_SetCh = 48;
id_FromBoolean = 49;
id_FromByte = 50;
id_FromChar = 51;
id_FromDouble = 52;
id_FromDoubleTrim = 53;
id_FromExt = 54;
id_FromExtTrim = 55;
id_FromLong = 56;
id_FromPtr = 57;
id_FromReal = 58;
id_FromRealTrim = 59;
id_FromRGB = 60;
id_HexFromByte = 61;
id_HexFromLong = 62;
id_HexFromPtr = 63;
id_HexFromWord = 64;
id_ToBoolean = 65;
id_ToByte = 66;
id_ToChar = 67;
id_ToDouble = 68;
id_ToExt = 69;
id_ToInteger = 70;
id_ToLong = 71;
id_ToReal = 72;
id_ToRGB = 73;
id_ToWord = 74;
id_AppendStr = 75;
id_UpperCase = 76;
id_LowerCase = 77;
id_CompareStr = 78;
id_CompareText = 79;
id_AnsiUpperCase = 80;
id_AnsiLowerCase = 81;
id_AnsiCompareStr = 82;
id_AnsiCompareText = 83;
id_IsValidIdent = 84;
id_IntToStr = 85;
id_IntToHex = 86;
id_StrToInt = 87;
id_StrToIntDef = 88;
id_LoadStr = 89;
id_FmtLoadStr = 90;
id_Format = 91;
id_FloatToStr = 92;
id_FloatToStrF = 93;
id_FormatFloat = 94;
id_StrToFloat = 95;
id_StrCat = 96;
id_StrComp = 97;
id_StrCopy = 98;
id_StrECopy = 99;
id_StrEnd = 100;
id_StrIComp = 101;
id_StrLCat = 102;
id_StrLIComp = 103;
id_StrLComp = 104;
id_StrLCopy = 105;
id_StrLen = 106;
id_StrLower = 107;
id_StrMove = 108;
id_StrPas = 109;
id_StrPCopy = 110;
id_StrPos = 111;
id_StrRScan = 112;
id_StrScan = 113;
id_StrUpper = 114;
id_Compare = 115;
id_CompareI = 116;
id_CompareL = 117;
id_CompareLI = 118;
id_CompareLong = 119;
id_CompareDouble = 120;
id_CompareExt = 121;
id_IsSame = 122;
id_isSameL = 123;
id_IsSameLI = 124;
id_Includes = 125;
id_Within = 126;
id_Delete = 127;
id_Insert = 128;
id_InsertL = 129;
id_PadCentre = 130;
id_PadEnd = 131;
id_PadFront = 132;
id_RemoveDIC = 133;
id_RemoveSIC = 134;
id_Trim = 135;
id_TrimEnd = 136;
id_TrimFront = 137;
id_TrimZero = 138;
id_FindCmdLine = 139;
id_FindCmdLineAndParse = 140;
id_FindCmdLineParam = 141;
id_AppendStringRes = 142;
id_LoadStringRes = 143;
id_ReadIniKeyword = 144;
id_WriteIniKeyword = 145;
id_FindIniSectionKeywords = 146;
id_AddBackSlash = 147;
id_BuildPathName = 148;
id_DefaultExtension = 149;
id_ExpandFileName = 150;
id_ForceExtension = 151;
id_HasBackSlash = 152;
id_HasDrive = 153;
id_HasExtension = 154;
id_HasFileName = 155;
id_HasDirectory = 156;
id_DirectoryExists = 157;
id_DriveExists = 158;
id_FileExists = 159;
id_JustExtension = 160;
id_JustFileName = 161;
id_JustDirectory = 162;
id_SetCurDir = 163;
id_ChCount = 164;
id_FindBetween2Ch = 165;
id_FindFirst = 166;
id_FindFirstCh = 167;
id_FindLast = 168;
id_FindLastCh = 169;
id_FindNext = 170;
id_FindNextCh = 171;
id_FindPrev = 172;
id_FindPrevCh = 173;
id_SubStrCount = 174;
id_FirstCharToUpper = 175;
id_IsAlphaNumeric = 176;
id_ToLower = 177;
id_ToUpper = 178;
id_ReplaceAll = 179;
id_ReplaceFirst = 180;
id_ReplaceLast = 181;
id_ReplaceChAll = 182;
id_ReplaceChFirst = 183;
id_ReplaceChLast = 184;
id_FirstParseDelim = 185;
id_NextParseDelim = 186;
id_ParseDelimCount = 187;
id_ParseDelimToList = 188;
id_ParsePosToList = 189;
id_SameI = 190;
id_JustName = 191;
id_FileSplit = 192;
id_FindCurrentDir = 193;
id_DeleteFrom = 194;
id_FindRelPath = 195;
id_ParseMultiDelimToList = 196;
id_Grep = 197;
id_AddFilterDesc = 198;
id_RecalcLength = 199;
id_NL = 200;
id_FromComponent = 201;
id_FromComponentItem = 202;
id_ToComponent = 203;
id_IsSameI = 204;
id_CreateDirectory = 205;
id_RemoveDirectory = 206;
id_SameDrive = 207;
id_SameDirectory = 208;
id_SameExtension = 209;
id_SameFileName = 210;
id_SameName = 211;
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
TYPE
PFunctionRecord = ^TFunctionRecord;
TFunctionRecord = RECORD
Id : WORD;
Name : PChar;
END;
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
procedure TSCTestBed.Button1Click(Sender: TObject);
begin
Close;
end;
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
procedure TSCTestBed.FormCreate(Sender: TObject);
begin
{ clear memo control }
OutConsole := TConsole.Create(Self);
OutConsole.Parent := GroupBox1;
OutConsole.Left := 8;
OutConsole.Top := 24;
OutConsole.Width := 569;
OutConsole.Height := 200;
OutConsole.Options := OutConsole.Options + [coStdOutput];
{ create container to hold id/func name recs }
TheFuncList := TRecordContainer.Create(SIZEOF(TFunctionRecord));
SetupFuncLb;
end;
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
procedure TSCTestBed.FormClose(Sender: TObject; var Action: TCloseAction);
{ ++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE KillStr(R : PFunctionRecord); FAR;
BEGIN
StrDispose(R^.Name);
END;
{ ++++++++++++++++++++++++++++++++++++++++++++++++++ }
begin
TheFuncList.ForEach(@KillStr);
TheFuncList.Free;
end;
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
PROCEDURE TScTestbed.SetupFuncLb;
{ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE AddItem(id : INTEGER; AStr : PChar);
VAR
R : PFunctionRecord;
BEGIN
FuncLb.Items.Add(StrPas(AStr));
NEW(R);
R^.Id := id;
R^.Name := StrNew(AStr);
TheFuncList.Add(R);
END;
{ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
BEGIN
AddItem(id_Create,'Create');
AddItem(id_CreateSize,'CreateSize');
AddItem(id_CreateString,'CreateString');
AddItem(id_CreateStringNL,'CreateStringNL');
AddItem(id_CreateBoolean,'CreateBoolean');
AddItem(id_Destroy,'Destroy');
AddItem(id_Copy,'Copy');
AddItem(id_CopyFrom,'CopyFrom');
AddItem(id_Clear,'Clear');
AddItem(id_Empty,'Empty');
AddItem(id_RecalcLength,'RecalcLength');
AddItem(id_Assign,'Assign');
AddItem(id_AssignFrom,'AssignFrom');
AddItem(id_AssignLen,'AssignLen');
AddItem(id_AssignMid,'AssignMid');
AddItem(id_AssignNL,'AssignNL');
AddItem(id_AssignPad,'AssignPad');
AddItem(id_AssignRight,'AssignRight');
AddItem(id_AssignTrim,'AssignTrim');
AddItem(id_Append,'Append');
AddItem(id_AppendBoolean,'AppendBoolean');
AddItem(id_AppendByte,'AppendByte');
AddItem(id_AppendCh,'AppendCh');
AddItem(id_AppendDIC,'AppendDIC');
AddItem(id_AppendDouble,'AppendDouble');
AddItem(id_AppendDoubleTrim,'AppendDoubleTrim');
AddItem(id_AppendExt,'AppendExt');
AddItem(id_AppendExtTrim,'AppendExtTrim');
AddItem(id_AppendLen,'AppendLen');
AddItem(id_AppendLong,'AppendLong');
AddItem(id_AppendMid,'AppendMid');
AddItem(id_AppendNL,'AppendNL');
AddItem(id_AppendPad,'AppendPad');
AddItem(id_AppendPtr,'AppendPtr');
AddItem(id_AppendReal,'AppendReal');
AddItem(id_AppendRight,'AppendRight');
AddItem(id_AppendSIC,'AppendSIC');
AddItem(id_AppendTrim,'AppendTrim');
AddItem(id_AppendWithTab,'AppendWithTab');
AddItem(id_NL,'NL');
AddItem(id_NLAppend,'NLAppend');
AddItem(id_Prepend,'Prepend');
AddItem(id_FirstNonSpaceCh,'FirstNonSpaceCh');
AddItem(id_HasCh,'HasCh');
AddItem(id_isCh,'IsCh');
AddItem(id_IsFirstCh,'IsFirstCh');
AddItem(id_IsLastCh,'IsLastCh');
AddItem(id_LastNonSpaceCh,'LastNonSpaceCh');
AddItem(id_RemoveLastCh,'RemoveLastCh');
AddItem(id_SetCh,'SetCh');
AddItem(id_FromBoolean,'FromBoolean');
AddItem(id_FromByte,'FromByte');
AddItem(id_FromChar,'FromChar');
AddItem(id_FromComponent,'FromComponent');
AddItem(id_FromComponentItem,'FromComponentItem');
AddItem(id_FromDouble,'FromDouble');
AddItem(id_FromDoubleTrim,'FromDoubleTrim');
AddItem(id_FromExt,'FromExt');
AddItem(id_FromExtTrim,'FromExtTrim');
AddItem(id_FromLong,'FromLong');
AddItem(id_FromPtr,'FromPtr');
AddItem(id_FromReal,'FromReal');
AddItem(id_FromRealTrim,'FromRealTrim');
AddItem(id_FromRGB,'FromRGB');
AddItem(id_HexFromByte,'HexFromByte');
AddItem(id_HexFromLong,'HexFromLong');
AddItem(id_HexFromPtr,'HexFromPtr');
AddItem(id_HexFromWord,'HexFromWord');
AddItem(id_ToBoolean,'ToBoolean');
AddItem(id_ToByte,'ToByte');
AddItem(id_ToChar,'ToChar');
AddItem(id_ToComponent,'ToComponent');
AddItem(id_ToDouble,'ToDouble');
AddItem(id_ToExt,'ToExt');
AddItem(id_ToInteger,'ToInteger');
AddItem(id_ToLong,'ToLong');
AddItem(id_ToReal,'ToReal');
AddItem(id_ToRGB,'ToRGB');
AddItem(id_ToWord,'ToWord');
AddItem(id_AppendStr,'AppendStr');
AddItem(id_UpperCase,'UpperCase');
AddItem(id_LowerCase,'LowerCase');
AddItem(id_CompareStr,'CompareStr');
AddItem(id_CompareText,'CompareText');
AddItem(id_AnsiUpperCase,'AnsiUpperCase');
AddItem(id_AnsiLowerCase,'AnsiLowerCase');
AddItem(id_AnsiCompareStr,'AnsiCompareStr');
AddItem(id_AnsiCompareText,'AnsiCompareText');
AddItem(id_IsValidIdent,'IsValidIdent');
AddItem(id_IntToStr,'IntToStr');
AddItem(id_IntToHex,'IntToHex');
AddItem(id_StrToInt,'StrToInt');
AddItem(id_StrToIntDef,'StrToIntDef');
AddItem(id_LoadStr,'LoadStr');
AddItem(id_FmtLoadStr,'FmtLoadStr');
AddItem(id_Format,'Format');
AddItem(id_FloatToStr,'FloatToStr');
AddItem(id_FloatToStrF,'FloatToStrF');
AddItem(id_FormatFloat,'FormatFloat');
AddItem(id_StrToFloat,'StrToFloat');
AddItem(id_StrCat,'StrCat');
AddItem(id_StrComp,'StrComp');
AddItem(id_StrCopy,'StrCopy');
AddItem(id_StrECopy,'StrECopy');
AddItem(id_StrEnd,'StrEnd');
AddItem(id_StrIComp,'StrIComp');
AddItem(id_StrLCat,'StrLCat');
AddItem(id_StrLIComp,'StrLIComp');
AddItem(id_StrLComp,'StrLComp');
AddItem(id_StrLCopy,'StrLCopy');
AddItem(id_StrLen,'StrLen');
AddItem(id_StrLower,'StrLower');
AddItem(id_StrMove,'StrMove');
AddItem(id_StrPas,'StrPas');
AddItem(id_StrPCopy,'StrPCopy');
AddItem(id_StrPos,'StrPos');
AddItem(id_StrRScan,'StrRScan');
AddItem(id_StrScan,'StrScan');
AddItem(id_StrUpper,'StrUpper');
AddItem(id_Compare,'Compare');
AddItem(id_CompareI,'CompareI');
AddItem(id_CompareL,'CompareL');
AddItem(id_CompareLI,'CompareLI');
AddItem(id_CompareLong,'CompareLong');
AddItem(id_CompareDouble,'CompareDouble');
AddItem(id_CompareExt,'CompareExt');
AddItem(id_IsSame,'IsSame');
AddItem(id_IsSameI,'IsSameI');
AddItem(id_isSameL,'IsSameL');
AddItem(id_IsSameLI,'IsSameLI');
AddItem(id_Includes,'Includes');
AddItem(id_Within,'Within');
AddItem(id_Delete,'Delete');
AddItem(id_DeleteFrom,'DeleteFrom');
AddItem(id_Insert,'Insert');
AddItem(id_InsertL,'InsertL');
AddItem(id_PadCentre,'PadCentre');
AddItem(id_PadEnd,'PadEnd');
AddItem(id_PadFront,'PadFront');
AddItem(id_RemoveDIC,'RemoveDIC');
AddItem(id_RemoveSIC,'RemoveSIC');
AddItem(id_Trim,'Trim');
AddItem(id_TrimEnd,'TrimEnd');
AddItem(id_TrimFront,'TrimFront');
AddItem(id_TrimZero,'TrimZero');
AddItem(id_FindCmdLine,'FindCmdLine');
AddItem(id_FindCmdLineAndParse,'FindCmdLineAndParse');
AddItem(id_FindCmdLineParam,'FindCmdLineParam');
AddItem(id_AppendStringRes,'AppendStringRes');
AddItem(id_LoadStringRes,'LoadStringRes');
AddItem(id_ReadIniKeyword,'ReadIniKeyword');
AddItem(id_WriteIniKeyword,'WriteIniKeyword');
AddItem(id_FindIniSectionKeywords,'FindIniSectionKeywords');
AddItem(id_AddBackSlash,'AddBackSlash');
AddItem(id_AddFilterDesc,'AddFilterDesc');
AddItem(id_BuildPathName,'BuildPathName');
AddItem(id_CreateDirectory,'CreateDirectory');
AddItem(id_DefaultExtension,'DefaultExtension');
AddItem(id_DirectoryExists,'DirectoryExists');
AddItem(id_DriveExists,'DriveExists');
AddItem(id_ExpandFileName,'ExpandFileName');
AddItem(id_FileExists,'FileExists');
AddItem(id_FindCurrentDir,'FindCurrentDir');
AddItem(id_FindRelPath,'FindRelPath');
AddItem(id_ForceExtension,'ForceExtension');
AddItem(id_HasBackSlash,'HasBackSlash');
AddItem(id_HasDrive,'HasDrive');
AddItem(id_HasExtension,'HasExtension');
AddItem(id_HasFileName,'HasFileName');
AddItem(id_HasDirectory,'HasDirectory');
AddItem(id_FileSplit,'FileSplit');
AddItem(id_JustExtension,'JustExtension');
AddItem(id_JustFileName,'JustFileName');
AddItem(id_JustName,'JustName');
AddItem(id_JustDirectory,'JustDirectory');
AddItem(id_RemoveDirectory,'RemoveDirectory');
AddItem(id_SameDrive,'SameDrive');
AddItem(id_SameDirectory,'SameDirectory');
AddItem(id_SameExtension,'SameExtension');
AddItem(id_SameFileName,'SameFileName');
AddItem(id_SameName,'SameName');
AddItem(id_SetCurDir,'SetCurDir');
AddItem(id_ChCount,'ChCount');
AddItem(id_FindBetween2Ch,'FindBetween2Ch');
AddItem(id_FindFirst,'FindFirst');
AddItem(id_FindFirstCh,'FindFirstCh');
AddItem(id_FindLast,'FindLast');
AddItem(id_FindLastCh,'FindLastCh');
AddItem(id_FindNext,'FindNext');
AddItem(id_FindNextCh,'FindNextCh');
AddItem(id_FindPrev,'FindPrev');
AddItem(id_FindPrevCh,'FindPrevCh');
AddItem(id_Grep,'Grep');
AddItem(id_SubStrCount,'SubStrCount');
AddItem(id_FirstCharToUpper,'FirstCharToUpper');
AddItem(id_IsAlphaNumeric,'IsAlphaNumeric');
AddItem(id_ToLower,'ToLower');
AddItem(id_ToUpper,'ToUpper');
AddItem(id_ReplaceAll,'ReplaceAll');
AddItem(id_ReplaceFirst,'ReplaceFirst');
AddItem(id_ReplaceLast,'ReplaceLast');
AddItem(id_ReplaceChAll,'ReplaceChAll');
AddItem(id_ReplaceChFirst,'ReplaceChFirst');
AddItem(id_ReplaceChLast,'ReplaceChLast');
AddItem(id_FirstParseDelim,'FirstParseDelim');
AddItem(id_NextParseDelim,'NextParseDelim');
AddItem(id_ParseDelimCount,'ParseDelimCount');
AddItem(id_ParseDelimToList,'ParseDelimToList');
AddItem(id_ParseMultiDelimToList,'ParseMultiDelimToList');
AddItem(id_ParsePosToList,'ParsePosToList');
FuncLb.ItemIndex := -1;
END;
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
procedure TSCTestBed.FuncLbClick(Sender: TObject);
CONST
MaxLen = 500;
VAR
AStr : PChar;
AnItem : PFunctionRecord;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
FUNCTION MatchStr(R : PFunctionRecord) : BOOLEAN; FAR;
BEGIN
MatchStr := (SafeStrIComp(AStr,R^.Name) = 0);
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
begin
GetMem(AStr,Maxlen);
StrPCopy(AStr,FuncLb.Items.Strings[FuncLb.ItemIndex]);
AnItem := TheFuncList.FirstThat(@MatchStr);
IF AnItem <> NIL THEN
RunTest(AnItem^.Id);
FreeMem(AStr,Maxlen);
end;
{ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
PROCEDURE TScTestBed.RunTest(fid : WORD);
CONST
ANullPChar : PChar = NIL;
APChar : PChar = 'PChar string';
AStr : STRING = 'Pascal string';
ANullStr : STRING = '';
ALong : LONGINT = 99000;
APath : STRING = 'c:\windows\system.ini';
AReal : REAL = 21.3;
AnInteger : INTEGER = -5;
AWord : WORD = 66;
ADouble : DOUBLE = 66.4;
AByte : BYTE = 124;
AnExt : EXTENDED = 134.456;
VAR
ANullStrObj,AStrObj : TStringClass;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoCreate;
BEGIN
Writeln('Instantiates an object with null string and zero buffer length');
Writeln('e.g. AStrObj := TStringClass.Create');
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoCreateSize;
BEGIN
Writeln('Instantiates an object with a null string but with a buffer');
Writeln(' size preset to ''ASize'' bytes. Useful for situations ');
Writeln('where lots of assigns/appends are anticipated.');
Writeln('e.g. AStrObj := TStringClass.CreateSize(2000)');
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoCreateString;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr,''.'',APChar,''.'',ANullPChar,''.'']);');
TObj := TStringClass.CreateString([AStr,'.',APChar,'.',ANullPChar,'.']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoCreateStringNL;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateStringNL([AStr]);');
Writeln('TObj.Append([APChar]);');
TObj := TStringClass.CreateStringNL([AStr]);
TObj.Append([APChar]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoCreateBoolean;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateBoolean(TRUE,bt_NoYes);');
TObj := TStringClass.CreateBoolean(TRUE,bt_NoYes);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoDestroy;
BEGIN
Writeln('Disposes the string class object.');
Writeln('Do not call directly. Use the Free metheod');
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoCopy;
VAR
TObj,CObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('CObj := TObj.Copy;');
TObj := TStringClass.CreateString([AStr]);
CObj := TObj.Copy;
Writeln;
Writeln('Result:');
Writeln('Original string object text = ',TObj.ZString);
Writeln('Copy string object text = ',CObj.ZString);
TObj.Free;
CObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoCopyFrom;
VAR
TObj,CObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('CObj := TStringClass.Create;');
Writeln('CObj.CopyFrom(TObj);');
TObj := TStringClass.CreateString([AStr]);
CObj := TStringClass.Create;
CObj.CopyFrom(TObj);
Writeln;
Writeln('Result:');
Writeln('Original string object text = ',TObj.ZString);
Writeln('Copy string object text = ',CObj.ZString);
TObj.Free;
CObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoClear;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.Clear;');
TObj := TStringClass.CreateString([AStr]);
Writeln;
Writeln('Result pre clear :');
Writeln(TObj.ZString,'(Buffer Size = ',TObj.MaxSize,')');
TObj.Clear;
Writeln;
Writeln('Result post clear :');
Writeln(TObj.ZString,'(Buffer Size = ',TObj.MaxSize,')');
Writeln;
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoEmpty;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.Empty;');
TObj := TStringClass.CreateString([AStr]);
Writeln;
Writeln('Result pre Empty :');
Writeln(TObj.ZString,'(Buffer Size = ',TObj.MaxSize,')');
TObj.Empty;
Writeln;
Writeln('Result post Empty :');
Writeln(TObj.ZString,'(Buffer Size = ',TObj.MaxSize,')');
Writeln;
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssign;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.Assign([AStr,'' and '',APChar,'' '',ALong]);');
TObj := TStringClass.Create;
TObj.Assign([AStr,' and ',APChar,' ',ALong]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssignFrom;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AssignFrom([AStr,'' and '',APChar,'' '',ALong],7);');
TObj := TStringClass.Create;
TObj.AssignFrom([AStr,' and ',APChar,' ',ALong],7);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssignLen;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AssignLen([AStr,'' and '',APChar,'' '',ALong],9);');
TObj := TStringClass.Create;
TObj.AssignLen([AStr,' and ',APChar,' ',ALong],9);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssignMid;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AssignMid([AStr,'' and '',APChar,'' '',ALong],7,5);');
TObj := TStringClass.Create;
TObj.AssignMid([AStr,' and ',APChar,' ',ALong],7,5);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssignNL;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AssignNL([AStr,'' and '',APChar,'' '',ALong]);');
Writeln('TObj.Append([AWord]);');
TObj := TStringClass.Create;
TObj.AssignNL([AStr,' and ',APChar,' ',ALong]);
TObj.Append([AWord]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssignPad;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AssignPad([AStr],15,''x'');');
TObj := TStringClass.Create;
TObj.AssignPad([AStr],15,'x');
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssignRight;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AssignRight([AStr],3);');
TObj := TStringClass.Create;
TObj.AssignRight([AStr],3);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAssignTrim;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AssignTrim(['' '',AStr,'' '']);');
TObj := TStringClass.Create;
TObj.AssignTrim([' ',AStr,' ']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppend;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.Append([APChar,'' '',ADouble]);');
TObj := TStringClass.CreateString([AStr]);
TObj.Append([APChar,' ',ADouble]);
Writeln;
Writeln('Result:');
Writeln;
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendBoolean;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr,'' = '']);');
Writeln('TObj.AppendBoolean(FALSE,bt_FalseTrue);');
TObj := TStringClass.CreateString([AStr,' = ']);
TObj.AppendBoolean(FALSE,bt_FalseTrue);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendByte;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr,'' = '']);');
Writeln('TObj.AppendByte(AByte);');
TObj := TStringClass.CreateString([AStr,' = ']);
TObj.AppendByte(AByte);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendCh;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.AppendCh(''*'');');
TObj := TStringClass.CreateString([AStr]);
TObj.AppendCh('*');
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendDIC;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''Call me '']);');
Writeln('TObj.AppendDIC([''Mr Tibbs'']);');
TObj := TStringClass.CreateString(['Call me ']);
TObj.AppendDIC(['Mr Tibbs']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendDouble;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''Value = '']);');
Writeln('TObj.AppendDouble(ADouble,10,3);');
TObj := TStringClass.CreateString(['Value = ']);
TObj.AppendDouble(ADouble,10,3);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendDoubleTrim;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''Value = '']);');
Writeln('TObj.AppendDoubleTrim(ADouble);');
TObj := TStringClass.CreateString(['Value = ']);
TObj.AppendDoubleTrim(ADouble);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendExt;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''Value = '']);');
Writeln('TObj.AppendExt(AnExt,10,3);');
TObj := TStringClass.CreateString(['Value = ']);
TObj.AppendExt(AnExt,10,3);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendExtTrim;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''Value = '']);');
Writeln('TObj.AppendExtTrim(AnExt);');
TObj := TStringClass.CreateString(['Value = ']);
TObj.AppendExtTrim(AnExt);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendLen;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.AppendLen([APChar],4);');
TObj := TStringClass.CreateString([AStr]);
TObj.AppendLen([APChar],4);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendLong;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.AppendLong(ALong);');
TObj := TStringClass.CreateString([AStr]);
TObj.AppendLong(ALong);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendMid;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.AppendMid([APChar],3,2);');
TObj := TStringClass.CreateString([AStr]);
TObj.AppendMid([APChar],3,2);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendNL;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AppendNL([''1st line'']);');
Writeln('TObj.Append([''2nd line'']);');
TObj := TStringClass.Create;
TObj.AppendNL(['1st line']);
TObj.Append(['2nd line']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendPad;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.AppendPad([APChar],30,''?'');');
TObj := TStringClass.CreateString([AStr]);
TObj.AppendPad([APChar],30,'?');
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendPtr;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''ALong Pointer = '']);');
Writeln('TObj.AppendPtr(@ALong);');
TObj := TStringClass.CreateString(['ALong Pointer = ']);
TObj.AppendPtr(@ALong);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendReal;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''AReal = '']);');
Writeln('TObj.AppendReal(AReal,10,2);');
TObj := TStringClass.CreateString(['AReal = ']);
TObj.AppendReal(AReal,10,2);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendRight;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.AppendRight([APChar],3);');
TObj := TStringClass.CreateString([AStr]);
TObj.AppendRight([APChar],3);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendSIC;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''Call me '']);');
Writeln('TObj.AppendSIC([''Mr Tibbs'']);');
TObj := TStringClass.CreateString(['Call me ']);
TObj.AppendSIC(['Mr Tibbs']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendTrim;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([''Call me '']);');
Writeln('TObj.AppendTrim(['' Mr Tibbs '']);');
TObj := TStringClass.CreateString(['Call me ']);
TObj.AppendTrim([' Mr Tibbs ']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendWithTab;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AppendWithTab([''First'']);');
Writeln('TObj.Append([''Second'']);');
TObj := TStringClass.Create;
TObj.AppendWithTab(['First']);
TObj.Append(['Second']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoNLAppend;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.NLAppend([APChar]);');
TObj := TStringClass.CreateString([AStr]);
TObj.NLAppend([APChar]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoPrepend;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.Prepend([APChar]);');
TObj := TStringClass.CreateString([AStr]);
TObj.Prepend([APChar]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoFirstNonSpaceCh;
VAR
TObj : TStringClass;
w : WORD;
ACh : CHAR;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString(['' '',AStr]);');
Writeln('w := TObj.FirstNonSpaceCh(ACh);');
TObj := TStringClass.CreateString([' ',AStr]);
w := TObj.FirstNonSpaceCh(ACh);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
Writeln('First non space char at base zero position ',w,' and is a ',ACh,' character');
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoHasCh;
VAR
TObj : TStringClass;
w : WORD;
ACh : CHAR;
b : boolean;
BEGIN
Writeln('Code:');
Writeln('ACh := ''c'';');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('b := TObj.HasCh(ACh,w);');
ACh := 'c';
TObj := TStringClass.CreateString([AStr]);
b := TObj.HasCh(ACh,w);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
IF b THEN
BEGIN
Write('Character ',ACh,' is found within the string');
Writeln(' at position ',w);
END
ELSE
Writeln('Character ',ACh,' is NOT found within the string');
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoIsCh;
VAR
TObj : TStringClass;
w : WORD;
ACh : CHAR;
b : boolean;
BEGIN
Writeln('Code:');
Writeln('ACh := ''c'';');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('b := TObj.IsCh(3,ACh);');
ACh := 'c';
TObj := TStringClass.CreateString([AStr]);
b := TObj.IsCh(3,ACh);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
IF b THEN
BEGIN
Writeln('Character ',ACh,' is found at position 3');
END
ELSE
Writeln('Character ',ACh,' is NOT found at position 3');
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoFromRGB;
VAR
TObj : TStringClass;
C : TColorRef;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('C := RGB(255,255,0);');
Writeln('TObj.FromRGB(C);');
TObj := TStringClass.Create;
C := RGB(255,255,0);
TObj.FromRGB(C);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoFindCmdLine;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.FindCmdLine;');
TObj := TStringClass.Create;
TObj.FindCmdLine;
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoFindRelPath;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.FindRelPath([''c:\windows''],[''c:\test\data'']);');
TObj := TStringClass.Create;
TObj.FindRelPath(['c:\windows'],['c:\test\data']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoJustExtension;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.JustExtension([APath]);');
TObj := TStringClass.Create;
TObj.JustExtension([APath]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoJustFileName;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.JustFileName([APath]);');
TObj := TStringClass.Create;
TObj.JustFileName([APath]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoJustName;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.JustName([APath]);');
TObj := TStringClass.Create;
TObj.JustName([APath]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoJustDirectory;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.JustDirectory([APath]);');
Writeln('TObj.JustDirectory([''c:\windows'']);');
TObj := TStringClass.Create;
TObj.JustDirectory([APath]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.JustDirectory(['c:\windows']);
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoReplaceAll;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr,'' '',APChar]);');
Writeln('TObj.ReplaceAll([''string''],[''text'']);');
TObj := TStringClass.CreateString([AStr,' ',APChar]);
TObj.ReplaceAll(['string'],['text']);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoDelete;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.Delete(2,3);');
TObj := TStringClass.CreateString([AStr]);
TObj.Delete(2,3);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoDeleteFrom;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.DeleteFrom(2);');
TObj := TStringClass.CreateString([AStr]);
TObj.DeleteFrom(2);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoParseDelimToList;
VAR
TObj : TStringClass;
AList : TObjectContainer;
{ ++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE WrSub(S : TStringClass); FAR;
BEGIN
IF S.Length = 0 THEN
Writeln('<null>')
ELSE
Writeln(S.ZString);
END;
{ ++++++++++++++++++++++++++++++++++++++++++++++ }
BEGIN
Writeln('Code:');
Writeln('AList := TObjectContainer.Create;');
Writeln('AList.Capacity := 100;');
Writeln('TObj := TStringClass.CreateString([''xxx,yyy,zzzz,wwww,,qqqq,rrrr'']);');
Writeln('TObj.ParseDelimToList('','',delim_None,AList);');
Writeln('AList.ForEach(@WrSub);');
AList := TObjectContainer.Create;
AList.Capacity := 100;
TObj := TStringClass.CreateString(['xxx,yyy,zzzz,wwww,,qqqq,rrrr']);
TObj.ParseDelimToList(',',delim_None,AList);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
Writeln('Parsed sub strings ...');
AList.ForEach(@WrSub);
TObj.Free;
AList.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoParseMultiDelimToList;
VAR
PartObj,TObj : TStringClass;
AList : TObjectContainer;
I : LONGINT;
{ ++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE WrSub(S : TStringClass); FAR;
BEGIN
IF S.Length = 0 THEN
Writeln('<null>')
ELSE
Writeln(S.ZString);
END;
{ ++++++++++++++++++++++++++++++++++++++++++++++ }
BEGIN
Writeln('Code:');
Writeln('AList := TObjectContainer.Create;');
Writeln('AList.Capacity := 100;');
Writeln('AList.ForEach(@WrSub);');
Writeln('TObj := TStringClass.CreateString([''>QFADS 14:30:30 - 14:45:00 95/11/01'']);');
Writeln('TObj.ParseMultiDelimToList(['' - '','' '',''>QFADS'','':'',''/''],delim_ExcNull,AList');
AList := TObjectContainer.Create;
AList.Capacity := 100;
TObj := TStringClass.CreateString(['>QFADS 14:30:30 - 14:45:00 95/11/01']);
TObj.ParseMultiDelimToList([' - ',' ','>QFADS',':','/'],delim_ExcNull,AList);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
Writeln('Parsed sub strings ...');
AList.ForEach(@WrSub);
{ another way of doing the above is as follows .... }
(*
FOR I := 0 TO AList.Count-1 DO
BEGIN
PartObj := TStringClass(AList.Items[I]);
Writeln(PartObj.ZString);
END;
*)
TObj.Free;
AList.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoDirectoryExists;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([APath]);');
Writeln('B := TObj.DirectoryExists;');
TObj := TStringClass.CreateString([APath]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
Write('Directory ');
IF TObj.DirectoryExists THEN
Writeln('exists')
ELSE
Writeln('does not exist');
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoFindCurrentDir;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.FindCurrentDir;');
TObj := TStringClass.Create;
TObj.FindCurrentDir;
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoFileExists;
VAR
TObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('TObj := TStringClass.CreateString([APath]);');
TObj := TStringClass.CreateString([APath]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
Write('File ');
IF TObj.FileExists THEN
Writeln('exists')
ELSE
Writeln('does not exist');
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoFileSplit;
VAR
TObj,DObj,NObj,EObj : TStringClass;
BEGIN
Writeln('Code:');
Writeln('DObj := TStringClass.Create;');
Writeln('NObj := TStringClass.Create;');
Writeln('EObj := TStringClass.Create;');
Writeln('TObj := TStringClass.CreateString([APath]);');
Writeln('TObj.FileSplit(DObj,NObj,EObj);');
DObj := TStringClass.Create;
NObj := TStringClass.Create;
EObj := TStringClass.Create;
TObj := TStringClass.CreateString([APath]);
TObj.FileSplit(DObj,NObj,EObj);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
Writeln(DObj.ZString);
Writeln(NObj.ZString);
Writeln(EObj.ZString);
TObj.Free;
DObj.Free;
NObj.Free;
EObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoGrep;
VAR
TObj : TStringClass;
AList : TWordContainer;
E : LONGINT;
BEGIN
TObj := TStringClass.CreateString([APath]);
Writeln;
Writeln('Result:');
Writeln(TObj.ZString);
Writeln('Grep locations:');
AList := TWordContainer.Create;
AList.Capacity := 10;
IF TObj.Grep(['in'],AList) > 0 THEN
BEGIN
FOR E := 0 TO AList.Count-1 DO
WRITELN(' ',AList.Items[E]);
END
ELSE
Writeln('< none>');
AList.RemoveAll;
IF TObj.Grep(['s?'],AList) > 0 THEN
BEGIN
FOR E := 0 TO AList.Count-1 DO
WRITELN(' ',AList.Items[E]);
END
ELSE
Writeln('< none>');
TObj.Free;
AList.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAddFilterDesc;
VAR
TObj : TStringClass;
BEGIN
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AddFilterDesc([''Pascal source files''],[''PAS'']);');
Writeln('TObj.AddFilterDesc([''C++ source files''],[''CPP'']);');
Writeln;
Writeln('Result : ');
Writeln;
TObj := TStringClass.Create;
TObj.AddFilterDesc(['Pascal source files'],['PAS']);
TObj.AddFilterDesc(['C++ source files'],['CPP']);
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAddBackSlash;
VAR
TObj : TStringClass;
BEGIN
Writeln('TObj := TStringClass.CreateString([APath]);');
Writeln('TObj.AddBackSlash;');
Writeln;
Writeln('Result : ');
Writeln;
TObj := TStringClass.CreateString([APath]);
TObj.AddBackSlash;
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAnsiCompareStr;
VAR
TObj : TStringClass;
C : INTEGER;
BEGIN
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.ToUpper;');
Writeln('C := TObj.AnsiCompareStr(AStr);');
Writeln;
Writeln('Result : ');
Writeln;
TObj := TStringClass.CreateString([AStr]);
TObj.ToUpper;
C := TObj.AnsiCompareStr(AStr);
Writeln(TObj.ZString,' : ',AStr,' : ',C);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAnsiCompareText;
VAR
TObj : TStringClass;
C : INTEGER;
BEGIN
Writeln('TObj := TStringClass.CreateString([AStr]);');
Writeln('TObj.ToUpper;');
Writeln('C := TObj.AnsiCompareText(AStr);');
Writeln;
Writeln('Result : ');
Writeln;
TObj := TStringClass.CreateString([AStr]);
TObj.ToUpper;
C := TObj.AnsiCompareText(AStr);
Writeln(TObj.ZString,' : ',AStr,' : ',C);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAnsiLowerCase;
VAR
TObj : TStringClass;
C : INTEGER;
BEGIN
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AnsiLowerCase;');
Writeln;
Writeln('Result : ');
Writeln;
TObj := TStringClass.Create;
TObj.AnsiLowerCase(AStr);
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAnsiUpperCase;
VAR
TObj : TStringClass;
C : INTEGER;
BEGIN
Writeln('TObj := TStringClass.Create;');
Writeln('TObj.AnsiUpperCase;');
Writeln;
Writeln('Result : ');
Writeln;
TObj := TStringClass.Create;
TObj.AnsiUpperCase(AStr);
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
PROCEDURE DoAppendStr;
VAR
TObj : TStringClass;
C : INTEGER;
BEGIN
Writeln('TObj := TStringClass.CreateString([APChar]);');
Writeln('TObj.AppendStr(AStr);');
Writeln;
Writeln('Result : ');
Writeln;
TObj := TStringClass.CreateString([APChar]);
TObj.AppendStr(AStr);
Writeln(TObj.ZString);
TObj.Free;
END;
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ }
BEGIN
ANullStrObj := TStringClass.Create;
AStrObj := TStringClass.CreateString(['TStringClass string']);
OutConsole.ClrScr;
CASE fid OF
id_Create :
DoCreate;
id_CreateSize :
DoCreateSize;
id_CreateString :
DoCreateString;
id_CreateStringNL :
DoCreateStringNL;
id_CreateBoolean :
DoCreateBoolean;
id_Destroy :
DoDestroy;
id_Copy :
DoCopy;
id_CopyFrom :
DoCopyFrom;
id_Clear :
DoClear;
id_Empty :
DoEmpty;
id_Assign :
DoAssign;
id_AssignFrom :
DoAssignFrom;
id_AssignLen :
DoAssignLen;
id_AssignMid :
DoAssignMid;
id_AssignNL :
DoAssignNL;
id_AssignPad :
DoAssignPad;
id_AssignRight :
DoAssignRight;
id_AssignTrim :
DoAssignTrim;
id_Append :
DoAppend;
id_AppendBoolean :
DoAppendBoolean;
id_AppendByte :
DoAppendByte;
id_AppendCh :
DoAppendCh;
id_AppendDIC :
DoAppendDIC;
id_AppendDouble :
DoAppendDouble;
id_AppendDoubleTrim :
DoAppendDoubleTrim;
id_AppendExt :
DoAppendExt;
id_AppendExtTrim :
DoAppendExtTrim;
id_AppendLen :
DoAppendLen;
id_AppendLong :
DoAppendLong;
id_AppendMid :
DoAppendMid;
id_AppendNL :
DoAppendNL;
id_AppendPad :
DoAppendPad;
id_AppendPtr :
DoAppendPtr;
id_AppendReal :
DoAppendReal;
id_AppendRight :
DoAppendRight;
id_AppendSIC :
DoAppendSIC;
id_AppendTrim :
DoAppendTrim;
id_AppendWithTab :
DoAppendWithTab;
id_NLAppend :
DoNLAppend;
id_Prepend :
DoPrepend;
id_FirstNonSpaceCh :
DoFirstNonSpaceCh;
id_HasCh :
DoHasCh;
id_isCh :
DoIsCh;
(*
id_IsFirstCh = 44;
id_IsLastCh = 45;
id_LastNonSpaceCh = 46;
id_RemoveLastCh = 47;
id_SetCh = 48;
id_FromBoolean = 49;
id_FromByte = 50;
id_FromChar = 51;
id_FromDouble = 52;
id_FromDoubleTrim = 53;
id_FromExt = 54;
id_FromExtTrim = 55;
id_FromLong = 56;
id_FromPtr = 57;
id_FromReal = 58;
id_FromRealTrim = 59;
*)
id_FromRGB :
DoFromRGB;
(*
id_HexFromByte = 61;
id_HexFromLong = 62;
id_HexFromPtr = 63;
id_HexFromWord = 64;
id_ToBoolean = 65;
id_ToByte = 66;
id_ToChar = 67;
id_ToDouble = 68;
id_ToExt = 69;
id_ToInteger = 70;
id_ToLong = 71;
id_ToReal = 72;
id_ToRGB = 73;
id_ToWord = 74;
*)
id_AppendStr :
DoAppendStr;
(*
id_UpperCase = 76;
id_LowerCase = 77;
id_CompareStr = 78;
id_CompareText = 79;
*)
id_AnsiUpperCase :
DoAnsiUpperCase;
id_AnsiLowerCase :
DoAnsiLowerCase;
id_AnsiCompareStr :
DoAnsiCompareStr;
id_AnsiCompareText :
DoAnsiCompareText;
(*
id_IsValidIdent = 84;
id_IntToStr = 85;
id_IntToHex = 86;
id_StrToInt = 87;
id_StrToIntDef = 88;
id_LoadStr = 89;
id_FmtLoadStr = 90;
id_Format = 91;
id_FloatToStr = 92;
id_FloatToStrF = 93;
id_FormatFloat = 94;
id_StrToFloat = 95;
id_StrCat = 96;
id_StrComp = 97;
id_StrCopy = 98;
id_StrECopy = 99;
id_StrEnd = 100;
id_StrIComp = 101;
id_StrLCat = 102;
id_StrLIComp = 103;
id_StrLComp = 104;
id_StrLCopy = 105;
id_StrLen = 106;
id_StrLower = 107;
id_StrMove = 108;
id_StrPas = 109;
id_StrPCopy = 110;
id_StrPos = 111;
id_StrRScan = 112;
id_StrScan = 113;
id_StrUpper = 114;
id_Compare = 115;
id_CompareI = 116;
id_CompareL = 117;
id_CompareLI = 118;
id_CompareLong = 119;
id_CompareDouble = 120;
id_CompareExt = 121;
id_IsSame = 122;
id_IsSameI = 122;
id_isSameL = 123;
id_IsSameLI = 124;
id_Includes = 125;
id_Within = 126;
*)
id_Delete :
DoDelete;
id_DeleteFrom :
DoDeleteFrom;
(*
id_Insert = 128;
id_InsertL = 129;
id_PadCentre = 130;
id_PadEnd = 131;
id_PadFront = 132;
id_RemoveDIC = 133;
id_RemoveSIC = 134;
id_Trim = 135;
id_TrimEnd = 136;
id_TrimFront = 137;
id_TrimZero = 138;
*)
id_FindCmdLine :
DoFindCmdLine;
(*
id_FindCmdLineAndParse = 140;
id_FindCmdLineParam = 141;
id_AppendStringRes = 142;
id_LoadStringRes = 143;
id_ReadIniKeyword = 144;
id_WriteIniKeyword = 145;
id_FindIniSectionKeywords = 146;
*)
id_AddBackSlash :
DoAddBackSlash;
(*
id_BuildPathName = 148;
id_DefaultExtension = 149;
id_ExpandFileName = 150;
*)
id_addFilterDesc :
DoAddFilterDesc;
id_FindRelPath :
DoFindRelPath;
(*
id_ForceExtension = 151;
id_HasBackSlash = 152;
id_HasDrive = 153;
id_HasExtension = 154;
id_HasFileName = 155;
id_HasDirectory = 156;
*)
id_FindCurrentDir :
DoFindCurrentDir;
id_DirectoryExists :
DoDirectoryExists;
(*
id_DriveExists = 158;
*)
id_FileExists :
DoFileExists;
id_FileSplit :
DoFileSplit;
id_JustExtension :
DoJustExtension;
id_JustFileName :
DoJustFileName;
id_JustName :
DoJustName;
id_JustDirectory :
DoJustDirectory;
(*
id_SetCurDir = 163;
id_ChCount = 164;
id_FindBetween2Ch = 165;
id_FindFirst = 166;
id_FindFirstCh = 167;
id_FindLast = 168;
id_FindLastCh = 169;
id_FindNext = 170;
id_FindNextCh = 171;
id_FindPrev = 172;
id_FindPrevCh = 173;
id_SubStrCount = 174;
id_FirstCharToUpper = 175;
id_IsAlphaNumeric = 176;
id_ToLower = 177;
id_ToUpper = 178;
*)
id_ReplaceAll :
DoReplaceAll;
(*
id_ReplaceFirst = 180;
id_ReplaceLast = 181;
id_ReplaceChAll = 182;
id_ReplaceChFirst = 183;
id_ReplaceChLast = 184;
id_FirstParseDelim = 185;
id_NextParseDelim = 186;
id_ParseDelimCount = 187;
*)
id_ParseDelimToList :
DoParseDelimToList;
id_ParseMultiDelimToList :
DoParseMultiDelimToList;
(*
id_ParsePosToList = 189;
*)
id_grep :
DoGrep;
END;
{ scroll to top }
OutConsole.ScrollTo(0,0);
END;
{ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }
end.