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.
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.
*... ... 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