You can declare a static array of records or data items by specifying a size value in brackets, as in the following examples:
myDataItem01 CHAR(30)[5]; // an array of 5 items myDataItem02 myDataItemPart[6]; // an array of 6 items myRecord myRecordPart[7]; // an array of 7 records
The size value must be an integer literal.
A static array may be used locally within a given function, may be a program-global variable, and may even be declared in a library and used by many programs, libraries, and/or page handlers. The array cannot be passed as an argument to another function (although individual elements can be passed). Also, the array cannot act as a parameter.
The number of dimensions in a static array of records is the highest number of array dimensions in the record structure, plus one dimension for the record array itself. Assume, for example, that your code can access the following part at development time:
record myRecordPart siTop[3]; siNext CHAR(10)[2]; end
The following statement declares an array of three dimensions:
myRecord myRecordPart[5];
In the previous example, these references are valid:
myRecord.siTop.siNext[1,1,2] siNext[1,1,2]
The in-memory arrangement of elements of the static array are as described for structure-item arrays.
The system variable sysLib.size(arrayName) contains the number of elements in the first dimension of a static array of records or data items. (Substitute the array name for arrayName and note that the name may be qualified by a package name, a library name, or both.)
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.