From Bohemia Interactive Community
Revision as of 11:36, 7 April 2019 by Erentar (talk | contribs) (template:command argument fix)
Jump to navigation Jump to search



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
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
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
Posted on 14 juil, 2016
Pierre MGI
You can substract array from array using select: _array = [[1],[2],[3]]; _sub = [2]; _array - _sub // [[1],[2],[3]; _array select {!(_x isEqualTo _sub)} // [[1],[3]]; [[1],[2],[2],[2],[2],[3]] select {!(_x isEqualTo _sub)} // [[1],[3]];

Bottom Section

Posted on June 22, 2015 - 23:23 (UTC)
Killzone Kid
Usually when select tries to pick up element out of range, Arma throws "division by zero" error. However there are exceptions. Basically as long as index of element you are selecting is less then or equal to array size, you will get no error. [] select 0; //ok, result is nil [1,2,3] select 3; //ok, result is nil [1,2,3] select 4; //division by zero
Posted on November 12, 2016 - 22:36 (UTC)
It is not safe to escape the code block of alternative syntax #5 with exitWith, breakOut etc.
x3 = [1,2,3,4,5] select { if (_x == 3) exitWith { false; }; true }; // could be expected to be: x3 = [1,2,4,5] // actual result: x3 = false
Posted on February 14, 2017 - 16:26 (UTC)
Syntax #5 is the equivalent of passing in a predicate that returns a boolean. In SQF, a piece of code will always return what the last executed command returned. myAliveUnits = allunits select {alive _x;}; // alive returns a boolean, the last statement run was alive _x, therefore this piece of code will return a true/false to the select command myEastGroups = allgroups select {side _x == EAST;}; // returns all groups that are side EAST my4ManGroups = allgroups select { count (units _x) == 4;}; // returns all groups that have 4 men in them UnitsThatDetectedMe = allunits select {_x knowsAbout player > 0.1;}; // returns a list of units that have detected the player
Posted on May 28, 2017 - 13:51 (UTC)
Very simple example of how to report about the status of the player: [ "Player is dead.", "Player is alive" ] select ( alive player ) returns "Player is alive" because ( alive player ) returned true. If ( alive player ) returned false, the first element (0) would have been returned. That is a great way of reporting about something without having to write a complicated it then else statement.
Posted on April 14, 2018 - 13:06 (UTC)
Since 1.82 "#" symbol can be used to select from an array. It's shorter to write and has higher priority than math functions.