alarm

Set an alarm to trigger after a specified duration.

Syntax

status = alarm ( seconds ) ;

Arguments

int seconds

Return Value

boolean status

Warnings

%BOUNDS : Invalid alarm seconds, not between 0 and 86400 seconds (1 day).

Exceptions

%ARGUMENT : Invalid arguments. Usage: status = alarm ( seconds ) ;

Description

When an alarm is triggered, the STATUS variable is set to "%ALARM". Depending on the state of the program and whether an alarm handler was specified with the on_alarm statement, the program will take the additional actions as follows:

State of HypersScript prior to alarm No handler, STATUS set to %ALARM Handler sets STATUS to TRUE condition(*) Handler sets STATUS to FALSE condition(*)
EXECUTE HyperScript terminates. HyperScript continues to execute. HyperScript terminates.
IDLE HyperScript terminates. HyperScript continues to idle. HyperScript aborts idle state, value of idle() function equals STATUS.
QUERY HyperScript terminates. HyperScript continues to wait for reply. HyperScript aborts query, value of query*() function equals STATUS.

(*) The handler must set the STATUS variable just before it exits. A handler can set a TRUE or FALSE condition in the STATUS variable such as in the following examples:

on_alarm STATUS = "$ACK" ;
H() { return "%BAD" ; } ;
on_alarm return H() ;
on_alarm continue ;  //STATUS;is $ACK
on_alarm ; /* STATUS will be "%ALARM" */ 
alarm 2 ; stat = idle() ; puts stat ;

Examples

To execute the example below, press or modify the example to try different variations.

Related Links

on_alarm