Returns a flag enum instance with the state of the indicated flag(s) toggled. In other words, the flag is unset if it was previously set, and set if it was previously unset.
A reference to a flag enum instance. The enum type (flag-enum-type) of this instance must match the type of the instance the method is invoked on.
The following example results in vReflectFlag, an instance of Progress.Reflect.Flags, with the Public flag set and the Protected flag unset:
DEFINE VARIABLE vReflectFlag AS Flags.
vReflectFlag = Flags:Protected.
/* These two lines toggle the status of the Public and
Protected flags without affecting the status of any of
the other flags in vReflectFlag. */
vReflectFlag = vReflectFlag:ToggleFlag(Flags:Public).
vReflectFlag = vReflectFlag:ToggleFlag(Flags:Protected).
You can use the bitwise XOR operator to achieve the same result. For example, replacing the last line with vReflectFlag = vReflectFlag XOR Flags:Protected also toggles the status of the Protected flag.
Notes
This method is available for all built-in flag enums, and the compiler automatically generates it for all user-defined flag enums. For example, this code excerpt uses a user-defined Permissions flag enum, initializes vPerm with the Read flag set, and then uses ToggleFlag( ) to set the Create flag, resulting in an enum instance with both the Read and Create flags set: