Skip to main content

ENUM

ENUM( [ type ,] name [=value] [ , name [=value] ... ] )

typeThe numeric value type of the values. If omitted, defaults to UNSIGNED4.
nameThe label of the enumerated value.
valueThe numeric value to associate with the name. If omitted, the value is the previous value plus one (1). If all values are omitted, the enumeration starts with one (1).

The ENUM declaration specifies constant values to make code more readable.

Example:

GenderEnum := ENUM(UNSIGNED1,Male,Female,Either,Unknown);
        //values are 1, 2, 3, 4
      
Pflg := ENUM(None=0,Dead=1,Foreign=2,Terrorist=4,Wanted=Terrorist*2);
        //values are 0, 1, 2, 4, 8
namesRecord := RECORD
  STRING20 surname;
  STRING10 forename;
  GenderEnum gender;
  INTEGER2 age := 25;
END;
       
namesTable2 := DATASET([{'Foreman','George',GenderEnum.Male,Pflg.Foreign},
                        {'Bin','O',GenderEnum.Male,Pflg.Foreign+Pflg.Terrorist+Pflg.Wanted}
                       ], namesRecord);
OUTPUT(namesTable2);
        
myModule(UNSIGNED4 baseError, STRING x) := MODULE
  EXPORT ErrCode := ENUM( ErrorBase = baseError,
                          ErrNoActiveTable,
                          ErrNoActiveSystem,
                          ErrFatal,
                          ErrLast);
  EXPORT reportX := FAIL(ErrCode.ErrNoActiveTable,'No ActiveTable in ' + x);
END;
       
myModule(100, 'Call1').reportX;
myModule(300, 'Call2').reportX;