Sample code for 30+ languages & platforms
Lazarus Pascal

Load StringTable from a StringBuilder

Demonstrates how to load a StringTable from the text contained in a Chilkat StringBuilder object.

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
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,
  Chilkat.StringTable;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  strTab: TStringTable;
  sb: TStringBuilder;
  i: Integer;
  numStrings: Integer;

begin
  success := False;

  strTab := TStringTable.Create;
  sb := TStringBuilder.Create;

  sb.Append('This is line 1' + #13#10);
  sb.Append('An empty line follows...' + #13#10);
  sb.Append(#13#10);
  sb.Append('This is line 4' + #13#10);

  strTab.AppendFromSb(sb);

  i := 0;
  numStrings := strTab.Count;
  while i < numStrings do
    begin
      WriteLn(i + ': ' + strTab.StringAt(i));
      i := i + 1;
    end;



  strTab.Free;
  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.