4gl 中定义变量的 NO-UNDO 是什么意思?

what is the meaning of NO-UNDO on define variable in progress 4gl?

我是 progress 4GL 语言的初学者,我想知道 NO-UNDO 和 NO-ERROR in progress 4gl 语言的区别。

没有错误

没有错误会抑制运行时中的错误,并将这些错误的责任交给您,开发人员。

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

NO-UNDO

No-undo 删除撤消处理。这通常是 default 首选行为,除非您需要临时表、变量等来使用撤消处理。下面是一个非常基本的例子。

除非你真的需要撤消处理,否则最好避免。它可能会影响性能、本地磁盘写入等。它还会限制字符变量的长度等。

注意:从 "default" 更改为 "preferred behavior" 因为这是更好的描述

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.