donderdag 5 augustus 2010

Outputting the Name of an Enum element, instead of its Label

Example:

Enum WorkTimeControl has 3 elements:

Name - Label - EnumValue: (labels are in Dutch)
Open - Openen - 0
Closed - Afgesloten - 1
UseBasic - Basiskalender - 2


We define a variable:
WorkTimeControl workTimeControl = WorkTimeControl::Closed;

This code will render the Label of the element:
info(strfmt("%1", workTimeControl));
output = Afgesloten

This code will render the Name of the element:
info(strfmt("%1", enum2symbol(enumnum(WorkTimeControl), workTimeControl)));
output = Closed

1 opmerking: