× 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.


  • Subject: Re: Data Structures with Structures
  • From: boldt@xxxxxxxxxx
  • Date: Thu, 28 Jun 2001 08:53:34 -0400
  • Importance: Normal

SCarter wrote:
>I know this is really long but I wanted to let you know what I am dealing
>with here.
>I have this very large array it looks like a three level structure  where
a
>file is read and fills out the top level then each of the FORMATxx fields
>are used
>to read a different record  and fill out the second level and again the
>FORMATxx records on this level are used to read the file and fill out the
>last level.
>What I am trying to see is there a more intuitive way of performing the
>same function without getting into things like recursion.....
>
>D DATA            DS
>D  PARMS                              DIM(10)
>D   CO1                        580    OVERLAY(PARMS:1  )
>D     FSCOA                      2    OVERLAY(CO1:1)
>D     FSCOA#                     2  0 OVERLAY(CO1:1)
>...

First, I would recommend avoiding the use of explicit numeric
values in the OVERLAY keyword.  Use *NEXT whenever possible to
avoid hardcoding explicit offsets.  The subfields can be rearranged
to avoid the hardcoded offsets.

Actually, there is a better way to code that.  Unfortunately, the
RPG compiler that can handle that technique only exists on one
machine in the Toronto Lab.  Basically, what you want is a complex
structure involving a 3 dimensional array.  Below is an example of
what we're working on.  Remember, this is still under development
and not announced, and so maybe this will never be released outside
the lab.  Or if it is, perhaps it'll look a lot different.  But
here's your data structure rewritten in a more concise form:

-------------------------------------------------------------
 1 D subsds          ds                  qualified based(@)
 2 D   cbr                          3
 3 D     co                         2    overlay(cbr)
 4 D       co#                      2  0 overlay(co)
 5 D     br                         1    overlay(cbr:*next)
 6 D   fmt                         10
 7 D subarr          ds                  qualified based(@)
 8 D   subs                              dim(10) likeds(subsds)
 9 D data            ds                  dim(10) qualified
10 D   fscoa                        2
11 D     fscoa#                     2  0 overlay(fscoa)
12 D   fscobra#                     3  0
13 D     fsbra                      1    overlay(fscobra#)
14 D   formata                     10
15 D   co                                dim(10) likeds(subarr)
16  /free
17     data(3).co(4).subs(5).fmt = 'testing';
18     *inlr = *on;
19  /end-free
-------------------------------------------------------------

What's different?  For the first few lines, we have normal RPG IV.
(Keyword QUALIFIED is new for V5R1, though.)  In line 8, we have
keyword LIKEDS.  The keyword was added in V5R1, however, what's
new is that it's coded for a subfield.  Thus, "SUBARR.SUBS" is
defined as both a subfield and as a data structure.  Subfields
of "SUBARR.SUBS" would be referenced like "SUBARR.SUBS(X).FMT".

The next new thing is on line 9.  Keyword DIM has been around
since V3R1, but here we see it on a data structure.  And so,
subfields of "DATA" are referenced like "DATA(Y).FORMATA".

To put it all together, we can see how data within the structure
is referenced on line 17.  Currently in V5R1, qualified names can
only be of the form "DS.SUBF".  By allowing DIM on a DS definition
and LIKEDS on a subfield definition, we now get full data
structuring capability, much like other languages.

Both of these items were listed in our last enhancement poll.  DIM
on DS definition was voted in the top $100.  LIKEDS on subfield
came in close to the bottom of the polling, and so maybe there's
no real justification for releasing that item.

To emphasize again, nothing officially exists until you see that
announcement letter.

Cheers!  Hans

Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com

+---
| 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 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.