set: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (template:command argument fix)
(26 intermediate revisions by 10 users not shown)
Line 1: Line 1:
back to [[Scripting_Reference#S|COMREF]]
{{Command|= Comments
____________________________________________________________________________________________


<h2 style="color:#000066">'''''array'' set ''element'''''</h2>
| ofpr |= Game name


|1.75|= Game version
____________________________________________________________________________________________


'''Operand types:'''
| 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=
____________________________________________________________________________________________


'''array:''' [[Array]]
| array '''set''' [index, value] |SYNTAX=


'''element:''' [[Array]]
|p1= array: [[Array]] |PARAMETER1=
|p2= [index, value]: [[Array]] |PARAMETER2=
|p3= index: [[Number]] |PARAMETER3=
|p4= value: [[Anything]] |PARAMETER4=


'''Type of returned value:'''
| [[Nothing]] |RETURNVALUE=
____________________________________________________________________________________________
 
|x1= <code>_arrayOne [[set]] [0, "Hello"];</code> |EXAMPLE1=


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


'''Compatibility:'''


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


'''Description:'''
| [[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=


Format of element is '''''[index, value]'''''.
}}


Changes an '''element''' of given '''array'''.
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->


If '''element''' does not exist, [[resize]] index+1 is called to create it.
<!-- Note Section END -->
</dl>


 
<h3 style="display:none">Bottom Section</h3>
'''Example:'''
[[Category:Scripting Commands|SET]]
 
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
arrayOne '''set''' [0, "Hello"]
[[Category:Scripting Commands OFP 1.96|SET]]
[[Category:Scripting Commands ArmA|SET]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]

Revision as of 15: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