BIS fnc subSelect: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
m (Some wiki formatting)
 
(32 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma2
____________________________________________________________________________________________
|version1= 1.00


| arma2 |= Game name
|game2= arma2oa
|version2= 1.50


|1.00|= Game version
|game3= tkoh
____________________________________________________________________________________________
|version3= 1.00


| <pre>
|game4= arma3
/************************************************************
|version4= 0.50
Subarray Select


Returns a sub-selection of the passed array. There are various
|gr1= Arrays
methods the sub-array can be determined.


Parameters: [array, beg, <end>]
|descr= Returns a sub-selection of the passed array.
Returns: subarray


array - Array to select sub array from.
|s1= [array, start, endOrLength] call [[BIS_fnc_subSelect]]
beg - Index of array to begin sub-array. If negative, index is
counted from the end of array.
end - Optional. 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).


Examples:
|p1= array: [[Array]] array to select sub array from


_array = ["a","b",true,3,8];
|p2= start: [[Number]] index of array to begin sub-array. '''If negative''', index is counted from the end of array
[_array, 2] call BIS_fnc_subSelect; //returns [true,3,8]
[_array, -2] call BIS_fnc_subSelect; //returns [3,8]
[_array, 1, 3] call BIS_fnc_subSelect; //returns ["b",true,3]
[_array, 1, -2] call BIS_fnc_subSelect; //returns ["b",true]


************************************************************/
|p3= 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)


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
|r1= [[Array]]
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_subSelect]]; --> |= Syntax
|x1= <sqf>
private _array = ["a", "b", true, 3, 8];
[_array, 2] call BIS_fnc_subSelect; // returns [true,3,8]
</sqf>


|p1= |= Parameter 1
|x2= <sqf>[_array, -2] call BIS_fnc_subSelect; // returns [3,8]</sqf>


| |= Return value
|x3= <sqf>[_array, 1, 3] call BIS_fnc_subSelect; // returns ["b",true,3]</sqf>
____________________________________________________________________________________________


|x1= <code></code> |=
|x4= <sqf>[_array, 1, -2] call BIS_fnc_subSelect; // returns ["b",true]</sqf>
____________________________________________________________________________________________
 
| |= See also


|seealso= [[select]] [[count]] [[selectRandom]] [[BIS_fnc_arrayShuffle]] [[BIS_fnc_randomIndex]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Arrays|{{uc:subSelect}}]]
[[Category:Functions|{{uc:subSelect}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:subSelect}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:subSelect}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:subSelect}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:subSelect}}]]

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