Use the $TIMER() function to set one or more asynchronous timers. As each interval expires, a record is written to a stack to notify your IMOD.
The $TIMER() function has this syntax:
Form 1:
id = $TIMER(SET,sec,stknum,[rec],[imodid])
Form 2:
id = $TIMER(CLEAR,id)
The $TIMER() function takes these arguments:
Establishes a new timer interval without affecting existing intervals.
Clears an existing interval.
Unique ID assigned by timing facility. If you are canceling an existing interval, you must specify this ID.
Number of seconds in the interval.
Number of the stack that should be posted when the interval expires.
1- to 256-byte argument placed on the stack when the interval expires. The default is TIME_EXPIRED.
IMOD that owns the stack that is being posted when interval expires.
When an interval expires, the text in rec (or TIME_EXPIRED) is written to the stack, followed by a blank and the interval ID (id) returned by the SET argument.
The $TIMER() function produces these return codes:
ARG n MISSING OR INVALID
TIMER IS NOT AVAILABLE
SYSTEM SHUTDOWN IN EFFECT
STORAGE EXHAUSTED
Example
/* Set two timers */
id1 = $timer('set',10,1,'INTERVAL_1')
id2 = $timer('set',60,1,'INTERVAL_2')
.../* start other processes */
x = wait(0,1,2) /* wait on multiple events)
if x = 1 then do
rec = pull(1)
parse var rec string id .
select
when string = 'INTERVAL_1 then call expire_1
when string = 'INTERVAL_2 then call expire_2
otherwise signal timer_error
end
end
| Copyright © 2012 CA. All rights reserved. | Tell Technical Publications how we can improve this information |