There is a way to do this?
I need repeat a proccess in every 40 minutes, but i don't have the exactly total time spent in my repeat cycles.
I need something like this:
let>loopTime=0
let>totalTime=0
let>x=0
label>start
repeat>x
count_time_function
actions
let>x=x+1
count_time_function_end,%loopTime%
let>totalTime=totaTime+loopTime
until>x=5
wait>2400-totalTime
goto>start
Thanks in advance.
Count time spent in a repeat cycle.
Moderators: Dorian (MJT support), JRL
Re: Count time spent in a repeat cycle.
Hi, If I understand it correctly then you want to loop 5 times and than wait until 40 minutes have passed since the process started, and then start again? In that case you do not have to keep track of the time in each loop, just the time since the process started (I assume the 5 loops finish within the 40 minutes so there is no running conflict).
Under the tab "Run When" you can set your script to run every 40 minutes, which would be a simple solution.
If you want to do it in the script like you tried to, then there are many possibilities, one example would be something like the example below. To define when it should stop then you can eg use Timer> which gives the time since the script started, or add a counter for total number of iterations, or GetTime> for current time.
Hope it helps.
Under the tab "Run When" you can set your script to run every 40 minutes, which would be a simple solution.
If you want to do it in the script like you tried to, then there are many possibilities, one example would be something like the example below. To define when it should stop then you can eg use Timer> which gives the time since the script started, or add a counter for total number of iterations, or GetTime> for current time.
Hope it helps.
Code: Select all
Let>timeDiff=0
//Intervall in minutes
Let>timeIntervall=40
Label>start
Timer>t1
let>x=0
label>start
repeat>x
//your actions
Let>x=x+1
until>x=5
While>timeDiff<{%timeIntervall%*60*1000}
Timer>t2
Let>timeDiff=%t2%-%t1%
Wait>0.1
EndWhile
Let>timeDiff=0
Goto>start
Re: Count time spent in a repeat cycle.
Hello!
Sorry for the delay to post here.
Works fine in my project!
Sorry for the delay to post here.
Works fine in my project!