OWBasic for Pocketviewer

Home INTRO Alphabetical Index

Declaring Enumeration Types

ENUM <name>=(<constant 1>[=<value>], <constant 2>[=<value>], ...)

Enumeration types can be declared by the directive ENUM. Variables of this type can only be assigned one of the constants given at the type declaration.
If a ENUM variable shall be assigned an integer value, the integer value has to be converted explicitly:

<varname>=ENUM\<type>(<integer value>)

The values of the constants are given in numerical order. The values can also be given explicitly.
Example:

ENUM daytime_t=(MORNING=0, NOON, AFTERNOON, EVENING, NIGHT)
CONST daytimes$=("morning", "noon", "afternoon", "evening", "night")

PROC show_daytime daytime\daytime_t
 PRINT daytimes[INT(daytime)]
 IF daytime=#NIGHT THEN
  POWEROFF
 ENDIF
ENDP

show_daytime #NOON

Home INTRO Alphabetical Index