Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get MessageSet IDs as a Comma-Separated String
See more IMAP Examples
Demonstrates the Chilkat MessageSet.ToCommaSeparatedStr method, which returns the unique identifiers as a comma-separated string in ascending numeric order. It takes no arguments; an empty set returns an empty string. This example inserts a few ids and prints them.
Background: This is the fully expanded, human-readable form — every identifier listed explicitly, such as
1,2,3,5. It is handy for logging or display. When you need the terse form that collapses consecutive runs into ranges (for example 1:3,5), use ToCompactString instead. Like the compact form, the returned string contains only the numeric values and not the HasUids setting.Chilkat Pascal (Lazarus/Delphi) 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.MessageSet;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
msgSet: TMessageSet;
csv: string;
begin
// Demonstrates the MessageSet.ToCommaSeparatedStr method, which returns the unique identifiers
// as a comma-separated string in ascending numeric order. It takes no arguments.
msgSet := TMessageSet.Create;
// Build a set by inserting individual identifiers. The insertion order does not matter;
// the identifiers are kept in ascending order and duplicates are ignored.
msgSet.InsertId(3);
msgSet.InsertId(1);
msgSet.InsertId(2);
msgSet.InsertId(5);
// Get the identifiers as a comma-separated string.
csv := msgSet.ToCommaSeparatedStr();
WriteLn(csv);
// Output: 1,2,3,5
msgSet.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.