Whats the simplest way of using an extern string "Yes" or "No" to activate or deactivate a void function?
- Effective Volume Indicator - monitoring the large players
- enum or switch? - switching orders for closing?
- How do you deactivate an EA (or indicator) ?
DomGilberto:
Whats the simplest way of using an extern string "Yes" or "No" to activate or deactivate a void function?
Whats the simplest way of using an extern string "Yes" or "No" to activate or deactivate a void function?
Something like this . . . off the top of my head, not tested . . .
extern string YesOrNo = ""; bool Yes = FALSE; if(YesOrNo == "YES" || YesOrNo == "Yes" || YesOrNo == "yes") Yes = TRUE; //call the function A_Function(Yes) // declare the function void A_Function(bool lYes) { if(!lYes) return; // rest of function . . . }
Yea nice one thanks (all but moving the 1 at the end of "1Yes" like so "Yes1"). How could I go about having a drop down as an extern Yes or No? As opposed to writing it in the box within the parameters? (i.e. not a string but drop-down)
DomGilberto:
Whats the simplest way of using an extern string "Yes" or "No" to activate or deactivate a void function?
Whats the simplest way of using an extern string "Yes" or "No" to activate or deactivate a void function?
I would suggest an enum (to tested!):
enum isBool { fs, // no, false tr // yes, true }; extern isBool UseFuncA = fs; extern isBool UseFuncB = tr; .. if ( UseFuncA == 1 ) x = funcA(..);
DomGilberto:
Yea nice one thanks (all but moving the 1 at the end of "1Yes" like so "Yes1"). How could I go about having a drop down as an extern Yes or No? As opposed to writing it in the box within the parameters? (i.e. not a string but drop-down)
Yea nice one thanks (all but moving the 1 at the end of "1Yes" like so "Yes1"). How could I go about having a drop down as an extern Yes or No? As opposed to writing it in the box within the parameters? (i.e. not a string but drop-down)
enum YesOrNo {No=0,Yes=1}; extern YesOrNo ActivateFunction=Yes;
Edit: sorry gooly, must have posted at the same time.
bool Yes = FALSE; if(YesOrNo == "YES" || YesOrNo == "Yes" || YesOrNo == "yes") Yes = TRUE;If must be in init.
bool Yes = FALSE; OnInit(){ Yes = YesOrNo == "YES" || YesOrNo == "Yes" || YesOrNo == "yes";
DomGilberto:
Yea nice one thanks (all but moving the 1 at the end of "1Yes" like so "Yes1"). How could I go about having a drop down as an extern Yes or No? As opposed to writing it in the box within the parameters? (i.e. not a string but drop-down)
It's an l as in Local as has been said, use an enum . . . I've not used them in mql4 . . . I have in LabVIEW though
Yea nice one thanks (all but moving the 1 at the end of "1Yes" like so "Yes1"). How could I go about having a drop down as an extern Yes or No? As opposed to writing it in the box within the parameters? (i.e. not a string but drop-down)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register