parseSimpleArray: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\{\{GameCategory\|(arma[0123])\|[ _]?New[ _]Scripting[ _]Commands[ _]List\}\}" to "{{GameCategory|$1|New Scripting Commands}}") |
Lou Montana (talk | contribs) m (Text replacement - "_{10,} " to "") |
||
Line 1: | Line 1: | ||
{{Command|Comments= | {{Command|Comments= | ||
| arma3 |Game name= | | arma3 |Game name= | ||
Line 10: | Line 9: | ||
|gr2= Arrays |GROUP2= | |gr2= Arrays |GROUP2= | ||
| Converts given, formatted as simple array, [[String]] into a valid [[Array]]. Simple array is array consisting of [[Number]]s, [[String]]s, [[Boolean]]s and [[Array]]s of all of the above. For example: <tt>[1,"2",true,[4,"five",false]]</tt>. The string representation of this array compatible with [[parseSimpleArray]] will be <tt>"[1,""2"",true,[4,""five"",false]]"</tt> accordingly. This command is almost '''4x faster''' than similar uncached [[call]] [[compile]] method. And because [[call]] [[compile]] is not required, it is also '''more secure''' and primarily intended for use with [[callExtension]] to parse the [[String]] output into [[Array]]. Since Arma 3 v.1.95.145925 the command will tolerate extra spaces and supports single quotes. The only recognised keywords (case '''in'''sensitive) are: | | Converts given, formatted as simple array, [[String]] into a valid [[Array]]. Simple array is array consisting of [[Number]]s, [[String]]s, [[Boolean]]s and [[Array]]s of all of the above. For example: <tt>[1,"2",true,[4,"five",false]]</tt>. The string representation of this array compatible with [[parseSimpleArray]] will be <tt>"[1,""2"",true,[4,""five"",false]]"</tt> accordingly. This command is almost '''4x faster''' than similar uncached [[call]] [[compile]] method. And because [[call]] [[compile]] is not required, it is also '''more secure''' and primarily intended for use with [[callExtension]] to parse the [[String]] output into [[Array]]. Since Arma 3 v.1.95.145925 the command will tolerate extra spaces and supports single quotes. The only recognised keywords (case '''in'''sensitive) are: | ||
Line 20: | Line 18: | ||
* <tt>any</tt> - translates into [[nil]] | * <tt>any</tt> - translates into [[nil]] | ||
|DESCRIPTION= | |DESCRIPTION= | ||
| '''parseSimpleArray''' stringArray|SYNTAX= | | '''parseSimpleArray''' stringArray|SYNTAX= | ||
Line 27: | Line 24: | ||
| [[Array]] - valid array|RETURNVALUE= | | [[Array]] - valid array|RETURNVALUE= | ||
|x1=<code>_arr = [[parseSimpleArray]] "[1,2,3]";</code>|= | |x1=<code>_arr = [[parseSimpleArray]] "[1,2,3]";</code>|= | ||
Line 37: | Line 33: | ||
// Note how _bool and _num do not need [[str]], however if used anyway, the result in this case would be identical | // Note how _bool and _num do not need [[str]], however if used anyway, the result in this case would be identical | ||
[[hint]] [[str]] _res; // [true,123.45,"ok",[1,false,"cool"]]</code> |EXAMPLE2= | [[hint]] [[str]] _res; // [true,123.45,"ok",[1,false,"cool"]]</code> |EXAMPLE2= | ||
| [[set]], [[resize]], [[pushBack]], [[pushBackUnique]], [[select]], [[apply]], [[reverse]], [[count]], [[find]], [[in]], [[forEach]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[arrayIntersect]], [[callExtension]] |SEEALSO= | | [[set]], [[resize]], [[pushBack]], [[pushBackUnique]], [[select]], [[apply]], [[reverse]], [[count]], [[find]], [[in]], [[forEach]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[arrayIntersect]], [[callExtension]] |SEEALSO= |
Revision as of 02:15, 17 January 2021
Description
- Description:
- Converts given, formatted as simple array, String into a valid Array. Simple array is array consisting of Numbers, Strings, Booleans and Arrays of all of the above. For example: [1,"2",true,[4,"five",false]]. The string representation of this array compatible with parseSimpleArray will be "[1,""2"",true,[4,""five"",false]]" accordingly. This command is almost 4x faster than similar uncached call compile method. And because call compile is not required, it is also more secure and primarily intended for use with callExtension to parse the String output into Array. Since Arma 3 v.1.95.145925 the command will tolerate extra spaces and supports single quotes. The only recognised keywords (case insensitive) are:
- Groups:
- StringsArrays
Syntax
- Syntax:
- parseSimpleArray stringArray
- Parameters:
- stringArray: String - string formatted as simple array
- Return Value:
- Array - valid array
Examples
- Example 1:
_arr = parseSimpleArray "[1,2,3]";
- Example 2:
_bool = true; _num = 123.45; _str = "ok"; _arr = [1,false,"cool"]; _res = parseSimpleArray format ["[%1,%2,%3,%4]", _bool, _num, str _str, str _arr]; // Note how _bool and _num do not need str, however if used anyway, the result in this case would be identical hint str _res; // [true,123.45,"ok",[1,false,"cool"]]
Additional Information
- See also:
- setresizepushBackpushBackUniqueselectapplyreversecountfindinforEachdeleteAtdeleteRangeappendsortarrayIntersectcallExtension
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
Bottom Section