set: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (template:command argument fix)
Line 8: Line 8:


| Changes the element at the given (zero-based) index of the [[Array|array]].
| Changes the element at the given (zero-based) index of the [[Array|array]].
<br>If the element does not exist, [[resize]] index+1 is called to create it. |= Description
<br>If the element does not exist, [[resize]] index+1 is called to create it. |DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________


| array '''set''' [index, value] |= Syntax
| array '''set''' [index, value] |SYNTAX=


|p1= array: [[Array]] |= Parameter 1
|p1= array: [[Array]] |PARAMETER1=
|p2= [index, value]: [[Array]] |= Parameter 2
|p2= [index, value]: [[Array]] |PARAMETER2=
|p3= index: [[Number]] |= Parameter 3
|p3= index: [[Number]] |PARAMETER3=
|p4= value: [[Anything]] |= Parameter 4
|p4= value: [[Anything]] |PARAMETER4=


| [[Nothing]] |= Return value
| [[Nothing]] |RETURNVALUE=
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <code>_arrayOne [[set]] [0, "Hello"];</code> |= Example 1
|x1= <code>_arrayOne [[set]] [0, "Hello"];</code> |EXAMPLE1=


|x2= <code>_arrayTwo [[set]] <nowiki>[</nowiki>[[count]] _arrayTwo, "Bye"];</code>
|x2= <code>_arrayTwo [[set]] <nowiki>[</nowiki>[[count]] _arrayTwo, "Bye"];</code>
appends "Bye" as last element to <tt>_arrayTwo</tt> |= Example 2
appends "Bye" as last element to <tt>_arrayTwo</tt> |EXAMPLE2=




|x3= <code>_arrayThree [[set]] <nowiki>[</nowiki>([[count]] _arrayThree) - 1, 23];</code>
|x3= <code>_arrayThree [[set]] <nowiki>[</nowiki>([[count]] _arrayThree) - 1, 23];</code>
replaces the last element of <tt>_arrayTwo</tt> with 23 |= Example 3
replaces the last element of <tt>_arrayTwo</tt> with 23 |EXAMPLE3=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[Array]], [[plus a]], [[valuea plus valueb]], [[a - b]], [[resize]], [[reverse]], [[select]], [[in]], [[find]], [[findIf]], [[toArray]], [[toString]], [[forEach]], [[count]], [[pushBack]], [[pushBackUnique]], [[apply]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[param]], [[params]], [[arrayIntersect]], [[splitString]], [[joinString]]|= See also
| [[Array]], [[plus a]], [[valuea plus valueb]], [[a - b]], [[resize]], [[reverse]], [[select]], [[in]], [[find]], [[findIf]], [[toArray]], [[toString]], [[forEach]], [[count]], [[pushBack]], [[pushBackUnique]], [[apply]], [[deleteAt]], [[deleteRange]], [[append]], [[sort]], [[param]], [[params]], [[arrayIntersect]], [[splitString]], [[joinString]]|SEEALSO=


}}
}}

Revision as of 14:46, 7 April 2019

Hover & click on the images for description

Description

Description:
Changes the element at the given (zero-based) index of the array.
If the element does not exist, resize index+1 is called to create it.
Groups:
Uncategorised

Syntax

Syntax:
array set [index, value]
Parameters:
array: Array
[index, value]: Array
index: Number
value: Anything
Return Value:
Nothing

Examples

Example 1:
_arrayOne set [0, "Hello"];
Example 2:
_arrayTwo set [count _arrayTwo, "Bye"]; appends "Bye" as last element to _arrayTwo
Example 3:
_arrayThree set [(count _arrayThree) - 1, 23]; replaces the last element of _arrayTwo with 23

Additional Information

See also:
Arrayplus avaluea plus valueba - bresizereverseselectinfindfindIftoArraytoStringforEachcountpushBackpushBackUniqueapplydeleteAtdeleteRangeappendsortparamparamsarrayIntersectsplitStringjoinString

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