|
On 17/02/2009, at 4:58 AM, Vern Hamberg wrote:
I don't remember the circumstances, and it may have been in an earlier
release - I have run into the need to declare the pointer and/or to
initialize the pointer explicitly with the %addr() function. The syntax
you give below seems to work most of the time, however. As I say, I
don't remember where I've had the problem. But leaving out one or both
items resulted in an MCH3601.
You might want to rethink this. Both
D var S 10 BASED(@var)
and
D @var S *
D var S 10 BASED(@var)
will result in a NULL pointer named @var being declared and var will be based on that NULL pointer. If your code attempts to reference either the pointer or the based storage you will get MCH3601 (except for the obvious case of a reference that assigns an address to the pointer).
You must set the basing pointer to a valid address before referencing the based variable. Whether you do that by using INZ(%ADDR())--which obviously requires you to explicitly declare the basing pointer--or via an EVAL @var = %ADDR() operation is immaterial. This is true of all languages with pointer support (on iSeries). If the pointer is not set you will get MCH3601 when you attempt to reference storage based on that pointer.
Perhaps you were bitten by Barbara's earlier point that a global basing pointer will be overridden by a compiler-generated local basing pointer? If so, that's a different issue.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
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.