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



There was an increasingly misnamed thread recently around the idea of
emulating a %max() BIF in RPG. While I think it is a very good idea to
vote for the proposed RFE (and I did), there were several proposals to
emulate such a function now; without waiting.

Clearly, the interface is a problem. RPG currently provides no
equivalent to C's ellipsis [va_arg()]. So any implementation of %max()
would either use a bunch of *NOPASS parameters, or something completely
different. Which is where I went.

Rexx has a MAX() function. MIN() too. The interface between RPG and
Rexx is a little wheezy - the Rexx external queue. It's sort of like a
dataqueue, and a queue can hold a varying number of entries, hm. Rexx
is also included on every IBM midrange system since AS/400.

Attached, please find an RPG program that uses an array of numbers,
passes them one by one to the Rexx queue, calls a Rexx procedure which
assembles them into a statement that is interpreted (much like QCMDEXEC
does for RPG), and pushes back the highest entry to the RPG program via
the queue.

I probably wouldn't use this in production; instead I'd do the Rexx part
in a sub-procedure that pulls entries off a queue (user space, data
queue, heap, array, whatever) one at a time and does the comparison. I
went through the exercise Just Because, and also because I realised
there are too few examples of RPG interacting with Rexx.

http://code.midrange.com/901f5bdd82.html


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.