Lazarus Pascal
Lazarus Pascal
StringBuilder ReplaceWord
Demonstrates the ReplaceWord method.Chilkat Lazarus Pascal Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.StringBuilder;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
sb: TStringBuilder;
numReplacements: Integer;
begin
sb := TStringBuilder.Create;
sb.Append('forest, lumber, lumberjack, jack, timberland');
// The ReplaceWord method replaces word occurances.
// For example:
numReplacements := sb.ReplaceWord('lumber','timber');
numReplacements := sb.ReplaceWord('jack','joe');
// The string content is now:
// forest, timber, lumberjack, joe, timberland
WriteLn(sb.GetAsString());
sb.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.