× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Mon, 29 Apr 2002, Joel R. Cochran wrote:
>
> I'm trying to call an RPGIV sub-procedure from a CLLE program and return a
> value.  When I step through the program in Debug, the passed parameter is
> full of garbage in the sub-procedure...
>
[SNIP]
>              CALLPRC    PRC(#GETSYS) PARM(&TYPE) RTNVAL(&AUDITVALUE)
[SNIP]
> d #getSys         pi            10
> d  type                         10    value

You're telling the CL program to pass the parameter by reference.  You're
telling the RPG program to receive the parameter by value.

So what is the CL program passing?   An address.  Just something that
tells whomever is receiving the parameter where to look for the data
in main storage.   It just says "if you go to location X, you'll find my
data".

The RPG procedure has been told that it's receiving by value.   It thinks
that the actual data will be passed, instead of an address.  It takes the
address that the CL program passed, and happily stores it into the TYPE
variable.  It never looks at the memory that the CL program was trying to
reference because it believes that it's receiving the VALUE of the data.

(I think that's a pretty clear explanation -- if not, ask me for more
info)

AFIAK, CL cannot pass by value.   So probably the best way to fix this is
to change the RPG to CONST.  If this procedure is in use by existing RPG
programs, you might need to define a wrapper proc that simple receives
a CONST parm, and calls the other proc by VALUE...

[SNIP]
> BTW, this works fine when called from another RPGIV procedure...
[SNIP]

That's only because you're telling the RPG proc to pass the arguments
by VALUE;   If you told them to pass it by reference, you'd have the
same exact problem. :)

Anyway -- I hope this message helped you understand not just what you
did wrong, but also how it works...



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.