Player APIs (BrightScript & Ja...
...
Object Reference
Date and Time Objects

roTimer

13min
this object allows the script to trigger events at a specific date/time or during specified intervals events are triggered by delivering rotimerevent objects to the specified message port the javascript equivalent is settimeout()/ setinterval() iftimer settime(hour as integer, minute as integer, second as integer, millisecond as integer) as void sets the time for the event to trigger in general, if a value is 1, then it is a wildcard and will cause the event to trigger every time the rest of the specification matches if there are no wildcards, then the timer will trigger only once when the specified time occurs periodic timers that fire every second are not supported the seconds and milliseconds parameters must be zero if there are any wildcards elsewhere settime(a as integer, b as integer, c as integer) setdate(year as integer, month as integer, day as integer) as void sets the date for the event to trigger in general, if a value is 1, then it is a wildcard and will cause the event to trigger every time the rest of the specification matches if there are no wildcards, then the timer will trigger only once when the specified date/time occurs setdayofweek(day of week as integer) as void sets the day of week for the event to trigger in general, if a value is 1, then it is a wildcard and will cause the event to trigger every time the rest of the specification matches if there are no wildcards, then the timer will trigger only once when the specified date/time occurs it is possible, using a combination of setdate() and setdayofweek() calls, to specify invalid combinations that will never occur if specifications include any wildcard, then the second and millisecond specifications must be zero; events will be raised at most once per minute near the whole minute setdatetime(date time as rodatetime) as void sets the time when you wish the event to trigger from an rodatetime object it is not possible to set wildcards using this method start() as boolean starts the timer based on the current values specified using the above functions stop() as void stops the timer setelapsed(seconds as integer, milliseconds as integer) configures a timer to trigger once the specified time period has elapsed unlike the absolute timer methods above, changes to the system clock will not affect the period of the setelapsed() timer ifmessageport setport(port as romessageport) as void posts messages of type rotimerevent to the attached message port ifuserdata setuserdata(user data as object) sets the user data that will be returned when events are raised getuserdata() as object returns the user data that has previously been set via setuserdata() it will return invalid if no data has been set ifidentity getidentity() as integer returns a unique number that can be used to identify when events originate from this object the ifidentity interface has been deprecated we recommend using the ifuserdata interface instead examples this script uses the setelapsed() method to create a timer that triggers every 30 seconds sub main() mp = createobject("romessageport") timer = createobject("rotimer") timer setport(mp) timer setelapsed(30, 0) print "start at "; uptime(0) timer start() while true ev = mp waitmessage(0) if type(ev) = "rotimerevent" then print "timer event received at "; uptime(0) timer start() else print "another event arrived "; type(ev) end if end while end sub this script creates a timer that triggers every minute using wildcards in the timer spec st=createobject("rosystemtime") timer=createobject("rotimer") mp=createobject("romessageport") timer setport(mp) timer setdate( 1, 1, 1) timer settime( 1, 1, 0, 0) timer start() while true ev = wait(0, mp) if (type(ev) = "rotimerevent") then print "timer event received" else print "unexpected event received" endif endwhile this script creates a timer that triggers once at a specific date/time timer=createobject("rotimer") mp=createobject("romessageport") timer setport(mp) timer setdate(2008, 11, 1) timer settime(0, 0, 0, 0) timer start() while true ev = wait(0, mp) if (type(ev) = "rotimerevent") then print "timer event received" else print "unexpected event received" endif endwhile