|Command||basic.%alarm C Function/BASIC Program
Applicable release versions: AP/Unix
|Category||BASIC Program (486)|
|Description||instructs the alarm clock of the calling process to send the signal "SIGALRM" to the calling process after the number of seconds specified in "number".
The default alarm handler is null (i.e.: it just interrupts the process). If "number" is 0, any previously made alarm request is canceled. If a user-written built-in function changes the alarm signal handler, it remains in effect, even if the Pick/BASIC program terminates, until the process is disconnected from the virtual machine.
The alarm signal handler can be assigned to any Pick command using the (TCL) "trap" command.
To differentiate between an alarm and another interrupt, the FlashBASIC or Pick/BASIC program may have to check the time. See the example below.
* Set a timer alarmend=time()+3 %alarm( 3 ) * Read from device n=%read(fd, buffer, BUFSIZE) if n<0 and system(0)=EINTR then * Read was interrupted if time() >= alarmend then * Was the timer stop "time out" end else * Not the timer. Disarm it %alarm(0) end end else * Read completed. Cancel timer %alarm( 0 ) end