Skip to main content

Create-Multi-Dim-Array

Command Description

Create any level of dimensional array according to a specified dimension number

Command Prototype

arrayRet = Array(arrSize,defaultValue)

Parameter Description

ParameterRequiredTypeDefaultDescription
arrSizeTrueexpression[5,5]If this property is an integer N, a new one-dimensional array containing N elements will be created; if this property is an array [M, N], a new two-dimensional array containing MN elements will be created; if this property is an array [M, N, Q], a three-dimensional array containing MN*Q elements will be created; in turn, when this property is an array, and the number of elements in the array is X, the output is an X-dimensional array, of which the number of each dimension is represented by an integer of the corresponding position in the property
defaultValueTrueexpressionnullAll elements in the created multidimensional array are filled with this value which defaults to null

return

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

Demo

TracePrint("----------------------Create multidimensional array---------------------- --") 
//-------------------------------------------------------------------------------
//[Remarks] Create a one-dimensional, two-dimensional, three-dimensional or higher-dimensional array according to the specified number of dimensions.
//Input parameter 1:
// arrSize--If the attribute is an integer N, create a new one-dimensional array containing N elements; if the attribute is an array [M, N], create a new one containing MN elements If the attribute is an array [M, N, Q], create a new three-dimensional array containing MN*Q elements; in short, when the attribute is an array, and the number of elements in the array is X , the output is an X-dimensional array, where the number of each dimension is represented by the integer at the corresponding position in the attribute.
//Input parameter 2:
// defaultValue--The elements in the created high-dimensional array are all filled with this value, and the default is null.
//out parameters:
// arrayRet--The variable to which the output of the function call is saved.
//
//Command prototype: arrayRet=Array(arrSize,defaultValue)
//-------------------------------------------------------------------------------
arrayRet=Array([2,2],0)
TracePrint(arrayRet)