parseNumber

From Bohemia Interactive Community
Revision as of 22:47, 2 October 2014 by Killzone Kid (talk | contribs) (description)
Jump to navigation Jump to search
-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Parses the string, interpreting its content as a floating point number. The command first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax resembling that of floating point literals, and interprets them as a numerical value. The rest of the string after the last valid character is ignored and has no effect on the behavior of this command. If the first sequence of non-whitespace characters in string does not form a valid floating-point number, or if no such sequence exists because either string is empty or contains only whitespace characters, no conversion is performed and the command returns 0.
Groups:
Uncategorised

Syntax

Syntax:
Number = parseNumber string
Parameters:
string: String
Return Value:
Number

Examples

Example 1:
_number = parseNumber "0.125"

Additional Information

See also:
See also needed

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

  • If the text does not represent a number ("abc" for example), parseNumber will return 0 (zero). It is therefore not possible to use parseNumber to determine if the string contains a valid number or not.
I beg to differ.
_stringNotContainingValidNumber = "abc"; if(parseNumber _stringNotContainingValidNumber == 0 && _stringNotContainingValidNumber != "0") then { comment "INVALID NUMBER"; } else { comment "VALID NUMBER"; }; MulleDK13 09:26, 11 July 2010 (CEST)

Bottom Section