Substring.Capacity Property

property Capacity: Integer read GetCapacity write SetCapacity;

The characters the string holds without taking more memory.

Returns: Integer

Remarks:

Setting it reserves room for that many characters and empties the string; Resize reserves and keeps the text. Set it before a loop: SubstringAllocCheck allows it, and the appends inside the loop then take no memory.

Examples

Reserving room for a long line.

uses Substr;

procedure Example;
var s: Substring;
begin
    s.Capacity := 2000;
    Assert(s.IsEmpty);
    Assert(s.Capacity >= 2000);
end;
See Also: Substring.Resize