|
|||||||
|
|
![]() |
|
|
|
|
||
|
Two-Dimensional Compile-Time Arrays in RPG Hey, Ted: How do you define a two-dimensional compile-time array in V5R2 RPG? --Joe Good question. I've only had to do that one time, and this is the method I used
D AdjTbl s 48a
dim(3) ctdata perrcd(1)
D AdjTblPtr s *
inz(%addr(AdjTbl))
D AdjRow ds
dim(3) qualified
D
based(AdjTblPtr)
D AdjCol 12a dim(4)
D Adjective s 12a
D Row s 10u 0
D Col s 10u 0
/free
Adjective = AdjRow(Row).AdjCol(Col);
/end-free
**
acrimonious bucolic crapulous dyadic
equivocal fecund gelatinous heliocentric
irascible jingoistic kinesthetic laic
I defined a compile-time array with the rows of data as I needed them. Then I used a pointer to overlay the compile-time array with a multi-dimensioned data structure that contained an array subfield. Notice that the AdjRow data structure is qualified. A data structure has to be qualified if it's given a dimension. To extract an element of the two-dimensional array, reference both the outer dimension (the data structure) and the inner dimension (the subfield) with subscripts. In this example, if Row has the value 3 and Col has the value 1, Adjective takes the value irascible. I'm guessing COBOL programmers won't bother to write me about this tip. COBOL has had 2D and 3D arrays for something like 40 years. --Ted
|
Editors
Contact the Editors |
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |