Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling particular functions in an external Rexx script

Tags:

mainframe

rexx

I have a Rexx script which functions standalone, and I wish to use another Rexx script to call particular functions within it. I am aware I can call both an entire external Rexx file and internal Rexx functions with call, but am I able to call a single function inside an external script? The following example illustrates what I want to do:

/* REXXA */
say 'hello'

run_test:
say 'test'

...

/* REXXB */
call 'REXXA' /* will say both 'hello' and 'test' */

How can I modify REXXB to say only 'test'?

EDIT: Further research indicates I might be looking for RxFuncAdd - can anyone confirm if that works with mainframe Rexx scripts? Most of the references involving it have been with regards to DLL libraries...

EDIT 2: Apparently not... anybody got any better ideas? RxFuncAdd routine not found

EDIT 3: I mustn't have explained my requirements properly, sorry about that - as per the comment under NealB's response, I essentially want something akin to calling a 'sin' function inside a 'math' class. The code I am writing is REXXB in the example above, and I want to change REXXA as little as possible.

like image 970
Matt Lyons Avatar asked Jan 18 '23 20:01

Matt Lyons


2 Answers

Directly there's no way to address internal labels in another program.

My first gut reaction is that you would have to slightly modify REXXA to add a wrapper function with a function code, something like

/* REXX A */

arg a1 a2 a3 a4 a5 (etc.)
select
when a1 = 'SIN'
  call sin a2 a3 ....
when a1 = 'COS'
  call cos a2 a3 ....
end
exit rc

sin:
  return some equation involving a2 that I last saw about 33 years ago

cos:
  return some equation involving a2 that I last saw about 33 years ago

/* REXX B */
call 'REXXA' 'sin 85' 

However, REXX under TSO does support external functions and subroutines which can be written in many languages, including REXX. The TSO/E REXX Reference External functions and subroutines, and function packages, z/OS V11 flavor describes how to do this.

There is a note in the doc about optionally compiling the REXX. If you don't have it, you may be able to find someone who is licensed for it who could compile it for use with ALTLIB (no license necessary).

like image 181
zarchasmpgmr Avatar answered Feb 16 '23 02:02

zarchasmpgmr


cschneid has the right idea... The following works under both TSO (z/os) and Windows ooRexx:

REXXA:

/* REXXA */
parse source . as_a .
if as_a = 'COMMAND' then
   say 'hello'

run_test:
say 'test'
return

REXXB:

/* REXXB */
call 'REXXA' /* will say 'test' */
return

From the TSO or Windows Comand Line prompt: Typing REXXA will print both hello and test. Typing REXXB will print only test.

I must admit that I find this requirement a bit strange...

like image 44
NealB Avatar answered Feb 16 '23 00:02

NealB