Convert a string to an integer value, with a default value.
Source position: sysstrh.inc line 147
function StrToIntDef( |
const S: string; |
Default: LongInt |
):LongInt; |
StrToIntDef will convert a string to an integer. If the string contains invalid characters or has an invalid format, then Default is returned.
To be successfully converted, a string can contain a combination of numerical characters, possibly preceded by a minus sign (-). Spaces are not allowed.
None.
|
Convert an integer value to a decimal string. |
|
|
Convert a string to an integer value. |
Program Example82; {$mode objfpc} { This program demonstrates the StrToInt function } Uses sysutils; Begin Writeln (StrToIntDef('1234',0)); Writeln (StrToIntDef('-1234',0)); Writeln (StrToIntDef('0',0)); Try Writeln (StrToIntDef('12345678901234567890',0)); except On E : EConvertError do Writeln ('Invalid number encountered'); end; End.