Skip to main content

GetText

function GetText: PChar;

Example

procedure PreferManagedText(const Items: TStringList; var Value: string);
begin
// Text is managed; avoid the raw allocated PChar returned by GetText.
Value := Items.Text;
end;

Usage

GetText allocates and returns a null-terminated PChar containing the list's joined Text representation.

  • Prefer Text, which returns a managed String and requires no manual deallocation.
  • Do not retain or pass the pointer across uncertain Velox lifetimes.
  • Treat this member as compatibility-only unless the host supplies an explicit allocator/deallocator contract.

Additional Technical Info

GetText is declared by hidden ancestor TStrings and is normally used through a concrete visible descendant such as TStringList. It is a low-level allocation API; the managed Text property is safer for scripts.

Source-backed behaviour

The installed RTL evaluates the same joined text used by Text, converts it to PChar, and calls StrNew. The returned buffer is a new heap allocation, not a pointer into the list, and normally requires a matching StrDispose by the caller.

The current Code Library exposes GetText but does not expose a matching StrDispose routine. Repeated script calls therefore have no documented safe release path and can leak memory. Embedded null characters also terminate PChar consumers before the managed text's logical end.

SetText accepts PChar input and replaces the list. Text is the normal script-facing equivalent.

Official RTL references

Created 2026-07-15