EventSetTimer() Question

 

Hello everyone,

I am trying to understand how the EventSetTimer() works. Hopefully, some one could address it for me.

If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?

How do you code to set the OnTimer() to run every 4-hour at a round hour like 4:00, 8:00,...(does not matter what time EA is attached)?

Thank you for helping out.

Regards,

PS: please don't judge my question, I'm new to the language.

 

aquarchitecture:

If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?

Correct

aquarchitecture:

How do you code to set the OnTimer() to run every 4-hour at a round hour like 4:00, 8:00,...(does not matter what time EA is attached)?


if (your condition)
EventSetTimer(in seconds);
 
qjol:
Correct

Thank qjol for getting back to me.

Where should I put that code? I am pretty sure NOT in OnInit(). Can you write an example code for me?

 
aquarchitecture: If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?<
EventSetTimer says "determine the frequency of the timer event" No where does it say WHEN the trigger occurs. I assume 12:40+900=12:55 etc. but it could just as well mean iTime(, PERIOD_M1,0) > time of[ EventSetTimee(x) ] + x. Don't assume.
 
put in OnTick()
 
Hai Nguyen:

Hello everyone,

I am trying to understand how the EventSetTimer() works. Hopefully, some one could address it for me.

If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?

How do you code to set the OnTimer() to run every 4-hour at a round hour like 4:00, 8:00,...(does not matter what time EA is attached)?

Thank you for helping out.

Regards,

PS: please don't judge my question, I'm new to the language.

hello,

I m new in progaming too.

 the result of function EventSetTimer() is true or false then you can use it in a IF conditions like down code:

if (EventSetTimer(900)==true);
print("It s time for your code");
this code print message every 900 seconds.
have a good time.
 
Hai Nguyen:

Hello everyone,

I am trying to understand how the EventSetTimer() works. Hopefully, some one could address it for me.

If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?

How do you code to set the OnTimer() to run every 4-hour at a round hour like 4:00, 8:00,...(does not matter what time EA is attached)?

Thank you for helping out.

Regards,

PS: please don't judge my question, I'm new to the language.

use down code, every 10 second alert a message.

void OnInit()
{
   EventSetTimer(10);
}

void OnTimer()
{
   string report="hello world"; 
   Alert(report);
}