Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Passing by Reference

Status
Not open for further replies.

jsplice

Programmer
Jun 3, 2003
88
US
I've been having a problem when passing a data structure by reference to a procedure that is part of a service program. When debugging the program, I try to see what value is contained in the data structure that was passed in, but when I do it says "Pointer not set for location referenced." If I attempt to pass an array by reference, I look at the values and in every element is all *'s. What could I be missing here?
 
I also forgot to mention that when I specify the "Value" keyword on the parameter in the procedure prototype, the value is passed in correctly. For some reason I am only having this problem when trying to pass by reference.
 
Unless field types and lengths match exactly, you should not pass parameters by reference. Use VALUE (only problem is, you can't use this with EXTPGM).

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
In most cases you are probably correct, but in this case the values must be passed by reference as they are being modified by the procedure (error message data structure). I did find the mistake however...the calling program was using a 2nd version of a copy book that I was not modifying. So in the end it was a small dumb mistake.
 
Glad you found the issue.

Question: why two versions of the same copybook?

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
It was just a naming convention thing...nothing really different between the two copy books. I created another one with a name that followed the desired naming convention and forgot to update the copy book file name in the calling program that used the service program.
 
What I mean is, why don't you just use the same copybook all over? Prototypes should be the same in service programs or in the programs they are called from. No reason (IMO) to have it otherwise.

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
It is being used all over. This is a new program being created and I created it with the incorrect name originally.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top