
Quote from Phil78 on September 15, 2021, 4:08 pmHi 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"
endifIf 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 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).

Quote from luishp on September 15, 2021, 4:30 pmHi @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.
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.

Quote from Phil78 on September 15, 2021, 5:47 pm@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?
@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?

Quote from luishp on September 15, 2021, 8:11 pmI 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.
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.

Quote from Phil78 on September 16, 2021, 5:13 pmHi 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 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

Quote from luishp on September 17, 2021, 1:09 pmHi @phil78, please take a look at the attached sample app.
Regards.
Hi @phil78, please take a look at the attached sample app.
Regards.
Uploaded files:
Quote from Phil78 on September 18, 2021, 3:21 pmThank 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
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