× 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 appreciate the input.

After yesterday's posting (and during a moment of insight while getting
ready for work this morning) I realised I was after two separate things.
1) To know if a series of sub procedures was returning a pointer value
to me correctly and 2) The more 'just because I want to' question of how
to display the value of a pointer.

>From the feedback I've gotten I decided to validate my procedures by
displaying a value out of the user space I create - something from the
header for example - that is based on the pointer returned by the
routine. This would be a much better test of the success of creating the
user space and the validity of the pointer.

For the 2nd point - I'll still mess with the code to display a pointer.
Why? Because it's there (and I didn't know how to before) ;-)

Thanks again for all the input.

Best Wishes

Jim Wiant

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Steve Richter
Sent: Thursday, 3 November 2005 1:52
To: RPG programming on the AS400 / iSeries
Subject: Re: Displaying/Printing a pointer value


On 11/1/05, Jon Paris <Jon.Paris@xxxxxxxxxxxxxx> wrote:
>  >> I'm looking for a way that I can display or print the value of a
Pointer
> in RPG IV.

there is a materialize pointer instruction in MI. this will show the
object the pointer points to.  If the pointer is a space pointer, the
materialize instruction will also show the pointer offset within the
space.  You can most likely call that instruction, MATPTR, from RPG.

if you are dealing with a pointer to a variable ( a space pointer )
you can see some useful information by cracking open the last 8 bytes
of the pointer.  The last 3 bytes of this 2nd half holds the offset
within the space - you can just display this as an integer value. The
first 5 bytes of the 2nd half contains the object segment identifier.
The segment id is a unique idenfifier of the 16 meg segment object -
whatever it is called - that the offset is located within. If you
display this 5 byte value in hex you can compare two pointers to know
if they address the same space object.

>
> Simply map it to a character field (or multiple integers for that
matter)
> via a DS.  You still won't be able to "prove" that it is a valid
pointer
> since there is no way to directly incorporate the tag bit but ... I
guess if
> it were critical you could incorporate a test for *NULL and output
that
> information too.
>
> However, seeing the pointer value is pretty useless information - it
doesn't
> even really help in testing even since the data it points to may be
the
> same - but the address of the pointer different.  Since a pointers
purpose
> is to "point" to data - why not simply dereference the pointer (i.e.
use it
> as a basing pointer) for an arbitrary field and display the content of
that
> field?  I would think that seeing if the data matches is far more
useful
> than knowing the value of the pointer anyway.

Jon, it is not like the pointer is something modern, like a managed
code object reference :)  ILE C and I guess RPG can compare two
pointers, returning a result that one is greater or less than another.
For debug purposes, the programmer needs to know how one pointer into
a buffer compares against another.

-Steve


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.