|
I want to convert filea with a format like (horizontal): flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224
to fileb that looks like (vertical): fldb1 fldb2 fldb11 fldb21 fldb1 fldb2 fldb11 fldb21 . . . fldb1 fldb2 fldb11 fldb21 (times 24)
darra1 s 3 0 dim(24) based(ptr1) darra2 s 8 0 dim(24) based(ptr2) dptr1 s * inz(*null) dptr2 s * inz(*null)
c dou %eof(filea) c clear ptr1 c clear ptr2 c read(e) filea c if %eof(filea) c leave c endif c clear c_rec * set pointer1 and pointer2 c eval ptr1 = %addr(flda101) c eval ptr2 = %addr(flda201) * at this point arra1 and arra2 should have all the data loaded. c z-add 0 i 2 0 * requirements and their dates c 1 do 24 i c if ptr1 <> *null c eval fldb1 = arra1(i) c endif c if ptr2 <> *null c eval fldb2 = arra2(i) c endif c write c_rec c enddo
From: rpg400-l-request@xxxxxxxxxxxx Reply-To: rpg400-l@xxxxxxxxxxxx To: rpg400-l@xxxxxxxxxxxx Subject: RPG400-L Digest, Vol 3, Issue 58 Date: Tue, 27 Jan 2004 16:04:03 -0600
Send RPG400-L mailing list submissions to rpg400-l@xxxxxxxxxxxx
To subscribe or unsubscribe via the World Wide Web, visit http://lists.midrange.com/mailman/listinfo/rpg400-l or, via email, send a message with subject or body 'help' to rpg400-l-request@xxxxxxxxxxxx
You can reach the person managing the list at rpg400-l-owner@xxxxxxxxxxxx
When replying, please edit your Subject line so it is more specific than "Re: Contents of RPG400-L digest..."
Today's Topics:
1. RE: Peer Code Review (was RE: GOTO - I still love you!!!) (QSRVBAS) 2. pointer based arrays (Dan Belu) 3. Re: pointer based arrays (MWalter@xxxxxxxxxxxxxxx) 4. Re: pointer based arrays (Wilbert van der Hoeven) 5. Re: pointer based arrays (Carel Teijgeler) 6. Re: pointer based arrays (Booth Martin) 7. Conditional compilation directives (rob@xxxxxxxxx) 8. Re: pointer based arrays (rick.baird@xxxxxxxxxxxxxxx)
----------------------------------------------------------------------
message: 1 date: Tue, 27 Jan 2004 11:22:37 -0800 from: QSRVBAS <qsrvbas@xxxxxxxxxxxx> subject: RE: Peer Code Review (was RE: GOTO - I still love you!!!)
rpg400-l-request@xxxxxxxxxxxx wrote:
> 3. Re: Peer Code Review (was RE: GOTO - I still love you!!!)
> (James Rich)
>
>Another use is to put a new topic there (by editing the Sandbox page) that
>has code that has been discussed here. For example, the code that
>recently came up about the socket problem. The code was posted, and a
>couple of people posted fixes. That code could become a new topic and
>then helpful posters could change the code to answer questions. Maybe
>even a body of code would be built up this way that answers common
>questions or illustrates common techniques.
I think this should be emphasized. Rather than posting problem or sample
code directly in the list, post it in Twiki. I've let numerous threads
slide because posting an example would be too lengthy. There's no such
concern with Twiki. The list posting becomes a link back to a Twiki subject.
Further, any posted example gets reviewed and glitches potentially removed. Every participant benefits.
Tom Liotta
-- Tom Liotta The PowerTech Group, Inc. 19426 68th Avenue South Kent, WA 98032 Phone 253-872-7788 x313 Fax 253-872-7904 http://www.powertech.com
------------------------------
message: 2 date: Tue, 27 Jan 2004 15:15:59 -0500 from: "Dan Belu" <danbelu@xxxxxxxxxxx> subject: pointer based arrays
Here is the situation:
I want to convert filea with a format like: flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224
to fileb that looks like: fldb1 fldb2 fldb11 fldb21 fldb1 fldb2 fldb11 fldb21 . . . fldb1 fldb2 fldb11 fldb21 (times 24)
The fields flda101, flda102, ..., flda124 have the same size and map all to fldb11 and flda201, flda202, ..., flda224 are alike and map to fldb21
I tried to use pointer based arrays to load the data in an elegant way. But is not working although is suppose to. The problem is that RPG does not load the data into the fields that aren't directly used in the program.
This is the code I use:
* * C_Template convert filea - horizontal to fileb - vertical * *---------------------------------------------------------------- ffilea if e k disk ffileb uf a e k disk
darra1 s 3 0 dim(24) based(ptr1) darra2 s 8 0 dim(24) based(ptr2) dptr1 s * inz(*null) dptr2 s * inz(*null)
c dou %eof(filea) c clear ptr1 c clear ptr2 c read(e) filea c if %eof(filea) c leave c endif c clear c_rec * set pointer1 and pointer2 c eval ptr1 = %addr(flda101) c eval ptr2 = %addr(flda201) * at this point arra1 and arra2 should have all the data loaded. c z-add 0 i 2 0 * requirements and their dates c 1 do 24 i c if ptr1 <> *null c eval fldb1 = arra1(i) c endif c if ptr2 <> *null c eval fldb2 = arra2(i) c endif c write c_rec c enddo
c enddo
c seton lr
The fileds flda102, flda103 and so on and the corresponding array elements will have zero values even if the input file has data in these fileds. The same with flda202, flda203 ... The only ones that get the data are flda101 and flda201 because I specifically use it in the code.
Any help would be greatly appreciated.
Dan
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
------------------------------
message: 3 date: Tue, 27 Jan 2004 15:54:34 -0500 from: MWalter@xxxxxxxxxxxxxxx subject: Re: pointer based arrays
I'm sure someone will correct me , but just because flda101, flda102, etc... are contiguous in the file doesn't mean that they are contiguous in memory. You may have to order the fields in a data structure defined as a array like this:
D DS Dunitsds 1 120 3 D dim(12) D @units1 1 10 3 INZ D @units2 11 20 3 INZ D @units3 21 30 3 INZ D @units4 31 40 3 INZ D @units5 41 50 3 INZ D @units6 51 60 3 INZ D @units7 61 70 3 INZ D @units8 71 80 3 INZ D @units9 81 90 3 INZ D @units10 91 100 3 INZ D @units11 101 110 3 INZ D @units12 111 120 3 INZ
@units1 - @units12 are fields in a file. I can access these fields using unitsds(index). Or I can take a corresponding data structure and move one to the other with one instruction.
Thanks,
Mark
Mark D. Walter Senior Programmer/Analyst CCX, Inc. mwalter@xxxxxxxxxx http://www.ccxinc.com
|---------+----------------------------->
| | "Dan Belu" |
| | <danbelu@xxxxxxxxx|
| | om> |
| | Sent by: |
| | rpg400-l-bounces@m|
| | idrange.com |
| | |
| | |
| | 01/27/2004 03:15 |
| | PM |
| | Please respond to |
| | RPG programming on|
| | the AS400 / |
| | iSeries |
| | |
|---------+----------------------------->
>------------------------------------------------------------------------------------------------------------------------------|
| |
| To: rpg400-l@xxxxxxxxxxxx |
| cc: |
| Subject: pointer based arrays |
>------------------------------------------------------------------------------------------------------------------------------|
Here is the situation:
I want to convert filea with a format like: flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224
to fileb that looks like: fldb1 fldb2 fldb11 fldb21 fldb1 fldb2 fldb11 fldb21 . . . fldb1 fldb2 fldb11 fldb21 (times 24)
The fields flda101, flda102, ..., flda124 have the same size and map all to
fldb11 and flda201, flda202, ..., flda224 are alike and map to fldb21
I tried to use pointer based arrays to load the data in an elegant way. But is not working although is suppose to. The problem is that RPG does not load the data into the fields that aren't directly used in the program.
This is the code I use:
* * C_Template convert filea - horizontal to fileb - vertical * *---------------------------------------------------------------- ffilea if e k disk ffileb uf a e k disk
darra1 s 3 0 dim(24) based(ptr1) darra2 s 8 0 dim(24) based(ptr2) dptr1 s * inz(*null) dptr2 s * inz(*null)
c dou %eof(filea) c clear ptr1 c clear ptr2 c read(e) filea c if %eof(filea) c leave c endif c clear c_rec * set pointer1 and pointer2 c eval ptr1 = %addr(flda101) c eval ptr2 = %addr(flda201) * at this point arra1 and arra2 should have all the data loaded. c z-add 0 i 2 0 * requirements and their dates c 1 do 24 i c if ptr1 <> *null c eval fldb1 = arra1(i) c endif c if ptr2 <> *null c eval fldb2 = arra2(i) c endif c write c_rec c enddo
c enddo
c seton lr
The fileds flda102, flda103 and so on and the corresponding array elements will have zero values even if the input file has data in these fileds. The same with flda202, flda203 ... The only ones that get the data are flda101 and flda201 because I specifically use it in the code.
Any help would be greatly appreciated.
Dan
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
_______________________________________________ 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/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.
------------------------------
message: 4 date: Tue, 27 Jan 2004 21:58:17 +0100 from: "Wilbert van der Hoeven" <hoeveb@xxxxxxxxxxxxxxxx> subject: Re: pointer based arrays
Dan,
You should add externally defined datastructures of the records that you
use.
Otherwise the program will put the fields in alphabetical order in his
memory (FLD1, FLD11, FLD2, FLD22 etc.), and not in the sequence that you use
in your file definition. When you add the externally defined datastructure
of the files, it uses that sequence instead of the alphabetical sequence,
and then you can use pointers to overlay multiple fields.
Regards, Wilbert
----- Original Message ----- From: "Dan Belu" <danbelu@xxxxxxxxxxx> To: <rpg400-l@xxxxxxxxxxxx> Sent: Tuesday, January 27, 2004 9:15 PM Subject: pointer based arrays
> Here is the situation:
>
> I want to convert filea with a format like:
> flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224
>
> to fileb that looks like:
> fldb1 fldb2 fldb11 fldb21
> fldb1 fldb2 fldb11 fldb21
> .
> .
> .
> fldb1 fldb2 fldb11 fldb21 (times 24)
>
> The fields flda101, flda102, ..., flda124 have the same size and map all
to
> fldb11 and
> flda201, flda202, ..., flda224 are alike and map to fldb21
>
> I tried to use pointer based arrays to load the data in an elegant way.
> But is not working although is suppose to.
> The problem is that RPG does not load the data into the fields that aren't
> directly used in the program.
>
> This is the code I use:
>
> *
> * C_Template convert filea - horizontal to fileb - vertical
> *
> *----------------------------------------------------------------
> ffilea if e k disk
> ffileb uf a e k disk
>
> darra1 s 3 0 dim(24) based(ptr1)
> darra2 s 8 0 dim(24) based(ptr2)
> dptr1 s * inz(*null)
> dptr2 s * inz(*null)
>
> c dou %eof(filea)
> c clear ptr1
> c clear ptr2
> c read(e) filea
> c if %eof(filea)
> c leave
> c endif
> c clear c_rec
> * set pointer1 and pointer2
> c eval ptr1 = %addr(flda101)
> c eval ptr2 = %addr(flda201)
> * at this point arra1 and arra2 should have all the data loaded.
> c z-add 0 i 2 0
> * requirements and their dates
> c 1 do 24 i
> c if ptr1 <> *null
> c eval fldb1 = arra1(i)
> c endif
> c if ptr2 <> *null
> c eval fldb2 = arra2(i)
> c endif
> c write c_rec
> c enddo
>
> c enddo
>
> c seton lr
>
> The fileds flda102, flda103 and so on and the corresponding array elements
> will have zero values even if the input file has data in these fileds.
> The same with flda202, flda203 ... The only ones that get the data are
> flda101 and flda201 because I specifically use it in the code.
>
> Any help would be greatly appreciated.
>
> Dan
>
> _________________________________________________________________
> The new MSN 8: smart spam protection and 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
>
> _______________________________________________
> 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/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.
>
>
------------------------------
message: 5 date: Tue, 27 Jan 2004 22:05:10 +0100 from: "Carel Teijgeler" <coteijgeler@xxxxxxxxx> subject: Re: pointer based arrays
Dan,
The old trick that dates from RPG III is to map the database fields to an array element in the old I-specs. Something like:
I C-REC I flda101 Arra1(1) etc.
Perhaps a lot of coding, but I think this wil work: read a record and the array is filled. It was a long time ago I did this, so I may be mistaken.
Regards, Carel Teijgeler
*********** REPLY SEPARATOR ***********
On 27-1-04 at 15:15 Dan Belu wrote:
>Here is the situation:
>
> I want to convert filea with a format like:
>flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224
>
> to fileb that looks like:
>fldb1 fldb2 fldb11 fldb21
>fldb1 fldb2 fldb11 fldb21
>.
>fldb1 fldb2 fldb11 fldb21 (times 24)
>
>The fields flda101, flda102, ..., flda124 have the same size and map all
>to fldb11 and flda201, flda202, ..., flda224 are alike and map to fldb21
>
>I tried to use pointer based arrays to load the data in an elegant way.
>But is not working although is suppose to.
>The problem is that RPG does not load the data into the fields that aren't
>directly used in the program.
------------------------------
message: 6 date: Tue, 27 Jan 2004 15:06:26 -0600 (Central Standard Time) from: "Booth Martin" <Booth@xxxxxxxxxxxx> subject: Re: pointer based arrays
Could you use two data structures with the EXTNAME(file) keyword and move one data structure to the other? Would that be easier?
--------------------------------------------------------- Booth Martin http://www.MartinVT.com Booth@xxxxxxxxxxxx ---------------------------------------------------------
-------Original Message-------
From: RPG programming on the AS400 / iSeries Date: 01/27/04 14:54:50 To: rpg400-l@xxxxxxxxxxxx Subject: pointer based arrays
Here is the situation:
I want to convert filea with a format like: flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224
to fileb that looks like: fldb1 fldb2 fldb11 fldb21 fldb1 fldb2 fldb11 fldb21 . . . fldb1 fldb2 fldb11 fldb21 (times 24)
The fields flda101, flda102, ..., flda124 have the same size and map all to fldb11 and flda201, flda202, ..., flda224 are alike and map to fldb21
I tried to use pointer based arrays to load the data in an elegant way. But is not working although is suppose to. The problem is that RPG does not load the data into the fields that aren't directly used in the program.
This is the code I use:
* * C_Template convert filea - horizontal to fileb - vertical * *---------------------------------------------------------------- ffilea if e k disk ffileb uf a e k disk
darra1 s 3 0 dim(24) based(ptr1) darra2 s 8 0 dim(24) based(ptr2) dptr1 s * inz(*null) dptr2 s * inz(*null)
c dou %eof(filea) c clear ptr1 c clear ptr2 c read(e) filea c if %eof(filea) c leave c endif c clear c_rec * set pointer1 and pointer2 c eval ptr1 = %addr(flda101) c eval ptr2 = %addr(flda201) * at this point arra1 and arra2 should have all the data loaded. c z-add 0 i 2 0 * requirements and their dates c 1 do 24 i c if ptr1 <> *null c eval fldb1 = arra1(i) c endif c if ptr2 <> *null c eval fldb2 = arra2(i) c endif c write c_rec c enddo
c enddo
c seton lr
The fileds flda102, flda103 and so on and the corresponding array elements will have zero values even if the input file has data in these fileds. The same with flda202, flda203 ... The only ones that get the data are flda101 and flda201 because I specifically use it in the code.
Any help would be greatly appreciated.
Dan
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
_______________________________________________ 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/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.
------------------------------
message: 7 date: Tue, 27 Jan 2004 16:36:26 -0500 from: rob@xxxxxxxxx subject: Conditional compilation directives
I want to store multiple parts of something in a /copy member. For instance some H specs, some D specs, etc. How do I ensure that when I /copy them the right parts get included in the right area of my program? I've done this before, but right now it's slipped out of my mind...
Rob Berendt -- Group Dekko Services, LLC Dept 01.073 PO Box 2000 Dock 108 6928N 400E Kendallville, IN 46755 http://www.dekko.com
------------------------------
message: 8 date: Tue, 27 Jan 2004 17:05:55 -0500 from: rick.baird@xxxxxxxxxxxxxxx subject: Re: pointer based arrays
Dan,
what release are you on? Didn't I hear something about an RPG equivelent to the 'MOVE CORRESPONDING' verb in COBOL using qualified data structures in V5R2? I just looked at the manual and found qualified data structures, but couldn't find anything about a move corresponding.
I'm not sure i have your layout exactly as you mean it to be, but you might be able to get something like this to work ( i may have this backwards):
d ds dim(24) d flda1 d flda2 d flda101 d flda102 *...etc...
d ds d yflda1 dim(24) like(flda1) d yflda2 dim(24) like(flda2) d yflda101 dim(24) like(flda101) d yflda102 dim(24) like(flda102) *...etc...
c movea flda1 yflda1 c movea flda2 yflda2 c movea flda101 yflda101 c movea flda102 yflda102
the effect of which is to move this format:
flda1(1) flda2(1) flda101(1) fld102(1) flda1(2) flda2(2) flda101(2) fld102(2) flda1(3) flda2(3) flda101(3) fld102(3) etc... flda1(24) flda2(24) flda101(24) fld102(24)
to this format:
flda1(1) flda1(2) flda1(3) flda1(4) flda1(5)... thru (24) flda2(1) flda2(2) flda2(3) flda2(4) flda2(5)... thru (24) flda101(1) flda101(2) flda101(3) flda101(4) flda101(5)... thru (24) flda102(1) flda102(2) flda102(3) flda102(4) flda102(5)... thru (24)
good luck,
Rick.
"I've been ordered to take you down to the bridge. Here I am, brain the size of a planet and they ask me to take you down to the bridge. Call that job satisfaction? 'Cos I don't." - Marvin the paranoid android
------original message--------- Here is the situation:
I want to convert filea with a format like: flda1 flda2 flda101 flda102 ... flda124 flda201 flda202 ... flda224
to fileb that looks like: fldb1 fldb2 fldb11 fldb21 fldb1 fldb2 fldb11 fldb21 . . . fldb1 fldb2 fldb11 fldb21 (times 24)
The fields flda101, flda102, ..., flda124 have the same size and map all to
fldb11 and flda201, flda202, ..., flda224 are alike and map to fldb21
I tried to use pointer based arrays to... <snip>
------------------------------
_______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) digest list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/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.
End of RPG400-L Digest, Vol 3, Issue 58 ***************************************
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.