parseNumber

From Bohemia Interactive Community
Jump to: navigation, search
Introduced with Armed Assault version 1.00
  

Click on the images for descriptions

Introduced in

Game:
Armed Assault
Version:
1.00

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.

Syntax

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

Examples

Example 1:
_number = parseNumber "0.125";
Example 2:
_number = parseNumber "2 abc";//2

Additional Information

Multiplayer:
-
See also:
BIS_fnc_parseNumber

Notes

Only post proven facts here. Report bugs on the feedback tracker. Use the talk page or the forums for discussions.
Add New Note | How To

Notes

Posted on Aug 28, 2014
ffur2007slx2_5
(A3 1.26)It only detects the first occurrence of a number in the string, return 0 by default. parseNumber "2s4f"; // 2 parseNumber "s2f4"; // 0 parse config or code, currently BIS_fnc_parseNumber, occurrence is only limited with number, return -1 by default. {s3s4f} call BIS_fnc_parseNumber; // -1

Bottom Section