End Channel every # of days.

Hello Guys,

I was wondering how can i use the END command to End channel every # of days.It will be great if anyone can share a line of code :slightly_smiling_face:

Cheers.

at start of your program, create a global timer variable, for example:


m.timer=createobject("rotimespan")
m.timer.mark()
m.days=5

There are various ways to implement the above, for instance, if you are using a more object oriented approach to your programming, you may want to include the timer in a global object that you create at start time:


function init() as object
return {timer:createobject("rotimespan")
        days:5}
end function

You might have a function that checks the time, which you can call from within all parts of your application, for example:

function timecheck()
     if m.timer.totalseconds() > (m.numdays * 86400)
          dialog=createobject("roonelinedialog")
          dialog.settitle("time's up!")
          dialog.show()
          sleep(10000)
          dialog.close()
          end
     end if 
end function

To do this you will need to make sure all your msg=wait(time,port) statements do not block, in otherwords, use values greater than 0: for example:


while true
     msg=wait(100,port)
     timecheck()
end while