Arrays: multi-dimensional

Key-based indexing can be used to simulate multi-dimensional arrays.

One example of a two-dimensional array is a table. Each item in the table has a row and a column. Shelf item keys can contain the row number and the column number separated by a separator character like period (.). Alternatively, if each row and column has a "name", then those names can be used in the keys instead of the row and column numbers. The following code is an example of a two-dimensional array, with the shelf item keys composed of the row number and column number for each item, separated by a period:

  global integer row
  global integer column
  global string  table variable
  
  element "table"
     clear table
     set row to 0
     suppress
  
  element "row"
     increment row
     set column to 0
     suppress
  
  element "column"
     increment column
     set table {"%d(row).%d(column)"} to "%c"

Using records

Another way to create multi-dimensional data structures it to use records. A record field is a shelf, and you can create a shelf of a record type, effectivly giving you shelves that can contain shelves. You can also use records to build other kinds of data structures such as trees.