# How to translate the integer returned by functions to enum?

790

For example, if you use the functions "SymbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS)" and "MarketInfo(Symbol(),MODE_SWAPTYPE)", you'll get the integer that is not easy to understand.

Is there a existing function or an easy way to translate the integer back to the enum identifier or description that is easy to understand?

Please don't suggest to add code to translate them as you know this post is made for better solution.

17994

 If you know the enumeration and you do know what RO3D returns. ```ENUM_TIMEFRAMES tf = (ENUM_TIMEFRAMES) _Period; ENUM_TIMEFRAMES tf = ENUM_TIMEFRAMES(_Period);``` For Swap type there is no enumeration; make up one. swap calculation method. 0 - in points; 1 - in the symbol base currency; 2 - by interest; 3 - in the margin currency
839

I am lost as to why you wouldn't just use code that made use of the Enum list as that is what it is there for, at least I thought it was, to save this type of coding gymnastics from being necessary.
17994

JD4: I am lost as to why you wouldn't just use code that made use of the Enum

The question was "symbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS)" and "MarketInfo(Symbol(),MODE_SWAPTYPE)" The first returns an integer, the second a double. How are you going to use a "Enum list?"

Does this make sense to you?

```int anInt = symbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS);
if( anInt == FRIDAY ) ?```
or does this fit better.
```ENUM_DAY_OF_WEEK RO3D = ENUM_DAY_OF_WEEK ( symbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS) );
if( RO3D == FRIDAY ) ?```
839

WHRoeder:

The question was "symbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS)" and "MarketInfo(Symbol(),MODE_SWAPTYPE)" The first returns an integer, the second a double. How are you going to use a "Enum list?"

Does this make sense to you?

or does this fit better.
By not using code that requires those conversions in the first place, but by making use of code that uses the enum list directly instead.  From my understanding, Enumerated lists in programming were specifically created to allow clearer program code by giving possible choices specific relevant names, and not having to go through and code "Ok, choice 1 does this, choice 2 does this other function, choice 3 means you can do this other long block of code," and so on, and then having to go back through and look at your code to figure out what specific item you were trying to identify would tell the program to do which action.
3330

JD4:
By not using code that requires those conversions in the first place, but by making use of code that uses the enum list directly instead.  From my understanding, Enumerated lists in programming were specifically created to allow clearer program code by giving possible choices specific relevant names, and not having to go through and code "Ok, choice 1 does this, choice 2 does this other function, choice 3 means you can do this other long block of code," and so on, and then having to go back through and look at your code to figure out what specific item you were trying to identify would tell the program to do which action.
I am afraid you do not understand that the enum is a type, it is not a list. There is no enumeration list in MQL.
Moderator
12292

For the other, if it's just to make the code easier to read, you could use #define

```  #define  POINTS 0
#define  BASE_CURRENCY 1
#define  INTEREST 2
#define  MARGIN_CURRENCY 3```
839

Ovo:
I am afraid you do not understand that the enum is a type, it is not a list. There is no enumeration list in MQL.

https://docs.mql4.com/basis/types/integer/enumeration shows this to be true, but it also shows how to create a list of items when using that type.  When used in conjunction with the Switch operator, it allows control branching based on constants, which the list within the enum type statement are created as.  I am sure that this is not the only possible use for an enum list, but it shows that it is not needed to use the integer value related to each enum list item.  The enum part refers to the specific title or name of the list, but within that list is still identifiers associated with that enumerated type.

I am seeing the items inside that header as an enumerated list, which is what I thought OP was asking about.  Or do they want the integer that is associated with the specific enum title of the list?