|
Hi Tom, Welcome to the wonderful world of pointers. Define your MODS as based on a pointer, with OCCURS set to a high number. No storage is actually used for this definition. Once you know how many occurrences you need, set the basing pointer to ALLOCate memory for NbrLabels * size of one MODS occurrence. d ptrLabels s * d Labels s 5 0 dim(9999) based(ptrLabels) d SizeLabels s 10 0 d ptrTot1 s * d Tot1DS ds occurs(9999) based(ptrTot1) d amt1 7 2 dim(7) d SizeTot1DS s 10 0 d ptrTot2 s * d Tot2DS ds occurs(9999) based(ptrTot2) d amt2 8 2 dim(7) d SizeTot2DS s 10 0 c* Read thru labels file, counting all of the useable label records c* Store that count in NumLabels to give us the number of Occurs for each DS c eval SizeLabels = %size(Labels) * NumLabels c alloc SizeLabels ptrLabels c eval SizeTot1DS = %size(Tot1DS) * NumLabels c alloc SizeTot1DS ptrTot1 c eval SizeTot2DS = %size(Tot2DS) * NumLabels c alloc SizeTot2DS ptrTot2 * At this point you can refer to Labels, Tot1DS, or Tot2DS as you normally would, e.g. c eval Labels(5) = 10 or c 7 occur Tot1DS c eval amt1 = amt1 + 73.5 I haven't done this in awhile, but I'm sure someone will correct me if I got anything wrong ;) hth, Peter Dow Dow Software Services, Inc. 909 425-0194 voice 909 425-0196 fax ----- Original Message ----- From: tomh@simas.com To: rpg400-l@midrange.com Sent: Thursday, April 12, 2001 3:38 PM Subject: Variable length MODS I need to build several MODS (multiple-occurence data structures), but I don't know the number of occurences that I'll need for them until I read some data from a file. Of course, I could just set the OCCURS on the D-spec to a high number, but would rather just create enough occurences to handle the data. Something like this: d Labels s dim(NumLabels) inz d Tot1DS ds occurs(NumLabels) inz d amt1 7 2 dim(7) d Tot2DS ds occurs(NumLabels) inz d amt2 8 2 dim(7) c* Read thru labels file, counting all of the useable label records c* Store that count in NumLabels to give us the number of Occurs for each DS Tom +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.