select: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(see also)
(expanded, format, example)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Selects an index element of an array or config object.
| Selects an element from an array, config entry from [[Config]] or substring from a string (since ["Arma 3","Arma3",127,126674,"Development"]).|= Description
____________________________________________________________________________________________
 
| array  '''select''' index |= Syntax
 
| p1= array : [[Array]] |= Parameter 1
 
| p2= index: [[Number]] - 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. |= Parameter 2
 
| [[Anything]] |= Return value


Index 0 denotes the first element, 1 the second, etc.<br>
If index has decimal places it gets rounded down for fractions less than or equal .5, otherwise it gets rounded up. |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| array  '''select''' index |= Syntax
| s2= array '''select''' boolean |= Syntax
 
| p21= array : [[Array]] |= Parameter 1
 
| p22= boolean: [[Boolean]] - [[true]] => 1, [[false]] => 0|= Parameter 2
 
| r2= [[Anything]] |= Return value
 
____________________________________________________________________________________________
 
| s3= config '''select''' index |= Syntax


|p1= array : [[Array]] |= Parameter 1
| p41= config : [[Config]] |= Parameter 1


|p2= index: [[Number]] or [[Boolean]] ([[true]] => 1, [[false]] => 0)|= Parameter 2
| p42= index: [[Number]] - 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.  |= Parameter 2


| [[Any Value]] |= Return value
| r3= [[Config]] |= Return value


____________________________________________________________________________________________
____________________________________________________________________________________________


|s2= config '''select''' index |= Syntax
| s4= string '''select''' [start, length] |= Syntax


|p21= config: [[Config]] |= Parameter 1
| p61= string: [[String]] |= Parameter 1


|p22= index: [[Number]] |= Parameter 2
| p62= [start, length]: [[Array]] |= Parameter 2


|r2= [[Config]] |= Return value
| p63= start: [[Number]] - String position to start selection from. 0 denotes the first character of the string, 1 the second, etc. If passed number has decimal places it gets rounded down for fractions less than or equal .5, otherwise it gets rounded up. |= Parameter 3
| p64= length (optional): [[Number]] - Number of the string characters to select. If "length" is omitted, selection will be made from "start" to the end of the string. |= Parameter 4
 
| r4= [[String]] |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <code>[1,2,3,4] [[select]] 2;</code> - result is 3 |= Example 1
|x1= <code>[1,2,3,4] [[select]] 2; //result is 3
[[position]] [[player]] [[select]] 2; //result is Z coordinate of player position</code>|= Example 1
 
|x2= <code>["", [[currentWeapon]] [[player]]] [[select]] [[alive]] [[player]]; //if dead "" is selected</code>|= Example 2


|x2= <code>[[position]] [[player]] [[select]] 2;</code> - result is Z coordinate of player position (see [[Position]] for more details) |= Example 2
|x3= <code>([[configFile]] >> "cfgVehicles" >> [[typeOf]] [[vehicle]] [[player]] >> "Turrets") [[select]] 0 >> "gunnerAction";</code>|= Example 3


|x3= <code>([[configFile]] >> "CfgVehicles") [[select]] 0; </code>|= Example 3


|x4= <code>["", [[currentWeapon]] [[player]]] [[select]] [[alive]] [[player]];</code>|= Example 4
|x4= <code>[[hint]] [[str]] ("japa is the man!" [[select]] [8]); //the man!
[[hint]] [[str]] ("japa is the man!" [[select]] [0,7]); //japa is</code>|= Example 4
____________________________________________________________________________________________
____________________________________________________________________________________________



Revision as of 21:16, 12 August 2014

Hover & click on the images for description

Description

Description:
Selects an element from an array, config entry from Config or substring from a string (since ["Arma 3","Arma3",127,126674,"Development"]).
Groups:
Uncategorised

Syntax 1

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

Syntax 2

Syntax:
array select boolean
Parameters:
array : Array
boolean: Boolean - true => 1, false => 0
Return Value:
Anything

Syntax 3

Syntax:
config select index
Parameters:
config : Config
index: Number - 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.
Return Value:
Config

Syntax 4

Syntax:
string select [start, length]
Parameters:
string: String
[start, length]: Array
start: Number - String position to start selection from. 0 denotes the first character of the string, 1 the second, etc. If passed number has decimal places it gets rounded down for fractions less than or equal .5, otherwise it gets rounded up.
length (optional): Number - Number of the string characters to select. If "length" is omitted, selection will be made from "start" to the end of the string.
Return Value:
String

Examples

Example 1:
[1,2,3,4] select 2; //result is 3 position player select 2; //result is Z coordinate of player position
Example 2:
["", currentWeapon player] select alive player; //if dead "" is selected
Example 3:
(configFile >> "cfgVehicles" >> typeOf vehicle player >> "Turrets") select 0 >> "gunnerAction";
Example 4:
hint str ("japa is the man!" select [8]); //the man! hint str ("japa is the man!" select [0,7]); //japa is

Additional Information

See also:
setresizereverseinfindtoArraytoStringforEachcount

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