Page tree
Skip to end of metadata
Go to start of metadata




Introduced in

Version:1.20

Description

Description:Inserts the elements of one array into another, at a specified index. Neither arrays are touched by reference, a new array is returned.

Syntax

Syntax:[baseArray, insertArray, index] call fn_vbs_arrayInsert
Parameters:
  • baseArray: Array - Array to insert into.
  • insertArray: Array - Array to insert into baseArray.
  • index: Number - Index at which to insert insertArray.
Return Value:Array

Warning

When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.

Examples

Examples:
_array = [[0,1,2,3,4], ["a","b","c"], 1] call fn_vbs_arrayInsert
Returns: [0,"a","b","c",1,2,3,4]

Additional Information

See also: fn vbs arrayInsertOrdered, fn vbs arrayAdd, fn vbs setEach
Multiplayer: 
Problems: 

Notes







This command has a bug in versions before 1.22: the insertArray parameter will be modified by reference. So if you use a variable here, the variable will be changed after running the function. To prevent this, pass a copy of the array, using the + operator. Ex: [_baseArray, +_insertArray, _index] call fn_vbs_arrayInsert