parseNumber: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>") |
Lou Montana (talk | contribs) m (Text replacement - "<dd class="note">([^}]*)<code>([^<]*)<\/code>" to "<dd class="note">$1<sqf>$2</sqf>") |
||
Line 53: | Line 53: | ||
<dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]</dt> | <dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]</dt> | ||
<dd class="note"> (A3 1.26)It only detects the first occurrence of a number in the string, return 0 by default. | <dd class="note"> (A3 1.26)It only detects the first occurrence of a number in the string, return 0 by default. | ||
< | <sqf>parseNumber "2s4f"; // 2 | ||
parseNumber "s2f4"; // 0</ | parseNumber "s2f4"; // 0</sqf> | ||
parse config or code, currently [[BIS_fnc_parseNumber]], occurrence is only limited with number, return -1 by default. | 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> | <code>{s3s4f} call BIS_fnc_parseNumber; // -1</code> | ||
Line 64: | Line 64: | ||
<dd class="note"> | <dd class="note"> | ||
This command '''does not''' work with strings representing hexadecimal numbers: | This command '''does not''' work with strings representing hexadecimal numbers: | ||
< | <sqf>parseNumber "0xCF"; //Returns 0</sqf> | ||
</dd> | </dd> | ||
</dl> | </dl> |
Revision as of 10:57, 13 May 2022
Description
- Description:
- An SQF equivalent of C++ atof function. 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:
- Strings
Syntax
- Syntax:
- parseNumber string
- Parameters:
- string: String
- Return Value:
- Number
Alternative Syntax
- Syntax:
- parseNumber boolean
- Parameters:
- boolean: Boolean
- Return Value:
- Number - 0 if false, 1 if true
Examples
- Example 1:
- Example 2:
- Example 3:
- Example 4:
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
- 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.
parse config or code, currently BIS_fnc_parseNumber, occurrence is only limited with number, return -1 by default.parseNumber "2s4f"; // 2 parseNumber "s2f4"; // 0
{s3s4f} call BIS_fnc_parseNumber; // -1
- Posted on April 5, 2021 - 14:56 (UTC)
- R3vo
-
This command does not work with strings representing hexadecimal numbers:
parseNumber "0xCF"; //Returns 0
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Strings