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.