ToNumber

From GECK
Jump to: navigation, search


A function added by the New Vegas Script Extender.

Description

Converts a string that contains a number, to a number. You can use '#' as shorthand alias.

If reportError is true, an NVSE Error will be reported if converting the string to a number was unsuccessful. The error can be caught using TestExpr.

  • This arg was added in xNVSE 6.2.9.

Syntax

[help]
(float) ToNumber ToConvert:string hexidecimal:bool reportError:bool{0}

Example

int iNum
string_var MyString
let MyString := "1969"
let iNum := #MyString ; 1969
float fNum
let MyString := "3.14"
let fNum := #MyString ; 3.14

let MyString := "00000ADD"
let iNum := ToNumber MyString, 1 ; 2781
let MyString := "0x00000ADD"    ;* will know it's a hex number if it starts with "0x"
let iNum := ToNumber MyString   ; 2781 

See Also