mainframezosrexx

Is there a way to pass an array to an external REXX program?


What I have tried:

Program A:

call PROGRAMB ARRAY val1 val2 

PROGRAM B:

PARSE arg ARRAY val1 val2 
/* test to see if ARRAY is passed successfully */
/* len1 equals the length of ARRAY */
interpret "len1 = "ARRAY".0"
say 'len1: ' len1 
DO i=0 TO len1
    say 'current line: '
    interpret "say "ARRAY".i"
END;

Expected Results:

  1. len1 would be equivalent to the length of the array. For example if ARRAY = [1,2,3], len would be equal to 3.
  2. Each member of the array should be printed.

Actual Results:

  1. len1 is equivalent to "JOBCARD.0" not the actual length.
  2. The program fails on the for loop due to a IRX0041I (Bad arithmetic conversion) and doesn't print out the members/

Solutions I have tried:

https://www.bde-gmbh.de/tipps-tricks/zos-rexx/how-to-pass-stems-as-procedure-arguments-in-rexx/

But this method only works for passing arrays to functions within the same program.


Solution

  • You can't pass a stem (array) to an external Rexx EXEC. Look into using NEWSTACK, PUSH, QUEUE, QUEUED(), PULL, DELSTACK. These are all documented in the keyword instructions, built-in functions, and TSO/E external functions sections of the TSO/E Rexx Reference