The problem of ?

One of the most difficult to get used to ‘features’ of progress 4GL:

The progress 4GL logical variable can take 3 values: Apart from the standard values - yes and no, 4GL logical expressions can also evaluate to the value: ‘?’ .

Just to make sure I got that through, “Question mark” - ‘?’ is a valid value that can be assigned to a Progress 4GL logical variable.


def var a as logical.
a = ?. /* Assigning the value of a to ? */

disp "First if : ".
if a then
   disp "then block executed" skip .
else
   disp "else block executed" skip.

disp "Second if : ".
if not a then
   disp "then block executed" skip .
else
   disp "else block executed" skip.

disp "third if".
if a or not a then
   disp "then block executed" skip .
else
   disp "else block executed" skip.

The output of the above program is:


First if :
  else block executed
Second if :
  else block executed
third if
  else block executed

With 4GL logical variables,

  1. not yes evaluates to no,
  2. not no evaluates to yes,
  3. not ? evalutates to ?

So it ends up that if “a” is a logical expression that evaluates to ‘?’, then it turns out that ‘a’ is equal to ‘not a’. When a logical expression in an if-then-else statement evaluates to ?, it is always treated as false and the else block of the statement is executed.

Wierd, huh? This little anomoly is often the cause some of the most difficult to track bugs with the handling of function returns.

Leave a Reply