Questions about the timer - Forum

Forum Navigation
You need to log in to create posts and topics.

Questions about the timer

Hi all

I have created a timer with autostart = false and interval = 60000.

I start manually with a pushbutton with these command ;

SetVar [DureeTimer] 120000
TimerStart "Timer1" [DureeTimer]

Code in event "expired" :

Math "([Dureetimer] - [Timer1]) / 60000" 0 [nDuree]
ConsoleLog "duree [nDuree]"
If [Timer1] >= [Dureetimer]
TimerStop "Timer1"
endif

If I check autostop = true, the code put in event "expired" is executed one time at the and of duration (2mn), I guess this is normal.

If I check autostop = false, I expect the same code to be executed every minute as indicated in the help, but it is also executed only once after 2 minutes??

The help file also says "Timer will execute repeatedly until manually stopped, the current Page is changed or the App shuts down", my timer is inside master page and started on page 2. If I navigate to page 1 and come back the timer seems always active (this is my need). 

Hi @phil78. In fact I think autostart and autostop properties have not much sense at all (except for beginners). I have always used TimerStart and TimerStop instead. Anything you put on a Master Page will work on every page the Master Page is active as if it was a "permanent" part shared among different pages.

Also be sure to check SetTimeOut, ClearTimeOut, SetInterval and ClearInterval commands for an alternative to the Timer object.

Regards.

@Luis, should I understand that it is well coded but that "expired" does not work properly?

I just tested SetInterval, but I don't understand what the variable [interval] receives
SetInterval 30000 "DisplayDuration" [interval]
in this example I got once 189 another time 191 and always the same value repeated.
On what criteria can I base myself in this case to stop with ClearInterval?

I just tested SetInterval, but I don't understand what the variable [interval] receives

@phil78 it's the variable to store your Interval. Think on it as the Interval name. You will need it to stop it later using ClearInterval.

Example:

SetInterval 1000 "mysubroutine" [myinterval]
ClearInterval [myinterval]

@Luis, should I understand that it is well coded but that "expired" does not work properly?

I have not tested your code but "Expired" event is executed each time the specified interval happens. On my tests it works quite well.

Regards.

 

Hi Luis

Ok I understand for SetInterval and ClearInterval.

But I would like you send me your timer test if it is possible, because for me there is nothing before the end and the timer variable is not known outside the timer object.

Regards

Hi @phil78, please take a look at the attached sample app.

Regards.

Uploaded files:
  • You need to login to have access to uploads.

Thank you Luis
With the example I understood where the misunderstanding came from, it's the TimerStart parameter in which I set the duration while you indicate the interval. For me it is not totally clear in the help file nor in the wording of the function.
Like this it works effectively, but what I don't understand is how it stops in autostop mode if you haven't set the duration anywhere, and why put the interval in parameter since it is already defined in the properties.

Regards