BIS fnc subSelect: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>")
m (Some wiki formatting)
 
(3 intermediate revisions by the same user not shown)
Line 17: Line 17:
|descr= Returns a sub-selection of the passed array.
|descr= Returns a sub-selection of the passed array.


|s1=[array, start, endOrLength] call [[BIS_fnc_subSelect]]
|s1= [array, start, endOrLength] call [[BIS_fnc_subSelect]]


|p1= array: [[Array]] array to select sub array from
|p1= array: [[Array]] array to select sub array from
Line 27: Line 27:
|r1= [[Array]]
|r1= [[Array]]


|x1= <code>private _array = ["a","b",true,3,8];
|x1= <sqf>
[_array, 2] [[call]] [[BIS_fnc_subSelect]]; {{codecomment|// returns [true,3,8]}}</code>
private _array = ["a", "b", true, 3, 8];
[_array, 2] call BIS_fnc_subSelect; // returns [true,3,8]
</sqf>


|x2= <code>[_array, -2] call BIS_fnc_subSelect; {{codecomment|// returns [3,8]}}</code>
|x2= <sqf>[_array, -2] call BIS_fnc_subSelect; // returns [3,8]</sqf>


|x3= <code>[_array, 1, 3] call BIS_fnc_subSelect; {{codecomment|// returns ["b",true,3]}}</code>
|x3= <sqf>[_array, 1, 3] call BIS_fnc_subSelect; // returns ["b",true,3]</sqf>


|x4= <code>[_array, 1, -2] call BIS_fnc_subSelect; {{codecomment|// returns ["b",true]}}</code>
|x4= <sqf>[_array, 1, -2] call BIS_fnc_subSelect; // returns ["b",true]</sqf>


|seealso= [[select]] [[count]] [[selectRandom]] [[BIS_fnc_arrayShuffle]] [[BIS_fnc_randomIndex]]
|seealso= [[select]] [[count]] [[selectRandom]] [[BIS_fnc_arrayShuffle]] [[BIS_fnc_randomIndex]]
}}
}}

Latest revision as of 23:02, 12 July 2022

Hover & click on the images for description

Description

Description:
Returns a sub-selection of the passed array.
Execution:
call
Groups:
Arrays

Syntax

Syntax:
[array, start, endOrLength] call BIS_fnc_subSelect
Parameters:
array: Array array to select sub array from
start: Number index of array to begin sub-array. If negative, index is counted from the end of array
endOrLength: Number - index of array to end the sub-array. If ommitted, remainder of the array will be selected. If negative, it specifies the length of the sub-array (in absolute form)
Return Value:
Array

Examples

Example 1:
private _array = ["a", "b", true, 3, 8]; [_array, 2] call BIS_fnc_subSelect; // returns [true,3,8]
Example 2:
[_array, -2] call BIS_fnc_subSelect; // returns [3,8]
Example 3:
[_array, 1, 3] call BIS_fnc_subSelect; // returns ["b",true,3]
Example 4:
[_array, 1, -2] call BIS_fnc_subSelect; // returns ["b",true]

Additional Information

See also:
select count selectRandom BIS_fnc_arrayShuffle BIS_fnc_randomIndex

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