Page 1 of 1

script on timer?

Posted: Wed Feb 12, 2014 12:30 am
by DavJans
is there a way to run a set of code every minute without any user interaction when on a specific card?

like onMouseup but on5minuteinterval

Re: script on timer?

Posted: Wed Feb 12, 2014 12:55 am
by dave.kilroy
There are lots of ways of doing this, such as, in the script of the card of your choice:

Code: Select all

local sKeepRepeating

on openCard
    --set up the script variable to control whether the handler can be stopped later on
    put true into sKeepRepeating
    
    --make the first call to repeatingHandler
    repeatingHandler
close openCard

on repeatingHandler
    --if the script variable is true then proceed
    --otherwise if it is false this handler runs through and is not called again
    if sKeepRepeating then
        --do some stuff 
        --if you wish to stop this handler being repeatedly called 
        --you can set sKeepRepeating to false here

        --this is the 'recursion' bit - where the handler calls itself
        send repeatingHandler to me in 5 seconds
    end if
close repeatingHandler

Re: script on timer?

Posted: Wed Feb 12, 2014 1:11 am
by DavJans
Thank you so much

Re: script on timer?

Posted: Wed Feb 12, 2014 1:15 am
by dave.kilroy
A pleasure - and I'm sure others will chime in with other/better ways. What are you building?