× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have this simple RPGLE program:
     fARRAYF    IF   E           K DISK

     d MyVar1          s                   like(keyfld)
     d MyVar2          s                   like(Ary1)
     d MyVar3          s                   like(Ary2)
     d MyVar4          s                   like(Ary3)

      /FREE
       SETLL *LOVAL ARRAYF;
       read arrayf;
       DOW %STATUS(ARRAYF)=0;
        MyVar1=KeyFld;
        MyVar2=Ary1;
        MyVar3=Ary2;
        // MyVar4=Ary3;
        read arrayF;
       EndDo;
       *inlr=*on;
      /END-FREE

I compiled it with *list for debugging.  When I open it in the Code
debugger it will pull in the following I specs:
        73=IARYREC
        74=I                             A    1   10  KEYFLD
        75=I                             P   11   13 0ARY1
        76=I                             P   14   16 0ARY2
        77=I                             P   17   19 0ARY3
Four of the five lines will be blue.  The Ary3 line will be black because
it is unreferenced.  If I display any of the other fields after the read
they will have a value - Ary3 will not.  And if you did not disable the
debugging of I/O it will stop on lines 73-76 but not 77.  At this point you
may be wondering why should I care?  I am getting there.  If I modify the
program to look like:
     fARRAYF    IF   E           K DISK

     d MyArray         s                   like(Ary1) dim(3)
     d                                     based(pMyArray)
     d pMyArray        s               *   inz(%addr(Ary1))
      /FREE
       SETLL *LOVAL ARRAYF;
       read arrayf;
       DOW %STATUS(ARRAYF)=0;
        MyArray(1)=MyArray(1);
        MyArray(2)=MyArray(2);
        MyArray(3)=MyArray(3);
        read arrayF;
       EndDo;
       *inlr=*on;
      /END-FREE
Ary1 and MyArray(1) will have a value because Ary1 is a referenced field.
Ary2, Ary3 and MyArray(2-3) will not have values because Ary2 and Ary3 are
unreferenced fields.

Now, in my opinion Ary2 and Ary3 are NOT unreferenced fields because they
are being used in an array.

Granted, setting a variable equal to itself won't normally be done - I just
did that for debugging purposes.

Rob Berendt
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
Benjamin Franklin



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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

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.