parseSimpleArray: Difference between revisions
Jump to navigation
Jump to search
m (Update) |
m (template:command argument fix) |
||
Line 22: | Line 22: | ||
[[hint]] [[str]] (_arr1 [[isEqualTo]] _arr2); //true | [[hint]] [[str]] (_arr1 [[isEqualTo]] _arr2); //true | ||
</code> | </code> | ||
Because of this strictness the command is on average '''3x faster''' than similar [[call]] [[compile]] string array 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]]. |= | Because of this strictness the command is on average '''3x faster''' than similar [[call]] [[compile]] string array 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]]. |DESCRIPTION= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| '''parseSimpleArray''' stringArray|= | | '''parseSimpleArray''' stringArray|SYNTAX= | ||
|p1= stringArray: [[String]] - string formatted as simple array |= | |p1= stringArray: [[String]] - string formatted as simple array |PARAMETER1= | ||
| [[Array]] - valid array|= | | [[Array]] - valid array|RETURNVALUE= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Line 39: | Line 39: | ||
_res = [[parseSimpleArray]] [[format]] ["[%1,%2,%3,%4]", _bool, _num, [[str]] _str, [[str]] _arr]; | _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 | // 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> |= | [[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]] |= | | [[set]], [[resize]], [[pushBack]], [[pushBackUnique]], [[select]], [[apply]], [[reverse]], [[count]], [[find]], [[in]], [[forEach]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[arrayIntersect]], [[callExtension]] |SEEALSO= | ||
}} | }} |
Revision as of 14:44, 7 April 2019
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 built for speed and security and because of this has several limitations. There is limited error reporting about format errors as the command expects well formatted array as argument. To be able to see exact format expected, you can just copy output result of str command applied to an array for reference: copyToClipboard str str [1,"2",true,[4,"five",false]] (notice the use of double str with copyToClipboard).
In any case here are the explicit rules:- no spaces are permitted between array elements: [1,2,3] - correct, [1, 2, 3] - incorrect!
- only double quotes " supported for Strings: ["hello"] - correct, ['hello'] - incorrect!
- use " to escape ", for example ["hello"] converted to string should look like this: "[""hello""]"
- no spaces should exist before or after array brackets: "[1,2,3]" - correct, "[1,2,3] " - incorrect!
_arr1 = getUnitLoadout player; _arr2 = parseSimpleArray str _arr1; hint str (_arr1 isEqualTo _arr2); //true
Because of this strictness the command is on average 3x faster than similar call compile string array 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. - Groups:
- Uncategorised
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