Get numerical value from Enumerator

I have an enum declared as:

E_Alarms : 
		(
		e_Offset := 4,
		e_Error1:,
		e_Error2
		);

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.

VAR
	TestINT : INT;
END_VAR

PROGRAM _INIT

	TestINT := DINT_TO_INT(e_Offset);
		 
END_PROGRAM

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).
https://help.br-automation.com/#/en/4/programming%2Fdatatypes%2Fprogrammingmodel_datatypes_derived_enums.html

2 Likes

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.