Product SiteDocumentation Site

5.4.2.3. init


>>-init(atime,message)-----------------------------------------><

Sets up an alarm for a future time atime. At this time, the alarm object sends the message that message, a message object, specifies. (See Section 5.1.7, “The Message Class”.) The atime can a String, DateTime object, or TimeSpan object.
If atime is a DateTime object, the DateTime specifies a time when the alarm will be triggered. The DateTime must be greater than the current time.
If atime is a TimeSpan, the Alarm will be set to the current time plus the TimeSpan. The TimeSpan must not be a negative interval.
If atime is a String, you can specify this as a date and time ('hh:mm:ss') or as a number of seconds starting at the present time. If you use the date and time format, you can specify a date in the default format ('dd Mmm yyyy') after the time with a single blank separating the time and date. Leading and trailing whitespace characters are not allowed in the atime. If you do not specify a date, the Alarm uses the first future occurrence of the specified time. You can use the cancel() method to cancel a pending alarm. See Section 4.2.9, “Initialization” for more information.
The following code sets up an alarm at 5:10 p.m. on December 15, 2007. (Assume today's date/time is prior to December 15, 2007.)

Example 5.186. Class ALARM

/* Alarm Examples */

PersonalMessage=.MyMessageClass~new("Call the Bank")
msg=.message~new(PersonalMessage,"RemindMe")

time = .DateTime~fromIsoDate("2007-12-15T17:10:00.000000")

a=.alarm~new(time, msg)
exit
::class MyMessageClass public
::method init
expose inmsg
use arg inmsg
::method RemindMe
expose inmsg
say "It is now" "TIME"("C")".Please "inmsg
/* On the specified data and time, displays the following message: */
/* "It is now 5:10pm. Please Call the Bank" */

For the following example, the user uses the same code as in the preceding example to define msg, a message object to run at the specified time. The following code sets up an alarm to run the msg message object in 30 seconds from the current time:

Example 5.187. Class ALARM

a=.alarm~new(30,msg)