Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

How can I display a variable?

I'm using an interactive debugger (STRISDB) and wanted to display the variable, i.e. X (Y Z). However, I received a message that this variable requires a basing pointer. I tried using the command, "Watch X (1 2)" but there is still an error in the command. How can I display the variable?
A Basing Pointer is a variable defined in your program that sets the address of the variable you are trying to watch. Look at the source code and see what the name of the variable is in the BASED D-spec keyword that will be associated with the field definition. That name is the name of the basing pointer.

If the pointer has not yet been set, you will get an error or a wildly inaccurate result.

If the variable or the pointer is defined in a subprocedure, trying to see the value outside of that procedure will give you an inaccurate result.

As for WATCH, try not to use it if you can use another method, since WATCH is system-wide (you can only have 16 Watches at a time in the whole machine!) and it is very hungry for system resources. Instead, look through the source and place breakpoints where the variable you are interested in changes.

Note: I tend to use STRDBG for interactive debugginging of ILE programs, and this behaves correctly with basing pointers. I do not know whether STRISDB behaves in the same way. If you are debugging non-ILE programs, there shouldn't be any pointer data types in them anyway. If you have problems with STRISDB and basing pointers in ILE programs use STRDBG instead.


The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

Dig Deeper on iSeries application development tools