Implementing 4GL Claims

What is the best way to implement claims using Progress 4GL or WebSpeed?

+3
source share
3 answers

After some consideration here is my solution to the problem. It works on the assumption that the propath of the development environment is different from the test and production environments, and the code is always recompiled for testing or production:

&IF PROPATH MATCHES '*development*' &THEN 
&SCOPED-DEFINE ASSERTION   {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} ~
{11} {12} {13} {14} {15} {16} {17} {18} {19} {20} ~
{21} {22} {23} {24} {25} {26} {27} {28} {29} {30} ~
{31} {32} {33} {34} {35} {36} {37} {38} {39} {40} ~
{41} {42} {43} {44} {45} {46} {47} {48} {49} {50} ~
{51} {52} {53} {54} {55} {56} {57} {58} {59} {60} ~
{61} {62} {63} {64} {65} {66} {67} {68} {69} {70} ~
{71} {72} {73} {74} {75} {76} {77} {78} {79} {80} 


 IF NOT ({&ASSERTION}) THEN 
     MESSAGE "Failed assertion {&ASSERTION} in" PROGRAM-NAME(1).

 IF ({&ASSERTION}) = ? THEN 
     MESSAGE "Unknown value as a result of assertion {&ASSERTION} in" 
              PROGRAM-NAME(1).

&ENDIF

The code is designed to prevent any side effects and works equally well in any runtime environment (GUI or ChUI, WebSpeed, AppServer, package, etc.).

1) Save the code as a file named "assert" (without any extension).

2) , PROPATH.

3) :

{assert valid-handle(hProc)}
{assert i > 0 and i <= 100}
{assert cExtra begins ‘opt’}  /* note the single quotes */
{assert dtEnd > = dtStart}

, , include , :

&SCOPED-DEFINE ASSERTION   {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} ~
{11} {12} {13} {14} {15} {16} {17} {18} {19} {20} ~
{21} {22} {23} {24} {25} {26} {27} {28} {29} {30} ~
{31} {32} {33} {34} {35} {36} {37} {38} {39} {40} ~
{41} {42} {43} {44} {45} {46} {47} {48} {49} {50} ~
{51} {52} {53} {54} {55} {56} {57} {58} {59} {60} ~
{61} {62} {63} {64} {65} {66} {67} {68} {69} {70} ~
{71} {72} {73} {74} {75} {76} {77} {78} {79} {80} 


 IF NOT ({&ASSERTION}) THEN 
     MESSAGE "Failed assertion {&ASSERTION} in" PROGRAM-NAME(1).

 IF ({&ASSERTION}) = ? THEN 
     MESSAGE "Unknown value as a result of assertion {&ASSERTION} in" 
              PROGRAM-NAME(1).

, {assert}.

+3

Progress , :

IF NOT <assertion> THEN
RUN assertionFailed.p.

assertionFailed.p , .

+1

, , , , . - , include. , , debugalert.i . assert.i , , , , , ..

To set up a statement, you simply follow the format {assert.i & condition =}


/ * assert.i * / {debugalert.i}

& IF DEFINED (DEBUGALERT) <> 0 & THEN

IF NOT {AND CONDITION} THEN DO:

MESSAGE THIS-PROCEDURE:FILENAME "ERROR...{&CONDITION}" 
    VIEW-AS ALERT-BOX.
/* add code to email message etc.. or stop */

END.

& Endif


/ * debugalert.i in a test or development environment, to disable claims, delete that statement * /

& GLOBAL-DEFINE DEBUGALERT


/ * In your test code, you simply do the following: / / test statement * /

DEF VAR h_ct AS INT NO-UNDO INIT 10.

{assert.i & CONDITION = "h_ct = 8"}

+1
source

Source: https://habr.com/ru/post/1707473/


All Articles