On 05/04/2007, at 11:19 PM, Johan Vangilbergen wrote:
When I run this interactively, all goes well. However, if I run this
in
batch, the procedure crashes on the "Clear Key2" statement, saying that
the pointer or location was not referenced.
What am I missing ?
First, have the courtesy to put a SUBJECT line in your appends.
Second, this code runs interactively simply by GOOD LUCK. There just
happen to be two old pointers on the stack after the two you pass when
calling this procedure. These old pointers are from some other previous
call to a procedure or program that was passed four or more parameters
by reference. In batch it just happens that those old parameters aren't
present so you get the pointer reference error.
Although your procedure "appears" to work interactively it is actually
CLEARing storage it has no right to address. That can cause other, much
subtler, errors which can be difficult to resolve. Again the fact that
this procedure runs interactively without causing problems is simply
good luck.
The resulting learning experience should be:
IF A PARAMETER WASN'T PASSED THEN DON'T REFERENCE IT IN CODE.
Other's have pointed out the coding defects that contribute to this
problem but no-one bothered to explain it. If my explanation is
insufficient then search the archives. There are previous discussions
on this very problem.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\
Fax: +61 3 9419 0175 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.