Start() vs OnTimer()

 

Hi all,


I'm not used to OnTimer() however, the EA refreshes every 2 minutes given by  EventSetTimer(60*2);


I would like to modify this EA, but it seems not working as usual:

Example

   if(TimeCurrent()>0) { bool test = true;} else{ test = false; }

If I do this, I got an error: "Test - Undeclared identifier"


So i have to do this:

   if(TimeCurrent()>0) { bool test = true;} else{ bool test = false; }

=> This is really weird.


I tried to add the Start()... but I got the same error?


While if i do this into any other EA... it works fine:

   if(TimeCurrent()>0) { bool test = true;} else{ test = false; }



Please help


Cheers

 

Declare the bool outside of {} if you are going to reference it in more than one{}

 

bool test;

if(TimeCurrent()>0) { test = true;} else{ test = false; }
 
bool test;

if(TimeCurrent()>0) { test = true;} else{ test = false; }
Just declare it on global.
 
deysmacro:
Just declare it on global.
Thx : )
Reason: