CreateObject To Display The Value of an enum?

 

Title pretty much says it all. How do I display on chart which day is selected with create object? Just throwing the variable name in there like so shows as '0' on chart.

CreateObject("2",day,15,55+inc);
enum day
  {
   Sunday,
   Monday,
   Tuesday,
   Wednesday,
   Thursday,
   Friday,
   Saturday
  };
 

enum day doesn't have a value does it? Unless value is re-assigned, Sunday will be value 0,Monday 1 etc

enum day
  {
   Sunday,
   Monday,
   Tuesday,
   Wednesday,
   Thursday,
   Friday,
   Saturday
  };

Change them around

enum day
  {
   Saturday,
   Friday,
   Thursday,
   Wednesday,
   Tuesday,
   Monday,
   Sunday
  };

and then Saturday will be 0, Friday 1 etc

 

I think he wants to display a chosen day like a string there is probably a way, but the documentation on using enums is true to form ...

I would like to know what is the point of gouping them in a named set.

 
 

OK after hacking at that with a script I think I got it now. Probably this description is technically wrong but for all intents it seems to be, creating the enum days set is kinda like defining a new data type, so you can declare a new variable of the days type .... then you could use it in EnumToString() ... You might be able to pass day directly to the create function I'm not sure about all that though.

enum days
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
};

days day = 4;

Print(EnumToString(day));  //prints Thursday




 
honest_knave:
EnumToString

SDC:

OK after hacking at that with a script I think I got it now. Probably this description is technically wrong but for all intents it seems to be, creating the enum days set is kinda like defining a new data type, so you can declare a new variable of the days type .... then you could use it in EnumToString() ... You might be able to pass day directly to the create function I'm not sure about all that though.


Thanks,

I've learnt something new there :)

 
Yeah. Got one undocumented tricks. XD
 
GumRai:


Thanks,

I've learnt something new there :)

A new one probably : there is no need to create a new enum for days, it's already existing.

ENUM_DAY_OF_WEEK mylearningday=FRIDAY;
Print("My learning day is ",EnumToString(mylearningday));

 
angevoyageur:

A new one probably : there is no need to create a new enum for days, it's already existing.

I what I did correct or is that an undocumented thing that might not work in the future ?
 
SDC: I what I did correct or is that an undocumented thing that might not work in the future ?
Why create a new one that is identical to an existing one? You can't use yours with TimeDayOfWeek unless you write conversion routines between your days and enum_day_of_week. Etc.
 
SDC:
I what I did correct or is that an undocumented thing that might not work in the future ?
What you did is perfectly correct, but as WHRoeder said, not needed for working with days. By the way i don't think you are using something undocumented.
Reason: