I am charged with modifying a program that has 15 locns ('01', '02'.......'15'). The program already has an array to store the locns in. The array contain 15 elements of 2 characters each. Now I have to create an array of 100 tags for each locn. In theory, anyway, each element of the locn array will contain and it's own array of 100 elements containing a tag# for that locn. Sounds like a case for a multi dimensional array if RPGLE supported it. Outside of using a MODS with each occurrence containing an array of tags, what would be the best way to set this up
Announcement
Collapse
No announcement yet.
How to simulate multi dimension arrays
Collapse
X
-
This example is pretty easy.
Code:Dcl-DS Locations dim(15) qualified; locn char(2); tags char(10) dim(100); End-Ds;
locations.locn(1) is the first locn - location.locn(15) would be the last. locations.tags(1,50) would be the 50th tag in the first location. Locations.tags(15,100) would be the 100th tag of the 15th location.
-
Sounds like you haven't been keeping up-to-date on your RPG features. Multi-dimensional arrays have been available for OVER 16 YEARS! They came in with V5R2.
Sounds like you need something like this:
Code:dcl-ds locations dim(15) Qualified; location char(2); dcl-ds tags dim(100); tag char(10); // or however it is defined end-Ds; end-Ds;
Comment
-
I believe I have the nomenclature wrong...
locations(1).locn is the first locn - locations(15).locn would be the 15th. locations(1).tags(1) would be the first tag for the first locn - locations(1).tags(100) would be the 100th of the first locn, etc.
Comment
-
And as always - I tend to make it much more difficult than necessary first go around...
Code:dcl-ds locations dim(15) qualified; locn char(2); tag char(10) dim(100); End-Ds locations;
Comment
-
Code:dcl-ds locations dim(15) qualified; locn char(2); tag char(10) dim(100); End-Ds locations;
Comment
-
Originally posted by gregwga50 View PostCode:dcl-ds locations dim(15) qualified; locn char(2); tag char(10) dim(100); End-Ds locations;
Last edited by mjhaston; July 16, 2019, 09:09 AM.
Comment
-
-
Originally posted by mjhaston View PostI see your post like this. I find it completely odd that I can edit someone else's post. Do you see the code portion of your post with line breaks that it didn't have before?
Comment
Comment