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



Hello Howard,

You wrote:
>All of the examples in the books show me how to get variables into Rexx,
>but either I am blind or brain-dead, but I can not get Rexx to pass a
>variable back into the CL, here is what I am doing, a bit jumbled at the
>moment out of frustration. How do I get the result back into the CL?

Since you just need a random number you can invoke the C-runtime srand()
and rand() functions, or the ILE CEERAN0 function.  These functions have
been discussed here before (and in the RPG list) so search the archives
for details.  If you really want to learn something about Rexx then read
on . . .

Rexx is intended to be used as the job control language.  It has support
for calling other programs and for invoking CL commands and retrieving
values from CL via RTNVAL(*YES) parameters.  The Rexx Programmer's Guide
discusses returning data from C to Rexx.  That method should work with any
ILE language.  It also discusses using the Rexx queue to return data from
non-ILE languages.  In all these cases Rexx is the driver.

You are using CL as the driver and invoking Rexx via STRREXPRC.  The PARM
keyword maps directly to the Rexx ARG list which implicitly means it is
input only (think of it as pass by VALUE) so no changes in Rexx will be
reflected in CL variables specified on PARM.

When using a non-Rexx program as the driver I believe there are two ways
of getting the data.

1/ If RETURN is used in a Rexx procedure that was NOT invoked via Rexx
CALL or as a Rexx function then the RETURN value will be sent in message
CPF7CFF.  However that restricts the return value to a number between
-32768 and 32767.

You are not using a seed value but you are setting a maximum limit on the
range of random numbers.  Your limit is a six-digit number based on time
(you might want to rethink that because I don't think that's what you
intended).  Any RETURN value is likely to be too big for the range allowed
by CPF7CFF.

2/ Put the return value on the Rexx queue (using PUSH) and retrieve it
using the QREXQ API.

Since Rexx can be the CPP for a CL command it would be nice if we could
use RTNVAL(*YES) for the parameter and code something like:

CMD        PROMPT('Test Rexx Command')

PARM       KWD(RANDOM) TYPE(*CHAR) LEN(6) RTNVAL(*YES)

however RTNVAL(*YES) is not supported when Rexx is used as the CPP.

Regards,
Simon Coulter.

--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists
   http://www.flybynight.com.au/

   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.