Download MetaTrader 5
To add comments, please log in or register
Sign up for MQL5.community to post your Forum topic
Pavel Soukup
559
Pavel Soukup 2016.03.07 12:30 

Section 1: (input data for script, indicator, EA)

input color clr=clrNONE;  // or extern color clr=clrNONE; declaration by user

OnStart()       // or OnInit()

Alert(clr);     // return 255,255,255


or


Section 2:

OnStart()

{

  color clr=clrNONE;  // declaraion inside

  Alert(clr);  // return clrNONE

}

My questions:

1) Why?

2) How check if user set on input color clrNONE?

   Ad Section 1) condition as: if (clr==clrNONE) is unsatisfiable. 255,255,255 (white) is always different clrNONE (value -1 by documentation MQL)

Vasyl Nosal
18217
Vasyl Nosal 2016.03.07 12:39  

use 

#property strict

and you will see. 

Pavel Soukup
559
Pavel Soukup 2016.03.07 12:56  

Here is actual test code:

Set clr_input in input dialog as clrNONE .... return clr_input=255,255,255

#property strict
#property script_show_inputs 

input color clr_input=clrRed;  // try set: clrNONE but in user´s input dialog! No in code mql4.
//+-------------------------------------+   -----+---------------------------
//| Script program start function       |        |
//+-------------------------------------+        |
void OnStart()                     //           \|/
{                                  //            V 
  Alert("clr_input=",clr_input);   // output: clr_input=255,255,255
  color clr=clrNONE;
  Alert("clr=",clr);               // output: clr=clrNONE
}
Vasyl Nosal
18217
Vasyl Nosal 2016.03.07 14:34  
Intrusting. But it works ok.
whroeder1
13641
whroeder1 2016.03.07 15:05  
endy5: 2) How check if user set on input color clrNONE?
Why do you care what color the user has set a line to? Just draw the line.
Pavel Soukup
559
Pavel Soukup 2016.03.07 18:35  
eevviill:
Intrusting. But it works ok.

Set on clrNONE in user input dialog

Message from terminal...

very interesting row: inputs: clr_input=....

Pavel Soukup
559
Pavel Soukup 2016.03.07 18:40  
WHRoeder:
endy5: 2) How check if user set on input color clrNONE?
Why do you care what color the user has set a line to? Just draw the line.

if (<user_input_set_clrNONE>) SetColorScheme_Auto()  else SetColorScheme_User();

By MT4: clrNONE is the same as 255,255,255 but in documentation is clrNONE have value "-1" ... Have I error somewhere?

/
To add comments, please log in or register