Try OpenEdge Now
skip to main content
ABL Reference
Class Properties and Methods Reference : CompareTo( ) method
 

CompareTo( ) method

Compares the enum instance to another specified enum instance based on their underlying numeric values. The method returns -1, 0, or 1 depending on whether the numerical value of the enum instance is less than, equal to, or greater than the specified enum instance, respectively. If the specified enum instance is not initialized, the method returns the Unknown value (?).
Return type: INTEGER
Access: PUBLIC
Applies to: Progress.Lang.Enum class

Syntax

CompareTo ( INPUT otherEnum AS Progress.Lang.Enum )
otherEnum
A reference to a Progress.Lang.Enum instance. The enum type of this instance must be the same as the enum type of the instance the method is invoked on.
The following example compares two enum instances of type Days:
ENUM Days:
DEFINE ENUM Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday.
END ENUM.
DEFINE VARIABLE myDeliveryDay AS Days NO-UNDO.

myDeliveryDay = Days:Sunday.

IF myDeliveryDay:CompareTo(Days:Friday) = 1 THEN
MESSAGE "That is not a valid delivery day.".

Notes

*The method raises error if the two enum instances are not the same type.
*You can also use the >, <, =, <>, >=, and <= operators to perform the same type of comparison. However, the enum type must be known at compile time for use with those operators. You can use this method if you need more flexibility, because this method can compare references of type Progress.Lang.Enum.

See also

ENUM statement