gpt4 book ai didi

progress-4gl - 进度 if 语句

转载 作者:行者123 更新时间:2023-12-04 04:20:56 24 4
gpt4 key购买 nike

我是一个进步的菜鸟,实际上在基本 block 方面有问题。

下面的问题是在我的 if else 语句中。它在 if, then, else then 时工作正常,但是当我想将多个语句放入 if 部分时,我必须将它放在一个 block 中,所以我使用 if, then do: else,然后做:但这些对我不起作用。您可以看到任何明显的错误吗?我的错误消息是 **冒号后跟空格终止语句。 (199)

INPUT FROM "r:\_content\stephen\4gl apps\dpl\output.csv".
REPEAT:
ASSIGN i_cntr = (i_cntr + 1).
myRow = "".
IMPORT DELIMITER ',' myRow.

IF myRow[5] <> "" THEN DO:
/*change this to assign 2 rows - 2 creates - 2 sets of four*/
c_fname = myRow[1].

MESSAGE
c_fname SKIP
myRow[2] SKIP
myRow[3] skip
myRow[4] skip
myRow[5] SKIP
i_cntr
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END./*end of if, then do:*/
ELSE IF myRow[5] = "" THEN DO:
MESSAGE
myRow[1] SKIP
myRow[2] skip
myRow[3] skip
myRow[4] skip
i_cntr
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END./*end of else if, then do:*/
END./*end of repeat*/

最佳答案

一个非常简单的语法错误:在 END 语句之后至少需要一个空格。

END. /*end of if, then do:*/
/* ^ Make sure there's space above here! */

如果您不想遵循 Tims 回答中的优秀建议(使用 CASE)。这是 IF 语句的“完整”语法。

IF expression1 THEN DO:
/* Code goes here */
END.
ELSE IF expression2 THEN DO:
/* Code goes here */
END.
ELSE DO:
/* Code goes here */
END.

expressions:

A constant, field name, variable name, or expression whose value is logical (TRUE or FALSE). The expression can include comparisons, logical operators, and parentheses.

您也可以省略 DO: END。当要执行的 IF 代码只有一条语句时:

IF TRUE THEN DISPLAY "TRUE".
ELSE DISPLAY "NOT TRUE".

您还可以使用其他 block 语句(例如 FOR 或 REPEAT),但这很可能只会创建难以阅读的代码。

关于progress-4gl - 进度 if 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24287352/

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