OpenEdge 4GL Unknown Value and the LITERAL-QUESTION Attribute
Sometimes a cigar is just a cigar, and sometimes a question mark is just a question mark.
You frequently need to assign character values to a buffer-field. Sometimes that value may be a question mark.
bh:BUFFER-FIELD(’c1′):BUFFER-VALUE = ‘?’.
When you query the buffer-value, Progress reports that the value is unknown.
MESSAGE
bh:BUFFER-FIELD(’c1′):BUFFER-VALUE = ‘?’
bh:BUFFER-FIELD(’c1′):BUFFER-VALUE = ?
VIEW-AS ALERT-BOX.
If this behavior is not what you intended or you need to keep the Unknown Value distinct for a “?” character, then you have a bug in your program.
How do you get Progress to treat the “?” appropriately? The trick is the LITERAL-QUESTION attribute.
When LITERAL-QUESTION = FALSE, “?” and ? will both evaluate to the unknown value.
When LITERAL-QUESTION = TRUE, “?” is a question mark, and ? is the unknown value.
bh:BUFFER-FIELD(’c1′):LITERAL-QUESTION = TRUE.
bh:BUFFER-FIELD(’c1′):BUFFER-VALUE = ‘?’.
MESSAGE bh:BUFFER-FIELD(’c1′):BUFFER-VALUE = ‘?’ VIEW-AS ALERT-BOX.
Sadly, there is no single-step way to make it always be true for all fields in a temp-table, but something like this may work for you:
FUNCTION SetLiteralQuestion RETURNS LOGICAL
( INPUT bh AS HANDLE ):
DEFINE VARIABLE i AS INTEGER NO-UNDO.
IF NOT VALID-HANDLE(bh) THEN RETURN FALSE.
IF bh:TYPE EQ ‘TEMP-TABLE’:U THEN bh = bh:DEFAULT-BUFFER-
HANDLE.
IF bh:TYPE NE ‘BUFFER’:U THEN RETURN FALSE.
DO i = bh:NUM-FIELDS TO 1 BY -1:
bh:BUFFER-FIELD(i):LITERAL-QUESTION = TRUE.
END.
RETURN TRUE.
END FUNCTION. /** SetLiteralQuestion() **/
You can then invoke the SetLiteralQuestion function using either a table-handle or a buffer-handle.
SetLiteralQuestion(TEMP-TABLE ttFoo:HANDLE).
SetLiteralQuestion(bh).
SetLiteralQuestion(INPUT BUFFER customer:HANDLE).
Since this does some looping and other processing, you’ll want to make sure you’re not calling SetLiteralQuestion() in a loop.
Comments
Leave a Reply
You must be logged in to post a comment.



