Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure Subrange(const Src: Substring; const SrcIdx, SrcLen: Integer); overload; | Views SrcLen characters of Src from SrcIdx (1-based), copying no character. |
| 2 | procedure Subrange(const Src: string; const SrcIdx, SrcLen: Integer); overload; | Views SrcLen characters of Src from SrcIdx, without copying them. |
Overload 1: procedure Subrange(const Src: Substring; const SrcIdx, SrcLen: Integer); overload;
Views SrcLen characters of Src from SrcIdx (1-based), copying no character.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | Substring | |
| 2 | SrcIdx | Integer | |
| 3 | SrcLen | Integer |
Result: stored in self (calling object)
Remarks:
The view is valid while Src lives unchanged. The range must lie inside Src, else ESubstringRangeError is raised.
Examples
The key of a key=value line, viewed in place.
uses Substr;
procedure Example;
var Line, Key: Substring;
begin
Line := Substring('key=value');
Key.Subrange(Line, 1, 3);
Assert(Key = 'key');
end;
Overload 2: procedure Subrange(const Src: string; const SrcIdx, SrcLen: Integer); overload;
Views SrcLen characters of Src from SrcIdx, without copying them.
| # | Name | Description |
|---|---|---|
| 1 | Src | The string viewed; it must live unchanged while the view is used. |
| 2 | SrcIdx | The first character's position, 1-based. |
| 3 | SrcLen | The number of characters. |
Result: stored in self (calling object)
Remarks:
The range must lie inside Src, else ESubstringRangeError is raised.
Examples
A view of a string's value part.
uses Substr;
procedure Example;
var Text: string;
s: Substring;
begin
Text := 'key=value';
s.Subrange(Text, 5, 5);
Assert(s = 'value');
Assert(s.IsExternal);
end;