TABLE AND ARRAY SPECIFICATION


Tables and arrays are declared with the definition specification. Specify the DIM keyword for a stand-alone field or data-structure subfield to declare the field as an array. If the table or array is loaded at compile time, the CTDATA keyword must be specified for the array declaration. In addition, the PERRCD keyword is used to indicate the number of array elements that are specified on each line of source code.

A compile-time table or array specification is identified by the **CTDATA keyword beginning in column 1 of the source line. The name of the compile-time table or array must appear beginning in position 10. Compile-time data must appear after all other source lines. The data to be loaded into the compile-time table or the array must begin on the line following the table or array specification. If multiple compile-time tables or arrays are used in a single program, each must begin with **CTDATA. For example, the program shown in Figure 2.22 contains two compile-time arrays.

click to expand
Figure 2.22: Code example with compile-time arrays.

When the program shown in Figure 2.22 is run, the output shown in Figure 2.23 is generated.

start figure

 *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... Index/value:  1  A01  Code Group Alpha Index/value:  2  B02  Code Group Beta Index/value:  3  C03  Code Group Gamma Index/value:  4  D04 Index/value:  5  E05 Index/value:  6  F06 

end figure

Figure 2.23: Sample output from program shown in Figure 2.22.




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net