|
At 10:52 AM 12/4/99 +1100, you wrote:
>Hello Mark,
>
>Since Jon hasn't answered this yet, I will. Perhaps you are confused by
>the fact that there is no explicit pointer definition for Array@. Array@
>is a based pointer. The compiler
>automatically defines any pointer used in a BASED definition. (I think
>that relying on this is sloppy and the programmer should code the pointer
>anyway, but that's just me!)
You got it - that's what threw me.
>The rest of the code is pretty straight-forward. The only real problem
>with such a technique
>is that array elements need to be the same size hence the "PADn" variables.
They are the same size. I thought the "PADn" variables were for
illustration purposes, i.e. "other" fields.
The way I'm understanding the rest of the code, assigning a regular field
value to a pointer variable will automatically result in the pointer
pointing to that variable's memory area. Correct?
-mark
> > Date: Thu, 25 Nov 1999 00:03:41 +1100
> > From: "Mark Lazarus" <mlazarus@ttec.com>
> > To: RPG400-L@midrange.com
> > Reply-To: RPG400-L@midrange.com
> > Subject: Using Pointers
>
> >
> > Jon,
> >
> > At 09:44 AM 11/22/99 -0500, you wrote:
> >
> > I followed the code until I got to Array@ ! Is there a "@" missing
> > somewhere?
> >
> > >The following technique (which does use pointers) could also work but I
> > doubt it
> > >is worth the effort. PS. The code sample here has been validated by
> > Code/400 but
> > >not tested.
> > >
> > >
> > > D FakeRecord DS
> > > D Elem1 4 Inz('ABCD')
> > > D Pad1 10
> > > D Elem2 4 Inz('EFGH')
> > > D Pad2 12
> > > D Elem3 4 Inz('IJKL')
> > > D Pad3 5
> > > D Elem4 4 Inz('MNOP')
> > >
> > > D ArrayPtrs DS
> > > D * Inz(%Addr(Elem1))
> > > D * Inz(%Addr(Elem2))
> > > D * Inz(%Addr(Elem3))
> > > D * Inz(%Addr(Elem4))
> > >
> > > D Array * Dim(4) Overlay(ArrayPtrs)
> > >
> > > D CurrentElem S 4 Based(Array@)
> > > D Count S 1 0
> > >
> > > C For Count = 1 to %Elem(Array)
> > > C Eval Array@ = Array(Count)
> > > C CurrentElem Dsply
> > > C EndFor
+---
| 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 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.