| Language basics / Arrays | |
An array defines a vector variable with a list of elements.
DEFINE variable ARRAY [ size [,size [,size] ] ]
[ ATTRIBUTES( attribute [ = "value" ] [,...] ) ]
OF datatype
DEFINE variable DYNAMIC ARRAY
[ ATTRIBUTES( attribute [ = "value" ] [,...] ) ]
[ WITH DIMENSION rank ]
OF datatype
DEFINE variable ARRAY [ ] OF javatype
The DEFINE ... ARRAY instruction creates a program variable as an array. The elements of the array can be of a simple type or structured records.
Consider using dynamic arrays instead of static arrays.
Java-style arrays will only be useful to interface with Java calls.
Static and dynamic arrays can be defined with the ATTRIBUTES() clause, to specify meta-data information for the variable. This feature is especially used when defining variables for XML-based Web Services. For more details about XML attributes, see Attributes to customize XML serialization.
DEFINE arr DYNAMIC ARRAY OF RECORD
p_num INTEGER,
p_name VARCHAR(50),
p_phone VARCHAR(20)
END RECORD
LET arr[1].p_num = 84335
LET arr[1].p_name = "Scott McCallum"
LET arr[1].p_phone = NULL
DISPLAU arr[1].*