PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Declaring enumerations
  • Passing an enumeration in parameter to a procedure
  • Special cases
  • Extension of enumeration
  • Creating aliases in an enumeration
  • Associated values
  • Associated properties
  • Available WLanguage functions
  • Limits
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
An enumeration is a set of values. An Enumeration variable or parameter can only be assigned with a value of the enumeration.
Versions 21 and later
Universal Windows 10 App The Enumeration type is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App The Enumeration type is now available in Universal Windows 10 App mode.
Universal Windows 10 App The Enumeration type is now available in Universal Windows 10 App mode.
Versions 23 and later
Java The Enumeration type is now available for the Java applications.
New in version 23
Java The Enumeration type is now available for the Java applications.
Java The Enumeration type is now available for the Java applications.
Example
// Declaration code
// Declare an enumeration
RobotType is Enumération
Walk
Stopped
InMaintenance
OutOfOrder
END
// Declare an Enumeration variable
Post1 is RobotType
// Assign the variable
Post1 = Walk
// Post1 = 1 // Displays a compilation error
// Post1 = "Walk" // Displays a compilation error
Syntax

Declaring an enumeration Hide the details

<Enumeration Name> is Enumeration
   <Enumeration Values>
END
<Enumeration Name>:
Name of enumeration to declare
<Enumeration Values>:
Different values that can be taken by the enumeration.
<END>:
End of declaration.

Declaring an Enumeration variable Hide the details

<Variable Name> is <Enumeration Name>
<Variable Name>:
Name of Enumeration variable to declare.
<Enumeration Name>:
Name of enumeration that was declared beforehand. The default enumeration value corresponds to the first enumeration value.
Remarks

Declaring enumerations

An enumeration must be declared in:
  • The initialization code of project in order to be used in all the processes of the project (code of project, code of windows, code of controls, procedures, ...).
  • The declaration code of global variables of a window in order to be used in all the processes of the window (code of window, code of controls found in the window, local procedures, ...).
  • The opening code of a report in order to be used in all the processes of the report (code of the report, code of controls found in the report, local procedures, ...).
  • The declaration code of a class in order to be used in the class.
    • To access this enumeration from a class method, use the following syntax:
      "::<Enumeration Name>"
    • To access this enumeration from a code external to the class, use the following syntax:
      "<Class Name>::<Enumeration Name>"
  • The declaration code of sets of procedures in order to be used in all the procedures of the set.
Note: An enumeration is always global:
  • to a project,
  • to a window,
  • to a report,
  • to a class.

Passing an enumeration in parameter to a procedure

An Enumeration variable can be passed in parameter to a procedure. To do so, use the following syntax:
<Procedure Name>(<Name of Enumeration Variable>)
For example:
// Procedure with an Enumeration parameter
PROCEDURE OperatingMode(p is RobotType)

// Calls with an Enumeration parameter
OperatingMode(Walk)
OperatingMode(1) // Displays a compilation error
OperatingMode("A") // Displays a compilation error

Special cases

  • Assisted input: The assisted input for an enumeration parameter proposes the different enumeration values.
  • Order of values: The <, <=, >, >= operators are available for the enumerations as well as the automatic sort operations (ArraySort, ArraySeek, ...). The order of values in the enumeration is the order in which the values are declared.
    Example:
    // Declaration code
    // Declare an enumeration
    RobotType is Enumération
    Walk
    Stopped
    InMaintenance
    OutOfOrder
    END

    // Declare an Enumeration variable
    Post1 is RobotType
    // Assign the variable
    Post1 = Walk

    ...

    IF Post1>Stopped THEN
    Info("The robot encounters a problem")
    END

Extension of enumeration

An enumeration can extend the values of one or more other enumerations by taking the values of this ones and by adding new values.
The following syntax is used:
<Enumeration Name> is Enumeration
   [Base Enumeration]
   <Additional Values of Enumeration>
END
where:
  • Enumeration Name: Name of enumeration that was declared beforehand.
  • Base Enumeration: Name of base enumeration to use.
  • Additional Values of Enumeration: Additional values that will be taken into account in the enumeration.
Example:
// Declaration code
// Declare an enumeration
RobotType is Enumération
Walk
Stopped
InMaintenance
OutOfOrder
END

AdvancedRobotType is Enumération
[RobotType]
InLoop
END
Assigning an extended value in a base enumeration is not allowed.

Creating aliases in an enumeration

You have the ability to declare aliases to insure a temporary compatibility for example.
The following syntax is used:
<Enumeration Name> is Enumeration
<Value 1 of Enumeration>
<Value 2 of Enumeration>
<Value 3 of Enumeration> = <Value 1 of Enumeration>
END
Example:
// Declaration code
// Declare an enumeration
RobotType is Enumération
Walk
Stopped
InMaintenance
OutOfOrder
// Declare the temporary aliases
Maintenance = InMaintenance
Breakdown = OutOfOrder
END

Associated values

In WLanguage, a constant value of simple type can be associated with each value of an enumeration. This value is associated with the enumeration value in the enumeration declaration.
// Declare the enumeration with associated values
RobotType is Enumération
Walk = "Running the robot"
Stopped = "Robot stopped"
InMaintenance = "Robot under maintenance"
OutOfOrder = "Robot breakdown"
END
Then, you will have the ability to read the associated value of an Enumeration variable via ..Value.
// Access to the associated value
e is RobotType
RobotMessage is string = e..Value
The associated value has no incidence on the other behaviors of enumerations. Especially if the sort order is identical to the declaration order of values in the enumeration.

Associated properties

The following properties are associated with the Enumeration variables:
NameAllows you to find out the name of an Enumeration variable.
ValueAllows you to find out the associated value of an Enumeration variable.
Versions 19 and later

Available WLanguage functions

An enumeration can be stored in a HFSQL item or in another file format. Depending on your requirements, you can store the enumeration name (..Name) or value (..Value).
The following WLanguage functions allow you to find out the characteristics of a stored enumeration:
Versions 19 and later
EnumerationCheckName
New in version 19
EnumerationCheckName
EnumerationCheckName
Checks whether an enumeration value known by its name is valid.
Versions 19 and later
EnumerationCheckValue
New in version 19
EnumerationCheckValue
EnumerationCheckValue
Checks whether an enumeration value known by its associated value is valid.
Versions 19 and later
EnumerationFromName
New in version 19
EnumerationFromName
EnumerationFromName
Returns an enumeration value known by its name.
Versions 19 and later
EnumerationFromValue
New in version 19
EnumerationFromValue
EnumerationFromValue
Returns an enumeration value known by its associated value.
New in version 19

Available WLanguage functions

An enumeration can be stored in a HFSQL item or in another file format. Depending on your requirements, you can store the enumeration name (..Name) or value (..Value).
The following WLanguage functions allow you to find out the characteristics of a stored enumeration:
Versions 19 and later
EnumerationCheckName
New in version 19
EnumerationCheckName
EnumerationCheckName
Checks whether an enumeration value known by its name is valid.
Versions 19 and later
EnumerationCheckValue
New in version 19
EnumerationCheckValue
EnumerationCheckValue
Checks whether an enumeration value known by its associated value is valid.
Versions 19 and later
EnumerationFromName
New in version 19
EnumerationFromName
EnumerationFromName
Returns an enumeration value known by its name.
Versions 19 and later
EnumerationFromValue
New in version 19
EnumerationFromValue
EnumerationFromValue
Returns an enumeration value known by its associated value.

Available WLanguage functions

An enumeration can be stored in a HFSQL item or in another file format. Depending on your requirements, you can store the enumeration name (..Name) or value (..Value).
The following WLanguage functions allow you to find out the characteristics of a stored enumeration:
Versions 19 and later
EnumerationCheckName
New in version 19
EnumerationCheckName
EnumerationCheckName
Checks whether an enumeration value known by its name is valid.
Versions 19 and later
EnumerationCheckValue
New in version 19
EnumerationCheckValue
EnumerationCheckValue
Checks whether an enumeration value known by its associated value is valid.
Versions 19 and later
EnumerationFromName
New in version 19
EnumerationFromName
EnumerationFromName
Returns an enumeration value known by its name.
Versions 19 and later
EnumerationFromValue
New in version 19
EnumerationFromValue
EnumerationFromValue
Returns an enumeration value known by its associated value.

Limits

The enumerations are not available in dynamic compilation.
Minimum version required
  • Version 18
This page is also available for…
Comments
Click [Add] to post a comment