Consultor Eletrônico



Kbase P22866: ENTRY statement appears to fail when second parameter is an expression.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   30/12/2004
Status: Unverified

SYMPTOM(s):

The 4GL ENTRY statement appears to fail?

Running the following code, one may expect the value "cc,bb" to be returned but the value "aa,bb" is returned instead.

THIS-PROCEDURE:PRIVATE-DATA = "aa,bb".
ENTRY(1,THIS-PROCEDURE:PRIVATE-DATA)="cc".
MESSAGE THIS-PROCEDURE:PRIVATE-DATA
VIEW-AS ALERT-BOX INFO BUTTONS OK.

Similarly, running the following code, one may expect the value "X,b,c,d,e" to be returned but the value "a,b,c,d,e" is returned instead.

DEFINE VARIABLE c AS CHARACTER NO-UNDO INITIAL "a,b,c,d,e".

ENTRY(1,SUBSTRING(c,1,1)) = "X".
MESSAGE c
VIEW-AS ALERT-BOX INFO BUTTONS OK

CAUSE:

The second parameter of the ENTRY statement must be a list of character strings and may not be an expression involving a function, an attribute or other expression elements.

If the second parameter used is an expression then the ENTRY built-in Function and not the ENTRY assignment statement is assumed and the 4GL statement evaluates to a logical.

Thus, the code:

THIS-PROCEDURE:PRIVATE-DATA = "aa,bb".
MESSAGE ENTRY(1,THIS-PROCEDURE:PRIVATE-DATA)="cc"
VIEW-AS ALERT-BOX INFO BUTTONS OK.

would return FALSE.

while the code:

DEFINE VARIABLE c AS CHARACTER NO-UNDO INITIAL "a,b,c,d,e".

MESSAGE ENTRY(1,SUBSTRING(c,1,1)) = "a"
VIEW-AS ALERT-BOX INFO BUTTONS OK

would return TRUE.

FIX:

To modify the value of an expression like "THIS-PROCEDURE:PRIVATE-DATA" via the ENTRY statement, use an intermediate variable:


DEFINE VARIABLE cVariable AS CHARACTER NO-UNDO.

ASSIGN
THIS-PROCEDURE:PRIVATE-DATA = "aa,bb"
cVariable = THIS-PROCEDURE:PRIVATE-DATA
ENTRY(1,cVariable) = "cc"
THIS-PROCEDURE:PRIVATE-DATA = cVariable.

MESSAGE THIS-PROCEDURE:PRIVATE-DATA
VIEW-AS ALERT-BOX INFO BUTTONS OK.