|
Buck, I'm going to assume that each field is always the same size, no matter where it sits in your flat file. (This may have already been stipulated, and I just missed it) If that is truly the case, then don't put your fields in a data structure at all. Make each of them based. Set up a structure of pointers that each field is based on. Set up an array with groups of pointers, with the addresses of each layout already set up. For each record type, move in the correct set of pointers, and you're ready to go. i.e. d fieldA s 5 Based(ptrA) d fieldB s 6 10 Based(ptrB) d fieldC s 11 15 Based(ptrC) d ds d ptrs d ptrA * Overlay(ptrs:1) d ptrB * Overlay(ptrs:*next) d ptrC * Overlay(ptrs:*next) d ds d ptrary 1 48 Dim(as many as you need) d ptr1 * Overlay(ptrary:1) d ptr2 * Overlay(ptrary:*next) d ptr3 * overlay(ptrary:*next) You might have to play with this to get everything to line up on the correct boundries. Actually, to get the addresses, it'd probably be more readable to go ahead and put the fields in structures, but change the names. i.e. d struc001 ds based(ptr001) d fieldA1 1 5 d fieldB1 6 10 d fieldC1 11 15 d struc002 ds based(ptr002) d fieldB2 1 5 d fieldC2 6 10 d fieldA2 20 24 Now it makes it easy to load the addresses, and once that's done the rest is simple. /Free BegSR *InzSR; ptr1(1) = %addr(fieldA1); ptr2(1) = %addr(fieldB1); ptr3(1) = %addr(fieldC1); ptr1(2) = %addr(fieldA2); ptr2(2) = %addr(fieldB2); ptr3(2) = %addr(fieldC2); EndSR; Once you read in your record, check to determine what type of record it is and load your array of basing pointers. BegSR SelectRecordType; Select; When RecType = 'A'; ptrs = ptrara(1); When RecType = 'B'; ptrs = ptrara(2); EndSl; Now everything is loaded, and you can process away. Duane ( disclaimer - none of this has been tested as it sits, although I have done similar things and know that it works.) > -----Original Message----- > From: Buck Calabro [SMTP:Buck.Calabro@xxxxxxxxxxxx] > Sent: Monday, May 05, 2003 10:48 AM > To: RPG programming on the AS400 / iSeries > Subject: RE: Flat file, same field, different positions > > >Could you possible base these structures using pointers? > > Sure, but the individual names still collide. > d struc001 ds based(ptr001) > d fieldA 1 5 > d fieldB 6 10 > d fieldC 11 15 > > d struc002 ds based(ptr002) > d fieldB 1 5 > d fieldC 6 10 > d fieldA 20 24 > > I'd like to be able to use FIELDA in all my structures because FIELDA > represents the same thing in each structure. > --buck > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo.cgi/rpg400-l > or email: RPG400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l.
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.