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:
|
SET |
Establishes a new timer interval without affecting existing intervals. |
|
CLEAR |
Clears an existing interval. |
|
id |
Unique ID assigned by timing facility. If you are canceling an existing interval, you must specify this ID. |
|
sec |
Number of seconds in the interval. |
|
stknum |
Number of the stack that should be posted when the interval expires. |
|
rec |
1- to 256-byte argument placed on the stack when the interval expires. The default is TIME_EXPIRED. |
|
imodid |
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:
101 - 105 ARG n MISSING OR INVALID
121 TIMER IS NOT AVAILABLE
122 SYSTEM SHUTDOWN IN EFFECT
123 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 © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |