REXX 中的 RC 特殊变量?

发布于 2024-10-05 08:06:02 字数 29 浏览 0 评论 0原文

如何给 REXX 中的 RC 特殊变量赋值?

how to assign a value to RC special variable in REXX?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

メ斷腸人バ 2024-10-12 08:06:05

正如 Deuian 之前所说,RC 由最后执行的命令设置,应提供更多详细信息以获得精确的答案(环境、目标/任务、批处理/交互等)。
在 Zos REXX 上设置 RC 的一个愚蠢的工作方法是创建一个缓冲区:RC 设置为缓冲区计数(因此,如果您需要 RC = 100,则应该创建 100 个缓冲区...),请参阅示例(我不认可使用此方法,这只是一个猜想)

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

请注意,前面的代码使缓冲区处于活动状态! (需要另一个 DROPBUF)

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)

尽揽少女心 2024-10-12 08:06:04

SAY 指令将发送屏幕提示或在输出中包含文本。如果您想将 RC 设置为可以由作业中的后续步骤解释的内容,请尝试:

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

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)
你对谁都笑 2024-10-12 08:06:04

如果要设置方法的返回值,则需要使用“return”命令并通过“result”获取返回代码,例如:

/* 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..."

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..."
怎言笑 2024-10-12 08:06:03
/* 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 */

上面的工作原理是,RC 变量没有什么特别之处,只是它会被最后一个命令的返回代码覆盖。
所以你至少可以在运行 Zos 的大型机上将其设置为你想要的任何值。

也许您需要在问题中提供更多详细信息,例如 Rexx 的类型(经典或 OO)以及您正在使用的环境。

/* 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文