|
Navigation: Function Reference > General Utility Functions > strToIntDef() strToIntDef() |
Top Previous Next |
strToIntDef( source: String; default: Integer ) : Integer;
Converts a numerical string into a integer number with a default value if the conversion fails.
Parameters
source |
numerical string |
default |
integer value to return on failure |
var s: string;
var i: integer;
s := '10';
i := strToIntDef( s, 1 );
//i is now equal to 10;
s := '45.23';
i := strToIntDef( s, 1 );
//i is now equal to 1 since the conversion failed
See also: