REXXTRY: Execute a line of REXX code and set &resultOverviewThe REXXTRY command is invoked in two different TSO/E environments to execute REXX execs:
REXXTRY is written in assembler and runs in the MVS/ESA, OS/390 and z/OS environments. It is a free program, available in source-code and load-module format in the freeware section of this Web site. |
REXXTRY can be invoked as a command anywhere in the TSO/E environment: READY prompt, PDF opt 6, ISPF TSO command, CLIST, ISPF panel, ISPF command table, etc. In particular, in a CLIST or in batch TSO/E:
REXXTRY a='A'; b='B'; RETURN a || b
If the REXX exec ends with a RETURN instruction (as shown in the example above), the returned value is stored into the &RESULT variable. The length of the data returned by the exec is limited to 256 bytes.
//REXX EXEC PGM=IKJEFT01 //STEPLIB DD DSN=CBTTAPE.FILE183.LOAD,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * REXXTRY SAY 'Hello!'
When REXXTRY runs in an on-line TSO session and no REXX code is specified as an argument, it displays its eye-catcher using TPUT and terminates with RC=20.
In the ISPF environment, if the REXX exec needs to access ISPF variables using VGET and VPUT, REXXTRY must be invoked with LANG(CREX). However, specifying LANG(CREX) prevents REXXTRY from storing the data returned by the REXX exec into &RESULT. Consequently, the REXX exec must be designed to use RETURN or VGET/VPUT, but not both. This restriction is imposed by the method ISPF uses to handle variables in the compiled REXX environment.
SET string = ABC DEF GHI JKL REXXTRY xxx="&string"; + n=WORDS(xxx); + RETURN WORD(xxx,n) WRITE LASTCC=&LASTCC RESULT=&RESULT
PROC 1 DSN ALL SET cmd = LISTC ENT(&STR(&dsn)) &all /* TSO Command */ REXXTRY RC=OUTTRAP("LINE."); "&cmd"; CC=RC; RC=OUTTRAP("OFF"); + CALL STEMEDIT "BROWSE","LINE.",,,"&cmd"
%RESULT=&result )INIT IF (&result=&Z) &result=0 )PROC &ZSEL='CMD(REXXTRY RETURN &result+1) MODE(FSCR)' )END
%RESULT=&result )INIT IF (&result=&Z) &result=0 )PROC &rexx='"VGET result"; result=&result+1; "VPUT result"' &ZSEL='CMD(REXXTRY ADDRESS ISPEXEC; &rexx) LANG(CREX)' )END
Execute two TSO TIME commands
//TSO EXEC PGM=IKJEFT01,PARM='REXXTRY "TIME"; "TIME" ' //STEPLIB DD DSN=CBTTAPE.FILE183.LOAD,DISP=SHR REXXTRY //SYSTSPRT DD SYSOUT=* //SYSTSIN DD DUMMY
Execute two REXX SAY commands
//TMP1 EXEC PGM=IKJEFT01,PARM='REXXTRY SAY DATE(); SAY TIME() ' //STEPLIB DD DSN=CBTTAPE.FILE183.LOAD,DISP=SHR REXXTRY //SYSTSPRT DD SYSOUT=* //SYSTSIN DD DUMMY
Execute in-line REXX code
//TMP2 EXEC PGM=IKJEFT01 //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * TSOLIB ACT DS('CBTTAPE.FILE183.LOAD') REXXTRY SAY "this is my REXX exec (line 1)" SAY "this is my REXX exec (line 2)" EXIT 3
//CLISTRX EXEC PGM=IKJEFT01 //STEPLIB DD DSN=CBTTAPE.FILE183.LOAD,DISP=SHR REXXTRY //SYSPROC DD DSN=CBTTAPE.FILE183.PDS,DISP=SHR EXECUTE //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * %EXECUTE CLIST /* The CLIST starts here */ CONTROL LIST CONLIST /*CLIST*/ WRITE Start of the CLIST /*CLIST*/ REXXTRY A=1; /*REXX*/ + B=2; /*REXX*/ + UID=USERID(); /*REXX*/ + RETURN(A+B UID) /*REXX*/ WRITE LASTCC=&LASTCC RESULT='&RESULT' /*CLIST*/ EXIT CODE(&LASTCC) /*CLIST*/
//VIACALL EXEC PGM=IKJEFT01 //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * CALL 'CBTTAPE.FILE183.LOAD(REXXTRY)' 'SAY XXX; SAY YYY' /*
//VIACALL2 EXEC PGM=IKJEFT01 //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * CALL 'CBTTAPE.FILE183.LOAD(REXXTRY)' SAY XXX SAY YYY /*
The return-code produced by the REXXTRY program is the return-code received from the REXX interpreter.