mainframerexx

Calling particular functions in an external Rexx script


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.


Solution

  • 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).