Get numerical value from Enumerator

I have an enum declared as:

E_Alarms : 
		e_Offset := 4,

Is there a way to get a numerical value from the enum Entries, so that I can use it just like a normal INT?

Enumeration have a 4 Byte Datatype and can directly used as DINT.
Does the following code match your requirement, it can also be used in Cyclic.

Use an Additional Integer Variable to which you Convert the Data.

	TestINT : INT;


	TestINT := DINT_TO_INT(e_Offset);

As a little correction to to Michaels answer. Enumerations are always internally a DINT, so you can use the numeric value directly.

In your case you would have the following values:

e_Offset := 4
e_Error1 := 5
e_Error2 := 6

Variables, or enumeration data type members are internally mapped as DINT. Their value range is determined through the DINT value range (-2147483648 … +2147483647).

1 Like

Thanks for your answers. I initially also tried this approach but probably made some other mistake. It is working now.
It’s also good to have some additional information about Enums.