User Defined Enumeration and Structure Types

Enumerated types are encoded as a series of symbolic names as either 8 or 16 bit values. The 16 bit representation is used automatically when there are more than 255 elements in the set.

   type Color in  White, Red, Green, Blue, Yellow

Note that in addition to the values listed, the value zero is always included. An enumerated constant value is denoted with a lead dot.

   Color = .Red
   Color = 0

You can also specify a zero-based range of numbers as an enumeration. The maximum upper bound is 65535. A standard type, Bit, has a range of 0 to 1.

   type Small in 0 to 99

Structures combine a set of data elements along with optional micro and macro declarations. Like primitive types, each field is initialized unless you code a question mark for the initial value.

   type Key is Name          string,        &Initialized field
               Array[Max] = ?  word,        &Uninitialized array field
               Size => length( Name ),      &Macro declaration
               Max |= 100                   :Micro declaration

To access a field in a structure use: Variable`Field

This example declares two global variables of the type Key and shows how the fields are referenced.

   global Key,           &A variable whose name and type name are the same.
          Current  Key   :A variable whose name and type name differ.

   IF Current`Value = Key`Value:    IF the Value fields match,
      Length = Current`Size;           Get the length of the Key field.

   ELSE:                            ELSE a mismatch,
      Length = Key`Max;                Get the maximum size.
   .

Pointer Variable

Array Variable