Table of Contents

Search

  1. Preface
  2. Function reference
  3. Constants
  4. Operators
  5. Dates
  6. Functions
  7. System variables
  8. Datatype reference

Function Reference

Function Reference

Multidimensional array

Multidimensional array

A multidimensional array is an array of arrays. You can use a subscript operator to access a primitive element in an array at the innermost level. You can also use a subscript operator to access an array at any level.
You can use subscript operators to return the following values:
  • A primitive element in an array at the innermost level.
  • One or more arrays at any level.
  • A subset of one or more arrays at any level.
To access a primitive element in an array at the innermost level, you use more than one subscript operator. The number of dimensions in a multidimensional array determines the number of subscript operators to use. Each subscript operator must contain one index value. The data type of the return value is the same as the data type of the primitive elements in the array.
For example, in a two-dimensional array, you use two subscript operators. The first subscript operator accesses the parent array. The second subscript operator accesses the child array within the parent array.

Examples

Consider the following two-dimensional parent array that contains three child arrays and each child array contains string elements:
menu_array = [ ['milk','coffee','tea','chai'], ['ham','turkey',NULL], ['caesar','cobb','greek','chipotle'] ]
You can use subscript operators to access the following types of elements:
Primitive elements
The following expressions use two subscript operators to access a specific string element from each child array in the parent array
menu_array
:
Input Value
RETURN VALUE
menu_array[0][1]
'coffee'
menu_array[2][3]
'chipotle'
menu_array[1][2]
NULL
Array elements
The following expressions use a single subscript operator to access the child arrays in the parent array
menu_array
:
Input Value
RETURN VALUE
menu_array[0]
['milk','coffee','tea','chai']
menu_array[0,2]
[ ['milk','coffee','tea','chai'], ['ham','turkey',NULL] ]
menu_array[1,0]
[ ]
menu_array[NULL,2]
NULL
Subset of array elements
The following expressions use two subscript operators to access a subset of child arrays in the parent array
menu_array
:
Input Value
RETURN VALUE
menu_array[0][0,2]
['milk','coffee']
menu_array[2][0,3]
['caesar','cobb','greek']
menu_array[0,2][0,3]
[ ['milk','coffee','tea'], ['ham','turkey',NULL] ]

Back to Top

0 COMMENTS

We’d like to hear from you!