Hi Michael,

> Yes...you can do it that way...or, you could take the contents of the
> file and put it into an array or data structure. HAve a basing pointer
> that points to the data structure, like this:
> D MyArr     S        80    Dim(100)
> D MyPtr     S           *  Based(MyArr)

That's not legal code.   I'm not sure whether you're intending to put the
array in the same memory as a user space, or whether you're just trying to
assign the address of MyArr to MyPtr?

In any case, the way you've coded this, you're telling it to put the
pointer into memory that's pointed to by MyArr.  And that makes no sense
whatsoever, since MyArr isn't a pointer, it can't point to memory.

This code would be used if MyArr is intended to be in a user space, or in
allocated memory:

  D MyArr     S         80    Dim(100) Based(MyPtr)
  D MyPtr     S           *

What that means is...  MyArr occupies the area of memory pointed to by
MyPtr.  If you change MyPtr, it changes where MyArr is located.  This is
how you're able to view a user space using variable names -- by changing
the space that the variable occupies to be in the user space's area.

The alternative is:

  D MyArr     S         80    Dim(100)
  D MyPtr     S           *   inz(%addr(MyArr))

In this case, MyArr is a normal array.  It's given it's own space is
memory to exist in when the program starts.  You've assigned MyPtr to that
area of memory, so if you wanted to pass the address of MyArr to something
else, you could pass MyPtr instead.

However, if you change MyPtr, it would make MyPtr point to another area of
memory, but MyArr would be unaffected.

I'm not quite sure which of these two examples you intended to use, but,
basing MyPtr on MyArr makes no sense, and says to me that you don't really
understand what the code does.  So, hopefully my explanation helped...

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