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

IsFlagSet( ) method

Indicates whether the enum instance has the specified flag(s) set.
Return type: LOGICAL
Access: PUBLIC
Applies to: Progress.Lang.FlagsEnum class

Syntax

IsFlagSet ( INPUT flags AS Progress.Lang.FlagsEnum )
flags
A reference to a Progress.Lang.FlagsEnum instance with one or more flags set. A runtime error will be generated if the underlying value of flag is 0. See the Notes for more information.
This method, invoked on thisInstance, is equivalent to evaluating the following expression:
(thisInstance AND flags = flags)
This means that if flags has multiple flags set, the method returns TRUE only if all the flags in flags are set in the enum instance. For example:
ENUM Permission:
DEFINE ENUM None = 0
Read
Write
ReadWrite = Read,Write
Create
Delete.
END ENUM.
DEFINE VARIABLE myPermission AS Permission NO-UNDO.
DEFINE VARIABLE lRret AS LOGICAL NO-UNDO.

myPermission = Permission:Read.

/* Returns TRUE. */
lRet = myPermission:IsFlagSet(Permission:Read).

/* Returns FALSE because Write is not set in myPermission. */
lRet = myPermission:IsFlagSet(Permission:ReadWrite).

/* Returns FALSE because the method is passed both
the Read and Write flags because of the bitwise OR,
but Write is not set in myPermission. */
lRet = myPermission:IsFlagSet(Permission:Read OR Permission:Write).

Notes

*The method raises error if the two enum instances are not the same type.
*Because IsFlagSet() cannot be passed an enum instance with an underlying value of 0, you must check for that case before using the method, using the EQ (=) or NE (<>) operators or the Equals() method, for example. Using the Permission enum from above, the following example checks that the user's permission level, myPermission, matches the permission level needed, neededPermissions, to perform an operation. The code checks to make sure neededPermissions is not Permission:None first, before invoking IsFlagSet():
DEFINE VARIABLE neededPermissions AS Permission NO-UNDO.
DEFINE VARIABLE myPermission AS Permission NO-UNDO.

...

myPermission = Permission:Read.

IF (neededPermissions NE Permission:None) OR
(NOT myPermission:IsFlagSet(neededPermissions)) THEN
MESSAGE "You do not have permission for this operation.".
END.

See also

ENUM statement