× 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 Arrays
  • From: "Peter Dow" <pcdow@xxxxxxxxx>
  • Date: Fri, 6 Oct 2000 20:07:26 -0700

Hi James,

Let's see if I can come up with an example code.


    D abc        DS        10 (occurrences that is)
    D  abc1                    10A

    D xyz        DS                based(ptrXYZ)
    D  xyz1                    10A

    c     1        occur    abc
    c              eval     ptrXYZ = %addr(abc)
    c     2        occur    abc

    c              if        abc1 = xyz1 (this is comparing 2 different
occurrences)
    c                ...
    c              endif

As I said, I haven't actually tried this, but my understanding is that after
the 2nd OCCUR stmt, the xyz data structure is still pointing to the 1st
occurrence. The %addr(abc) returns a pointer to whatever the current
occurrence is.

As to using pointers to do multi-dimensional arrays, I think you're right it
might get pretty ugly. IBM almost slipped up and gave it to us with those
array subfields, where you can overlay an array with subfields of an array
element and then sort the array by those subfields. But they didn't allow
the subfields to be arrays.

I haven't had much need for multi-dimensional arrays, but the couple of
times I have, they've been just 2-D arrays, which are fairly easily
simulated by calculations or an array within a multi-dimensional data
structure.

HTH
Peter Dow
Dow Software Services, Inc.
909 425-0194 voice
909 425-0196 fax




From: "James W. Kilgore" <qappdsn@attglobal.net>
> I must be having a case of Fridayitis, but don't get it.  AFAIK, unless
the names
> are different you are only looking at a single instance at any particular
point
> in time.

> Or am I just locked into classic RPG thinking?  I just had a thought, is
there a
> method through pointers to mimic multiple dimensional arrays?  Do you wind
up
> changing all of your calculations to use pointers and base pointer off
sets
> instead of field names?  How ugly, although possible, would this get?
>
> Gads, I just had an assembler shiver run up my spine!  It's going to take
me all
> weekend to get over it. ;-)
>
>
> Peter Dow wrote:
>
> > Hi Barbara,
> >
> > I haven't done it myself, but from other posts on this list, it sounds
like
> > it _is_ possible to use more than one occurrence at a time using
pointers.
> > If you have an identically defined data structure based on a pointer,
set
> > that pointer to the current occurrence of the multi-occurrence data
> > structure, then change the occurrence to something else and voila! you
are
> > now looking at two different occurrences.
> >
>
> +---
> | 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
> +---


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.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-Ups:
Replies:

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.