Multi-Dimensional Arrays - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

DEFINE_VARIABLE
CHAR StringTable_3[3][5]
DEFINE_START
CHAR StringTable_3[1] = 'Str 1'
CHAR StringTable_3[2] = 'Str 2'
CHAR StringTable_3[3] = 'Str 3'
For multidimensional array types, the data pertaining to each dimension is delimited using braces, as
shown below:
INTEGER Num2D[ ][ ] = {{1, 3}, {2, 4}, {7, 8}}
(* This sets the dimensions to Num2D[3][2] *)
Arrays can be manipulated using the operator "
another. In the example below, the contents of
Array1 = Array2
The arrays must match in number of dimensions and type. The size of each dimension of the destination
array must be greater than or equal to the corresponding dimension of the array being assigned;
otherwise, the contents of the array being assigned are truncated to fit into the destination array. If a type
mismatch is detected, the compiler will issue an appropriate warning.
The length of an array is determined by calling
LENGTH_ARRAY
array initialization or array manipulation operations (+ and -) or explicitly through a call to
SET_LENGTH_ARRAY
of an array. For example:
INTEGER Len
INTEGER Array[1] = {3, 4, 5, 6, 7}
INTEGER Array2[10] = {1, 2}
Len = MAX_LENGTH_ARRAY(Array1)
Len = MAX_LENGTH_ARRAY(Array2)
LENGTH_ARRAY
automatically when the arrays are initialized.
Len = LENGTH_ARRAY(Array1)
Len = LENGTH_ARRAY(Array2)

Multi-dimensional arrays

Any of the single dimension array types listed above can be used to define an array of n-dimensions. A
2-dimensional array is simply a collection of 1-dimensional arrays; a 3-dimensional array is a collection
of 2-dimensional arrays, and so forth. Here's an example:
INTEGER Num1D[10]
INTEGER Num2D[5][10]
INTEGER Num3D[2][5][10]
One way to view these arrays is to think of
being a collection of two
When referencing elements of the above arrays:
NetLinx Programming Language Reference Guide
returns the effective length of a dimension of an array; the length set implicitly through
.
MAX_LENGTH_ARRAY
is called to determine the effective length of
Num2D
.
Num2D's
". The "
" operator is used to assign one array to
=
=
are replaced by the contents of
Array1
and
LENGTH_ARRAY
MAX_LENGTH_ARRAY
is used to determine the maximum length of a dimension
// Len = 5
// Len = 10
and
Array1
// Len = 5
// Len = 2
// [Column]
// [Row][Column]
// [Table][Row][Column]
as being a collection of five
Language Elements
.
Array2
.
. This value is set
Array2
and
as
Num1D's
Num3D
53

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents