5

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

如果我把END-PERFORM。在任何一行都比我在退出程序之前的最后一行更早 - 它有效。但我需要程序每次都显示 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.
4

2 回答 2

9

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

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

于 2013-04-25T19:51:50.790 回答
4

您在显示 INPUTC 语句中有一个句点。删除期间,你应该没问题。Period 总是结束一个语句。

于 2013-07-12T20:18:15.443 回答