我是4GL进步语言的初学者,我想了解4gl进步语言中NO-UNDO和NO-ERROR之间的区别。
答案 0 :(得分:3)
没有错误
没有错误可以消除运行时中的错误,并将这些错误的责任及其交给开发人员。
/*
In this example we do basically the same thing twice, once with no-error and once without.
Without no-error the program will exit and the last message box will not be shown.
*/
DEFINE TEMP-TABLE tt NO-UNDO
FIELD a AS INTEGER.
CREATE tt.
ASSIGN tt.a = INTEGER("HELLO") NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
MESSAGE "There was an error" VIEW-AS ALERT-BOX ERROR.
/* You will be left with a tt-record with 0 as field value */
END.
MESSAGE "After no-error" VIEW-AS ALERT-BOX.
CREATE tt.
ASSIGN tt.a = INTEGER("GOODBYE").
MESSAGE "After error" VIEW-AS ALERT-BOX.
否-UNDO
否撤消删除撤消处理。这通常是 default 的首选行为,除非您需要临时表,变量等来利用撤消处理。下面是一个非常基本的示例。
除非您确实需要撤消处理,否则最好避免。它可能会影响性能,本地磁盘写入等。它还会限制字符变量的长度等。
注意:因为这是一个更好的描述,所以从“默认”更改为“首选行为”
DEFINE VARIABLE cTxt1 AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTxt2 AS CHARACTER.
DO TRANSACTION:
ASSIGN
cTxt1 = "HELLO"
cTxt2 = "GOODBYE".
MESSAGE "Do you want to undo?"
VIEW-AS ALERT-BOX
BUTTONS YES-NO
UPDATE lAnswer AS LOGICAL.
IF lAnswer THEN
UNDO, RETRY.
END.
DISPLAY cTxt1 cTxt2.