× 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.



Knezevic, Mihael wrote:
hi,

is it possible in rpg to return a value from a program. i don't mean to
get a return value of a procedure.

i like to do something in perl like this:

$myvar = `system myrpgprogram`;

but i don't know how i should define my prototype in the rpg program.
the rpg program name is BS_SUBS. it tried it like this:


DMain PR 10A EXTPGM('BS_SUBS') D subname 10A D sublib 10A * *Entry list (parameter) DMain PI 10A D subname 10A D sublib 10A

but it says that a return value is not supported with EXTPGM key word.

thanx in advance for any help.

mk

No.


The way you get return values from a program is by specifying a reference parameter that will receive the output from the program. Within the called program, the data to be returned is assigned to that parameter.

BTW, I believe the result of executing the expression `system myrpgprogram` is the return code from performing the specified command (that is, a success/failure indication), not the output of the command. Although a "return code" of a sort was set by RPG III programs (if I'm not mistaken), I'm not sure if it is set by RPG IV programs.

Cheers! Hans


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.