a hash b: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Arma[ _]3(\|.*)]]" to "{{GameCategory|arma3|Scripting Commands}}")
m (Text replacement - "_{10,} " to "")
Line 1: Line 1:
{{Command|Comments=
{{Command|Comments=
____________________________________________________________________________________________


| arma3 |Game name=
| arma3 |Game name=
Line 7: Line 6:


|gr1= Variables |GROUP1=
|gr1= Variables |GROUP1=
____________________________________________________________________________________________


| Selects an element from an [[Array | array]], same as [[select]] command for arrays, but has [[SQF_syntax#Rules_of_Precedence | higher precedence]] |Description=
| Selects an element from an [[Array | array]], same as [[select]] command for arrays, but has [[SQF_syntax#Rules_of_Precedence | higher precedence]] |Description=
____________________________________________________________________________________________


| array  [[a_hash_b|#]] index |Syntax=
| array  [[a_hash_b|#]] index |Syntax=
Line 19: Line 16:


| [[Anything]] |Return value=
| [[Anything]] |Return value=
____________________________________________________________________________________________
   
   
   
   
Line 25: Line 21:


|x2= <code>[[position]] [[player]] [[a_hash_b|#]] 2; {{codecomment|// result is Z coordinate of player's position}}</code> |Example 2=
|x2= <code>[[position]] [[player]] [[a_hash_b|#]] 2; {{codecomment|// result is Z coordinate of player's position}}</code> |Example 2=
____________________________________________________________________________________________


| [[select]], [[selectRandom]], [[selectRandomWeighted]], [[set]], [[resize]], [[reverse]], [[in]], [[find]], [[toArray]], [[toString]], [[forEach]], [[count]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[param]], [[params]], [[splitString]], [[joinString]], [[pushBack]], [[pushBackUnique]], [[apply]] |See also=
| [[select]], [[selectRandom]], [[selectRandomWeighted]], [[set]], [[resize]], [[reverse]], [[in]], [[find]], [[toArray]], [[toString]], [[forEach]], [[count]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[param]], [[params]], [[splitString]], [[joinString]], [[pushBack]], [[pushBackUnique]], [[apply]] |See also=

Revision as of 00:01, 17 January 2021

Hover & click on the images for description

Description

Description:
Selects an element from an array, same as select command for arrays, but has higher precedence
Groups:
Variables

Syntax

Syntax:
array # index
Parameters:
array: Array
index: Number
Return Value:
Anything

Examples

Example 1:
[1,2,3,4] # 2; // result is 3
Example 2:
position player # 2; // result is Z coordinate of player's position

Additional Information

See also:
selectselectRandomselectRandomWeightedsetresizereverseinfindtoArraytoStringforEachcountdeleteAtdeleteRangeappendsortparamparamssplitStringjoinStringpushBackpushBackUniqueapply

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

Bottom Section

Posted on April 25, 2018 - 00:51 (UTC)
KC Grimes
Although not alternative syntax, the below notations work as expected: ["A","B","C"] # 1; //B ["A","B","C"] #1; //B ["A","B","C"]#1; //B ["A","B",["C","D"]]#2#0; //C
Posted on May 3, 2019 - 15:41 (UTC)
7erra
Here is an example of what higher precedence means: [1,2,3,4] select 2/2; // divides 2 with 2, therefore selects second element = 2 [1,2,3,4] select (2/2); // same result with brackets [1,2,3,4] # 2/2; // selects third element, then divides by 2 = 1.5 ([1,2,3,4] # 2)/2; // same result with brackets
This operator can not be used in conjunction with the #define preprocessor.
#define SEL_ERR [0,1,2]#0 //error #define SEL_NOERR [0,1,2] select 0 //works