Substring.ToInteger Method

Overload List

#SignatureDescription
1function ToInteger: Integer; overload; inline;Converts the text to an Integer.
2class function ToInteger(const S: Substr.Substring): Integer; overload; static; inline;
3class function ToInteger(const S: string): Integer; overload; static; inline;

Overload 1: function ToInteger: Integer; overload; inline;

Converts the text to an Integer.

Returns: Integer - The value.

Remarks:

Accepted: leading spaces, a sign, then decimal digits, or hexadecimal digits after $, 0x, 0X, x or X. Any other text, or a value outside Integer, raises EConvertError: '<text>' is not a valid integer value for Integer type. An embedded #0 is a character. The class forms take every text kind.

Examples

Decimal and hexadecimal texts.

uses Substr;

procedure Example;
begin
    Assert(Substring(' -42').ToInteger = -42);
    Assert(Substring.ToInteger('$FF') = 255);
end;
See Also: Substr.StrToInt

Overload 2: class function ToInteger(const S: Substr.Substring): Integer; overload; static; inline;

#NameTypeDescription
1SSubstr.Substring

Returns: Integer

Overload 3: class function ToInteger(const S: string): Integer; overload; static; inline;

#NameTypeDescription
1Sstring

Returns: Integer