Using Arrays and Tables

Arrays and tables are both collections of data fields (elements) of the same:
  • Field length
  • Data type
    • Character
    • Numeric
    • Data Structure
    • Date
    • Time
    • Timestamp
    • Graphic
    • Basing Pointer
    • Procedure Pointer
    • UCS-2
  • Format
  • Number of decimal positions (if numeric)
Arrays and tables differ in that:
  • You can refer to a specific array element by its position
  • You cannot refer to specific table elements by their position
  • An array name by itself refers to all elements in the array
  • A table name always refers to the element found in the last LOOKUP (Look Up a Table or Array Element) operation
Note: You can define only run-time arrays in a subprocedure. Tables, prerun-time arrays, and compile-time arrays are not supported. If you want to use a pre-run array or compile-time array in a subprocedure, you must define it in the main source section.

The next section describes how to code an array, how to specify the initial values of the array elements, how to change the values of an array, and the special considerations for using an array. The section after next describes the same information for tables.