Here's my take...

  dcl-ds rcdXRCL likerec(<your rcd format> : *all);

  dcl-s ptrXRLA pointer inz(%addr(rcdXRCL));

  dcl-ds dsXRLA  based(ptrXRLA);
    arXRLA char(8) dim(3);

   chain 039356 XRCL01 rcdXRCL;

Read the record into the DS. After the chain, arXRLA(<index>) is the array representation of your file "buckets".

Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power


From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxx> on behalf of JRusling@xxxxxxxxxxx <JRusling@xxxxxxxxxxx>
Sent: Tuesday, September 12, 2017 9:43 AM
Subject: Auto load an array when reading a record.
i'm pretty sure i have seen this done but,

I'd like to read a record, and automatically populate an array.  I know it
can be done with the old syntax with beginng and ending positions
because i have old examples of it in the source here but i would like to
do it using newer syntax and as gracefully as possible.

My current example (i have had many variations) won't compile but i think
it gives the gist of what i am trying to do, which is automatically load
the LabelName
array upon read of the file xrcl01.

A successful example of what i am trying to do would be appreciated.

       dcl-f XRCL01   usage(*input ) keyed ;
         // File layout for xrcl01
         //  XRCUST customer number (key)
         //  XRLSTM last maint date
         //  XRLA01 label name 1  char(8)
         //  XRLA02 label name 2  char(8)
         //  XRLA03 label name 3  char(8)
         //  XRSET1 label 1 sets  dec(2:0)
         //  XRSET2 label 2 sets  dec(2:0)
         //  XRSET1 label 3 sets  dec(2:0)

       dcl-ds LabelName  dim(  3) ;
         XRLA01    pos(  1) ;
         XRLA02    pos(  9) ;
         XRLA03    pos( 17) ;

       chain 039356 XRCL01 ;

       *inlr = *on;
<br />
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on it, is
prohibited and may be unlawful.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by 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].