Clear
procedure Clear;
Example
procedure ResetList(const Items: TStringList);
begin
Items.Clear;
end;
Usage
Invokes the TStrings string list's abstract clear operation to remove every entry.
- Treat all current indexes and entry aliases as invalid after a successful clear.
- Do not assume associated objects are freed or retained from the
TStringstype alone. - Clear is not rollback-safe. Event and destructor exceptions can occur after state changes.
Additional Technical Info
Clear is declared by hidden ancestor TStrings and is normally used through a concrete visible descendant such as TStringList. The base class supplies no storage implementation, so object destruction, capacity changes and notifications are descendant-defined.
Source-backed behaviour
TStrings.Clear is abstract. In the visible parameterless TStringList, Clear emits changing/changed notifications when nonempty, sets count to zero, releases capacity, and does not free associated objects because that construction path is non-owning. A native TStringList created with OwnsObjects=True gathers and frees its object references after detaching the array.
If an owned object's destructor raises, the list is already empty and storage released; remaining gathered objects after the failing one are not guaranteed to be freed.
Related members
Delete removes one entry. Objects explains reference ownership. Count becomes zero after a successful clear.