I am the beginner for progress 4GL language and I'd like to know about the difference between NO-UNDO and NO-ERROR in progress 4gl language.
what is the meaning of NO-UNDO on define variable in progress 4gl?
Asked Answered
NO-ERROR
No error supresses errors in the runtime and hands the responsibility for those error and their handing to you, the developer.
/*
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 removes undo handling. This is usually the default preferred behavior unless you need temp-tables, variables etc to utilize undo-handling. A very basic example below.
Unless you really need undo handling it better be avoided. It might effect performance, local disk writes etc. It also limit the length of character variables etc.
Note: changed from "default" to "preferred behavior" as this is a better description
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.
To clarify a bit... NO-UNDO is not the default as in "don't type anything and you will get NO-UNDO behaviour". It is the "default" in the sense that it is almost universally added to variable and temp-table definitions because it is the behavior that most programmers usually want. A missing NO-UNDO is almost always a sign of a lazy programmer that made a mistake. That mistake may not be obviously harmful and it the bad effects may not be easily noticed. –
Pagano
@TomBascom I agree 100% –
Selfindulgent
Wha is DYNAMIC-FUNCTION in progress 4gl?..pls explain with small program –
Relay
@Thirumalai Post a real question instead. This is not the correct place... –
Selfindulgent
It seems like if progress can make something more work and / or over complicated, especially if it flies in the face of what everyone else is doing in the industry, they'll do it. –
Orling
© 2022 - 2024 — McMap. All rights reserved.