parseNumber: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) (description) |
(fix commit, added example) |
||
Line 7: | Line 7: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| 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. | | Parses the string, interpreting its content as a floating point number. | ||
<br>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. | |||
<br>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. |= Description | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | '''parseNumber''' string |= Syntax | ||
|p1= string: [[String]] |= Parameter 1 | |p1= string: [[String]] |= Parameter 1 | ||
Line 17: | Line 19: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1= | |x1= <code>_number = [[parseNumber]] "0.125";</code> |= Example 1 | ||
|x2= <code>_number = [[parseNumber]] "2 abc";//2</code> |= Example 2 | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | [[BIS_fnc_parseNumber]] |= See also | ||
}} | }} | ||
Line 27: | Line 31: | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<!-- Note Section BEGIN --> | <!-- Note Section BEGIN --> | ||
<dd class="notedate">Posted on Aug 28, 2014 | |||
< | <dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]] | ||
<dd class="note"> (A3 1.26)It only detects the first occurrence of a number in the string, return 0 by default. | |||
<code>[[parseNumber]] "2s4f"; // 2 | |||
[[parseNumber]] "s2f4"; // 0</code> | |||
parse config or code, currently [[BIS_fnc_parseNumber]], occurrence is only limited with number, return -1 by default. | |||
<code>{s3s4f} [[call]] [[BIS_fnc_parseNumber]]; // -1</code> | |||
[[ | |||
<!-- Note Section END --> | <!-- Note Section END --> | ||
</dl> | </dl> | ||
Line 47: | Line 46: | ||
[[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]] | [[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands | [[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]] |
Revision as of 23:38, 2 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