Substring.Resize Method

procedure Resize(const aLen: Integer);

Room for aLen characters, keeping the first aLen characters.

#NameDescription
1aLen

The characters reserved; below the Length the text is cut to aLen, as TVec.Resize does.

Result: stored in self (calling object)

Remarks:

Characters shared with another string, or too little room, are copied first. Resize and Capacity reserve room before a loop; SubstringAllocCheck allows them. A negative aLen raises ESubstringRangeError.

Examples

Reserving room and cutting a text.

uses Substr;

procedure Example;
var s: Substring;
begin
    s := Substring('abcdef');
    s.Resize(1000);
    Assert(s = 'abcdef');
    Assert(s.Capacity >= 1000);
    s.Resize(3);
    Assert(s = 'abc');
end;
See Also: Substring.Capacity