OpenEdge 4GL Unknown Value and the LITERAL-QUESTION Attribute

December 21, 2007 · Filed Under Development · Comment 

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.

OE Architect Editor Corruption Bug Fix in SP3

November 30, 2007 · Filed Under Development · Comment 

An editor corruption issue that causes OpenEdge Architect to crash or stop responding has been fixed in the just released OpenEdge Service Pack 3.

This issue was cropping up frequently enough during heads down coding sessions to cause use of OE Architect to be a hit or miss proposition for some of us.

While more prevelant on multi-core and HT processors single-core processors are not immune.

At Solvepoint we’re long-time Eclipse users so we’re eager to see OpenEdge Architect (based on Eclipse) to be stabilized and advanced.

Reference Kbase ID P124071 and Service Pack 3 Reference ID OE00150179.