insert: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Never gonna give you up)
 
m (Some wiki formatting)
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command
{{RV|type=command


|game1= arma3dev
|game1= arma3
|version1= 2.02


|version1= 2.01
|gr1= HashMap


|gr1= HashMap
|gr2= Arrays
|gr2= Arrays


|descr= Inserts multiple values into [[Array]]/[[String]]/[[HashMap]]
|gr3= Strings
 
|descr= Inserts multiple values into [[Array]]/[[String]]/[[HashMap]].<br>
The [[String]] variant also supports [[forceUnicode]].


|s1= array [[insert]] [index, [value1, value2, ...], onlyIfUnique]  
|s1= array [[insert]] [index, [value1, value2, ...], onlyIfUnique]  


|p1= array : [[Array]]
|p1= array : [[Array]]
|p2= index: [[Number]] - index at which the values will be inserted, -1 for append.
|p2= index: [[Number]] - index at which the values will be inserted, -1 for append.
|p3= [value1, value2, ...]: [[Array]] of [[Anything]] - Values to insert at the specified index
 
|p4= onlyIfUnique: [[Bool]] - Only insert if the value is unique in the array, like [[pushBackUnique]]
|p3= [value1, value2, ...]: [[Array]] of [[Anything]] - values to insert at the specified index
 
|p4= onlyIfUnique: [[Boolean]] - only insert if the value is unique in the array, like [[pushBackUnique]]


|r1= [[Nothing]]
|r1= [[Nothing]]


|s2= string [[insert]] [index, substring]
|s2= string [[insert]] [index, substring]


|p21= string : [[String]]
|p21= string : [[String]]
|p22= index: [[Number]] - index at which the values will be inserted, -1 for append.
|p22= index: [[Number]] - index at which the values will be inserted, -1 for append.
|p23= substring: [[String]] - String to insert


|r2= [[String]] - The new string
|p23= substring: [[String]] - string to insert
 
|r2= [[String]] - the new string


|s3= hashMap [[insert]] [<nowiki/>[key1, value1], [key2, value2], ...]


|s3= hashMap [[insert]] <nowiki>[[</nowiki>key1, value1], [key2, value2], ...]
|s3since= arma3 2.04


|p41= hashMap: [[HashMap]]
|p41= hashMap: [[HashMap]]
|p42= key: [[HashMapKey]]
|p42= key: [[HashMapKey]]
|p43= value: [[Anything]]
|p43= value: [[Anything]]


|r3= [[Nothing]]
|r3= [[Nothing]]


|x1= <code></code>
|s4= hashMap [[insert]]  [splitArray, [keysAndValues]]
 
|s4since= arma3 2.04
 
|p61= hashMap: [[HashMap]]
 
|p62= splitArray: [[Boolean]] - determines ''keysAndValues'' format (see ''keysAndValues''<nowiki/>'s description)
 
|p63= keysAndValues: [[Array]] - in format depending on ''splitArray''<nowiki/>'s value:
* [[true]] - {{ic|[<nowiki/>[key1, key2, ...], [value1, value2, ...]]}}
* [[false]] - {{ic|[<nowiki/>[key1, value1], [key2, value2], ...]}} (same as {{HashLink|#Syntax 3}})
 
|r4= [[Nothing]]


|x2= <code></code>
|x1= <sqf>"Test" insert [0, "Radio"]; // returns "RadioTest"</sqf>


|seealso= [[HashMap]]
|seealso= [[HashMap]]
}}
}}

Revision as of 14:56, 5 May 2022

Hover & click on the images for description

Description

Description:
Inserts multiple values into Array/String/HashMap.
The String variant also supports forceUnicode.
Groups:
HashMapArraysStrings

Syntax 1

Syntax:
array insert [index, [value1, value2, ...], onlyIfUnique]
Parameters:
array : Array
index: Number - index at which the values will be inserted, -1 for append.
[value1, value2, ...]: Array of Anything - values to insert at the specified index
onlyIfUnique: Boolean - only insert if the value is unique in the array, like pushBackUnique
Return Value:
Nothing

Syntax 2

Syntax:
string insert [index, substring]
Parameters:
string : String
index: Number - index at which the values will be inserted, -1 for append.
substring: String - string to insert
Return Value:
String - the new string

Syntax 3

Syntax:
hashMap insert [[key1, value1], [key2, value2], ...]
Parameters:
hashMap: HashMap
key: HashMapKey
value: Anything
Return Value:
Nothing

Syntax 4

Syntax:
hashMap insert [splitArray, [keysAndValues]]
Parameters:
hashMap: HashMap
splitArray: Boolean - determines keysAndValues format (see keysAndValues's description)
keysAndValues: Array - in format depending on splitArray's value:
  • true - [[key1, key2, ...], [value1, value2, ...]]
  • false - [[key1, value1], [key2, value2], ...] (same as Syntax 3)
Return Value:
Nothing

Examples

Example 1:
"Test" insert [0, "Radio"]; // returns "RadioTest"

Additional Information

See also:
HashMap

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