Skip to main content
Version: v6.0.0

Insert-Element

Command Description​

Inserts an element at a specified position in an array

Command Prototype​

arrRet = insert(array,postion,item)

Parameter Description​

ParameterRequiredTypeDefaultDescription
arrayTrueexpression[]The array to insert an element into
postionTruenumber0Position to insert element
itemTrueexpression""The element to insert into the array

return​

arrRet,The variable used to save the output of the command.

Demo​

TracePrint("----------------------Insert element ----------------------- -") 
//-------------------------------------------------------------------------------
//[Remarks] Add an element to the specified position of the array.
//Input parameter 1:
// array--The array into which elements are to be inserted.
//Input parameter 2:
// postion--The position to insert the element.
//Input parameter 3:
// item--The element to insert into the array.
//out parameters:
// arrRet--The variable to which the output of the function call is saved.
//
//Command prototype: arrRet=insert(array,postion,item)
//-------------------------------------------------------------------------------
arrRet=insert([1,3,4],1,2)
TracePrint(arrRet)