Consultor Eletrônico



Kbase P117167: Is it possible to use the VALIDATE statement with a variable array element updated Dynamically?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   05/09/2007
Status: Verified

GOAL:

Is it possible to use the VALIDATE statement with a variable array element updated Dynamically?

GOAL:

Why VALIDATE statement is not working when it is done in a dynamic update?

FIX:

The following example will not work.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE number AS INTEGER EXTENT 3.
DEFINE VARIABLE mensaje AS CHAR INIT "The number must be grater than ZERO, thank you".
DEFINE FRAME a
number[1] label "ok1" skip
number[2] label "ok2" skip
number[3] label "ok3" SKIP WITH OVERLAY 1 COLUMN.
DO i = 1 TO 3:
UPDATE number[i]
VALIDATE(number[i] > 0, STRING(mensaje)) WITH FRAME a.
END.
Instead do the following:
DEFINE VARIABLE number AS INTEGER EXTENT 3.
DEFINE VARIABLE mensaje AS CHAR INIT "The number must be grater than ZERO, thank you".
DEFINE FRAME a
number[1] label "ok1" skip
number[2] label "ok2" skip
number[3] label "ok3" SKIP WITH OVERLAY 1 COLUMN.
UPDATE number[1]
VALIDATE(number[1] > 0, STRING(mensaje)) WITH FRAME a.
UPDATE number[2]
VALIDATE(number[2] > 0, STRING(mensaje)) WITH FRAME a.
UPDATE number[3]
VALIDATE(number[3] > 0, STRING(mensaje)) WITH FRAME a.
The VALIDATE statement cannot evaluate the expression to validate dynamically (at run time), it evaluates the expression only for static elements it knows in advance.
VALIDATE only works with known elements (Variables or fields).