Locale Parse-type-() Method

Uses locale awareness to parse the text value in "value".

Function Signature

 bool ParseInt( value, int& out )

bool ParseInt64( value, int64_t& out )

bool ParseDouble( value, double& out )

Parameters

Parameter Type Description

value

string

The value to parse.

out

int&

int64_t&

double&

(Output) The value that receives the parsed number.

Return

Type Description

bool

Returns true if the value was successfully parsed.

Technical Details

SBM ModScript version: 11.3.

Example

var germanLocale = CreateLocale("de_DE");
var intV = 0;
var intR = germanLocale.ParseInt("2345", intV );
Ext.WriteStream( "int: result: ${intR}, expected: 2345, parsed: ${intV}" );
var int64V = 0ll;
var int64R = germanLocale.ParseInt64("422564125658", int64V );
Ext.WriteStream( "int64_t: result: ${int64R}, expected: 422564125658, parsed: ${int64V}" );
var dblV = 0.0;
var dblR = germanLocale.ParseDouble("234,2342", dblV );
Ext.WriteStream( "double: result: ${dblR}, expected: 234.2342, parsed: ${dblV}" ); 

Result:

int: result: true, expected: 2345, parsed: 2345
int64_t: result: true, expected: 422564125658, parsed: 422564125658
double: result: true, expected: 234.2342, parsed: 234.2342

Notes

Check the return value for success before using "out".

Related Topics

Locale