select: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(add. classification)
(merged variations)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Selects index element of the array.
| 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 <nowiki><=</nowiki> x.5 it gets floored, otherwise ceiled. |= Description
Index 0 denotes the first element, 1 the second, etc.<br>
If index has decimal places it gets rounded down for fractions less than .5, otherwise it gets rounded up. |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 19: Line 20:


| [[Any Value]] |= Return value
| [[Any Value]] |= Return value
____________________________________________________________________________________________
|s2= config '''select''' index |= Syntax
|p21= config: [[Config]] |= Parameter 1
|p22= index: [[Number]] |= Parameter 2
|r2= [[Config]] |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <code>[1,2,3,4] select 2</code> - result is 3 |= Example 1
|x1= <code>[1,2,3,4] select 2</code> - result is 3 |= Example 1


|x2= <code>[1,2,3,4] select true</code> - result is 2.<br />
|x2= <code>[[position]] [[player]] select 2</code> - result is Z coordinate of player position (see [[Position]] for more details) |= Example 3
Alternative method. If the index is [[false]], this selects the first element of the array. If it is [[true]], it selects the second one. The reason for this is that [[false]] is an alias for 0 and [[true]] an alias for 1. '''Obsolete syntax'''.  |= Example 2


|x3= <code>[[position]] [[player]] select 2</code> - result is Z coordinate of player position (see [[Position]] for more details) |= Example 3
|x3= <code>(configFile >> "CfgVehicles") select 0 </code>|= Example 4
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[select config]], [[select_string_(VBS2)|select string]] |= SEEALSO  
| [[count]] |= SEEALSO  


}}
}}
Line 36: Line 46:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
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.
--[[User:General Barron|General Barron]] 02:02, 3 March 2009 (CET)


<!-- Note Section END -->
<!-- Note Section END -->

Revision as of 16:05, 15 June 2010

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 .5, otherwise it gets rounded up.
Groups:
Uncategorised

Syntax

Syntax:
array select index
Parameters:
array : Array
index: Number
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

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. --General Barron 02:02, 3 March 2009 (CET)

Bottom Section