select: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(note added)
Line 17: Line 17:
|p1= array : [[Array]] |= Parameter 1
|p1= array : [[Array]] |= Parameter 1


|p2= index: [[Number]] |= Parameter 2
|p2= index: [[Number]] (Possibly ArmA3 1.18 with [[Boolean]] supported)|= Parameter 2


| [[Any Value]] |= Return value
| [[Any Value]] |= Return value
Line 46: Line 46:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on 3 March 2009
<dd class="notedate">Posted on 3 March 2009
<dt class="note">'''[[User:General Barron|General Barron]]'''<dd class="note">
<dt class="note">'''[[User:General Barron|General Barron]]'''<dd class="note">
When combined with the [[count]] command, this can be used to read all entries out of a config; even when you don't know exactly how many entries there will be. See the notes under [[count]] for more info.
When combined with the [[count]] command, this can be used to read all entries out of a config; even when you don't know exactly how many entries there will be. See the notes under [[count]] for more info.
<dd class="notedate">Posted on 27 Sep, 2013
<dd class="notedate">Posted on 27 Sep, 2013
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''<dd class="note">Rounding of fractions with [[select]] is not the same as when you use [[round]] command:
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''<dd class="note">Rounding of fractions with [[select]] is not the same as when you use [[round]] command:
Line 56: Line 54:
[[hint]] [[str]] ([0,1] [[select]] _roundThis); //0
[[hint]] [[str]] ([0,1] [[select]] _roundThis); //0
[[hint]] [[str]] [[round]] _roundThis; //1</code>
[[hint]] [[str]] [[round]] _roundThis; //1</code>
<dd class="notedate">Posted on 30 May, 2014 - 1549
<dt class="note">'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''<dd class="note">
In ArmA3 ver 1.18, [[Boolean]] type supported. Which [[true]] defaulted as 1 and [[false]] as 0.
<code>[0,1] [[select]] (56 > 40) // 1
[0,1,2] [[select]] ((![[isNil]] "v") && [[false]]) // 0</code>
<!-- Note Section END -->


<!-- Note Section END -->
</dl>


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>

Revision as of 09:57, 30 May 2014

Hover & click on the images for description

Description

Description:
Selects an index element of an array or config object. Index 0 denotes the first element, 1 the second, etc.
If index has decimal places it gets rounded down for fractions less than or equal .5, otherwise it gets rounded up.
Groups:
Uncategorised

Syntax

Syntax:
array select index
Parameters:
array : Array
index: Number (Possibly ArmA3 1.18 with Boolean supported)
Return Value:
Any Value

Alternative Syntax

Syntax:
config select index
Parameters:
config: Config
index: Number
Return Value:
Config

Examples

Example 1:
[1,2,3,4] select 2 - result is 3
Example 2:
position player select 2 - result is Z coordinate of player position (see Position for more details)
Example 3:
(configFile >> "CfgVehicles") select 0

Additional Information

See also:
count

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

Posted on 3 March 2009
General Barron
When combined with the count command, this can be used to read all entries out of a config; even when you don't know exactly how many entries there will be. See the notes under count for more info.
Posted on 27 Sep, 2013
Killzone_Kid
Rounding of fractions with select is not the same as when you use round command: _roundThis = 0.5; hint str ([0,1] select _roundThis); //0 hint str round _roundThis; //1
Posted on 30 May, 2014 - 1549
ffur2007slx2_5
In ArmA3 ver 1.18, Boolean type supported. Which true defaulted as 1 and false as 0. [0,1] select (56 > 40) // 1 [0,1,2] select ((!isNil "v") && false) // 0

Bottom Section