Programmatically get enum value descriptions?

 

Hi,

Is it possible to get enum value descriptions programmatically? I don't mean a switch-case lookup function but a way to programmatically get the description.

Something like this: 

E.g. EnumValueToString(PERIOD_H1) => "1 hour"

 
erdah:

Hi,

Is it possible to get enum value descriptions programmatically? I don't mean a switch-case lookup function but a way to programmatically get the description.

Something like this: 

E.g. EnumValueToString(PERIOD_H1) => "1 day"

   Print(EnumToString(Period()));
 
angevoyageur:

Thanks but that 's not what I'm after.

Print(EnumToString(Period())); // => "PERIOD_H1"

 I want something like:

Print(EnumValueToString(Period())); // => "1 hour"
 
erdah:

Thanks but that 's not what I'm after.

 I want something like:

You have to program it then, there is not such thing as a description for timeframe or enum in mql5.
 
angevoyageur:
You have to program it then, there is not such thing as a description for timeframe or enum in mql5.

The comment after each enum value is shown instead of the enum value itself in some situations in the terminal and the IDE. For example if you declare ENUM_POS_TYPE as an input parameter to your EA you will be presented with a listbox of Volume and Risk Percentage instead of POS_TYPE_VOLUME and POS_TYPE_RISK.

enum ENUM_POS_TYPE {
  POS_TYPE_VOLUME,  // Volume
  POS_TYPE_RISK     // Risk Percentage
};

I wonder if that data is also accessible from within MQL5.

 
erdah:

The comment after each enum value is shown instead of the enum value itself in some situations in the terminal and the IDE. For example if you declare ENUM_POS_TYPE as an input parameter to your EA you will be presented with a listbox of Volume and Risk Percentage instead of POS_TYPE_VOLUME and POS_TYPE_RISK.

I wonder if that data is also accessible from within MQL5.

I know, but unfortunately not. Of course, it would be possible technically, but Metaquotes doesn't provide a way to do that currently. You can try to make the suggestion to ServiceDesk.
 
Alain Verleyen #:
I know, but unfortunately not. Of course, it would be possible technically, but Metaquotes doesn't provide a way to do that currently. You can try to make the suggestion to ServiceDesk.

Do they provide such a beast yet, 10+ years later? I'm looking to do exactly the same thing as I am populating a list of fonts and am not interested in the numeric value of the enum, I'm interested in populating drop-downs with the descriptor (the font name) to have it dynamically change the font, rather than having to type the font into a string input.

Christian