gpt4 book ai didi

cobol - COBOL 中的嵌套执行循环?

转载 作者:行者123 更新时间:2023-12-04 05:48:00 27 4
gpt4 key购买 nike

为什么我不能在 COBOL 中执行此嵌套执行循环?

如果我把END-PERFORM。在任何一行中比我在 EXIT PROGRAM 之前拥有最后一个的地方早 - 它有效。但是我需要程序每次都显示 INPUT C 值。在外部执行循环中。它让我发疯。

PROCEDURE DIVISION USING INPUTC CIPHER.
COMPUTE CIPHERMAX = CIPHER.
MULTIPLY -1 BY CIPHER
---> PERFORM VARYING CIPHER FROM 0 BY 1
UNTIL CIPHERMAX = CIPHER
DISPLAY 'This is loop number: ' CIPHER
INSPECT INPUTC CONVERTING
"avcdefghijklmnopqrstuvwxyz" to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
COMPUTE CONVERTNUM = FUNCTION MOD (CIPHER, 26)
INSPECT FUNCTION REVERSE(INPUTC) TALLYING LENGTHNUM FOR LEADING SPACES
COMPUTE LENGTHNUM = LENGTH OF CIPHER - LENGTHNUM

---> PERFORM UNTIL SENTRY = LENGTHNUM

IF ((FUNCTION ORD(INPUTC(SENTRY:1)) + CONVERTNUM) > (FUNCTION ORD('Z')))
MOVE FUNCTION CHAR((FUNCTION ORD(INPUTC(SENTRY:1)) + CONVERTNUM) - 26) TO RECHAR
ELSE
MOVE FUNCTION CHAR(FUNCTION ORD(INPUTC(SENTRY:1)) + CONVERTNUM) TO RECHAR
END-IF
IF (((FUNCTION ORD(INPUTC(SENTRY:1))) >= (FUNCTION ORD('A'))) AND
((FUNCTION ORD(INPUTC(SENTRY:1))) <= (FUNCTION ORD('Z'))))
IF ((FUNCTION ORD(INPUTC(SENTRY:1)) + CONVERTNUM) > (FUNCTION ORD('Z')))
INSPECT INPUTC(SENTRY:1) REPLACING ALL INPUTC(SENTRY:1) BY RECHAR
ELSE
INSPECT INPUTC(SENTRY:1) REPLACING ALL INPUTC(SENTRY:1) BY RECHAR
END-IF
ELSE
INSPECT INPUTC(SENTRY:1) REPLACING ALL INPUTC(SENTRY:1) BY INPUTC(SENTRY:1)
END-IF

COMPUTE SENTRY = SENTRY + 1
---> END-PERFORM
DISPLAY INPUTC.
COMPUTE LOOPI = LOOPI + 1
--->END-PERFORM.
EXIT PROGRAM.
END PROGRAM SOLVE.

最佳答案

DISPLAY INPUTC. 之后那个讨厌的范围终止期正在终止嵌套 PERFORM 的范围声明。摆脱这个时期,一切都应该正常工作。

根据 COBOL-85 标准编码程序时,您应该在程序部中使用的唯一句点是终止节和段落标题所需的句点,以及终止当前段落、节或程序所需的句点。

关于cobol - COBOL 中的嵌套执行循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16220831/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com