Skip to main content

Names

property Names[Index: Integer]: string read;

Example

procedure ReadFirstName(const Items: TStringList; var Name: string);
begin
Items.NameValueSeparator := '=';
if Items.Count > 0 then
Name := Items.Names[0];
end;

Usage

Names returns the text before the first NameValueSeparator at an indexed entry, or an empty string when no separator exists.

  • Validate 0 <= Index < Count.
  • An empty result is ambiguous between a missing separator and an explicitly empty name.
  • Use IndexOfName or Values for name-based lookup.

Additional Technical Info

Names is declared by hidden ancestor TStrings and is normally used through a concrete visible descendant such as TStringList. It is a parsed view of Strings[Index], not separate stored metadata.

Source-backed behaviour

The installed getter reads the indexed string, finds the first NameValueSeparator with AnsiPos, and returns everything before it. If no separator occurs, the result is empty. Later separator characters remain in the value portion.

Index validation comes from the concrete string getter. A leading separator produces an empty name. Whitespace is not trimmed, case is not changed and duplicate names are permitted.

ValueFromIndex extracts the corresponding value. NameValueSeparator controls the split.

Official RTL references

Created 2026-07-15