开发者

RC special variable in REXX?

开发者 https://www.devze.com 2023-01-28 16:40 出处:网络
how to assign开发者_JS百科 a value to RC special variable in REXX?/* REXX */ \"LISTDS ?\"/* Command that sets RC to 12 */

how to assign开发者_JS百科 a value to RC special variable in REXX?


/* REXX */
"LISTDS ?"         /* Command that sets RC to 12 */
SAY 'RC IS' RC     /* RC is 12 */
RC = X             /* RC set to X */
SAY 'RC IS' RC     /* RC is X */

The above works, there is nothing special about the RC variable except it will be over written by the return code from the last command. So you can set it to whatever you want at least on a mainframe running Zos.

Maybe you need to provide more detail in your question like what type of Rexx it is (Classic or OO) and what environment you are using.


If you want to set the return value of your method you need to use the "return" commend and to get the return code with the "result", for example:

/* REXX - program A */ 
SAY "THIS IS PROG. A WITH RC = 4"
RETURN 4

/* REXX - PROGRAM B */
SAY "CALLING PROGRAM A..."
CALL PROG_A
RC = RESULT
SAY "RC = "RC " RETURN FROM PROGRAM A..."


As Deuian said before, RC is set by last command executed and more detail should be provided to get a precise answer (environment, goal/task, batch/interactive etc.). A silly working way to set RC on Zos REXX is to make a buffer: RC is set to the buffer count (so if you need RC = 100 you should create 100 buffers...), see the example (I do not endorse the usage of this method, it's just a conjecture)

/* rexx */
'MAKEBUF'
say RC
'MAKEBUF'
say RC
'DROPBUF'
say RC
/* exec output */
1
2
0
***

Beware that the previous code leaves a buffer active! (another DROPBUF needed)


The SAY instructions will send screen prompts or include text in the output. If you want to set the RC to something that can be interpreted by subsequent steps in a job, try:

/* REXX */
setrc = X             /* set a variable for RC to X */
exit(setrc)
0

精彩评论

暂无评论...
验证码 换一张
取 消