Substring.CheckIndex Method

procedure CheckIndex(const Indx: Integer);

Raises ESubstringRangeError unless Indx is inside the window.

#NameTypeDescription
1IndxInteger

Result: stored in self (calling object)

Remarks:

The check s[i] and s[i] := run in a unit compiled with {$C+} (assertions on).

Examples

An index past the end.

uses Substr;

procedure Example;
var Raised: Boolean;
begin
    Raised := False;
    try
        Substring('abc').CheckIndex(3);
    except
        on ESubstringRangeError do Raised := True;
    end;
    Assert(Raised);
end;