parseNumber: Difference between revisions
Jump to navigation
Jump to search
(fix commit, added example) |
No edit summary |
||
Line 48: | Line 48: | ||
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]] | ||
<!-- CONTINUE Notes --> | |||
<dl class="command_description"> | |||
<dd class="notedate">Posted on October 3, 2014 - 22:21 (UTC)</dd> | |||
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt> | |||
<dd class="note"> | |||
For clarity, the output of parseNumber only reflects numbers found before the first non-numeric character.<br><br> | |||
When trying to parse a string from an array, be sure to properly use parenthesis.<br> | |||
<code>parseNumber _array select 0; '''//""Error Generic error in expression"", position: _array |#|select 0''' | |||
hint format["%1", parseNumber _array select 0]; '''//"Error Generic error in expression", pos: _array |#|select 0<br>''' | |||
parseNumber (_array select 0); '''//No error'''</code> | |||
</dd> | |||
</dl> | |||
<!-- DISCONTINUE Notes --> |
Revision as of 23:21, 3 October 2014
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
Examples
- Example 1:
_number = parseNumber "0.125";
- Example 2:
_number = parseNumber "2 abc";//2
Additional Information
- See also:
- BIS_fnc_parseNumber
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
- 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
- Posted on October 3, 2014 - 22:21 (UTC)
- DreadedEntity
-
For clarity, the output of parseNumber only reflects numbers found before the first non-numeric character.
When trying to parse a string from an array, be sure to properly use parenthesis.
parseNumber _array select 0; //""Error Generic error in expression"", position: _array |#|select 0 hint format["%1", parseNumber _array select 0]; //"Error Generic error in expression", pos: _array |#|select 0
parseNumber (_array select 0); //No error