Pointer Based Basing Pointers and Debug

Archived from comp.sys.ibm.as400.misc

All rights reside with original authors, etc.


Message-ID: <43C84A3C.38DF558@ca.ibm.com>
Date: Fri, 13 Jan 2006 19:47:56 -0500
From: Barbara Morris 
X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.sys.ibm.as400.misc
Subject: Re: When the based variable's basing pointer is pointer based...

Chris Pando wrote:
> 
> When the based variable's basing pointer is pointer based
> you can't use debug to display it.
> 

That's true when debugging RPG.  At least, you can't display the
variable directly.

But for RPG and I believe COBOL, the debugger supports an a->b->c syntax
for following multiply-based pointers.  "A" is the top level pointer, B
is the pointer based on A, and C is the variable based on B.


 d recordDS        ds                  Based(ds@)
 d  parent@                        *
 d  objLen                       10i 0
 d  objDat                       10i 0
 d  objSiz                       10i 0
 d  objVar                        1a

 d ds@             s               *   Based(ds@@)

===>  eval ds@@->ds@->objLen


You can go more levels than 3, and you can modify variables this way:


===> eval ds@@->ds@->parent@->objDat = 13

To get the debug expression, work from right to left starting with the
variable you want to display:

   objLen


Now add the basing pointer for objLen:

   ds@->objLen

Now add the basing pointer for ds@:

   ds@@->ds@->objLen

The expression is ready when you reach a pointer that is not based (ds@@).

 ===> eval  ds@@->ds@->objLen


Valid HTML 3.2! Creative Commons License

BrilligWare/ chris@pando.org / revised February 2008