parseNumber: Difference between revisions
Jump to navigation
Jump to search
(note) |
Killzone Kid (talk | contribs) (description) |
||
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. |= Description | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Line 17: | Line 17: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1= < | |x1= _number <nowiki>=</nowiki> '''parseNumber''' "0.125" |= Example 1 | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | |= See also | ||
}} | }} | ||
Line 27: | Line 27: | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<!-- Note Section BEGIN --> | <!-- Note Section BEGIN --> | ||
* 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. | |||
<strong>I beg to differ.</strong><br /> | |||
_stringNotContainingValidNumber = "abc"; | |||
< | if(parseNumber _stringNotContainingValidNumber == 0 && _stringNotContainingValidNumber != "0") then | ||
{ | |||
comment "INVALID NUMBER"; | |||
} | |||
else | |||
{ | |||
comment "VALID NUMBER"; | |||
}; | |||
[[User:MulleDK13|MulleDK13]] 09:26, 11 July 2010 (CEST) | |||
<!-- Note Section END --> | <!-- Note Section END --> | ||
</dl> | </dl> | ||
Line 42: | Line 47: | ||
[[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 VBS2|{{uc:{{PAGENAME}}}}]] | ||
Revision as of 21:47, 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"
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.
_stringNotContainingValidNumber = "abc"; if(parseNumber _stringNotContainingValidNumber == 0 && _stringNotContainingValidNumber != "0") then { comment "INVALID NUMBER"; } else { comment "VALID NUMBER"; }; MulleDK13 09:26, 11 July 2010 (CEST)