%alarm() Function

For Windows: Not Supported

The %alarm() function instructs the alarm clock of the calling process to send the signal SIGALRM to the calling process.

Syntax

var = %alarm(num)

Parameter(s)

num

Number of seconds before the signal is sent.

Description

The default alarm handler is null (that is, it just interrupts the process). If num is 0, any previous alarm request is canceled. If a user-written built-in function changes the alarm signal handler, it remains in effect, even if the FlashBASIC program terminates, until the process is disconnected from the virtual machine.

The alarm signal handler can be assigned to any D3 statement using the TCL trap command.

To differentiate between an alarm and another interrupt, the FlashBASIC program may have to check the time. See the example below.

Example(s)

* Set a timer

alarmend=time()+3

%alarm(3)

* Read from device

n=%recv(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

See Also

FlashBASIC C Functions Overview

cfunction Statement

trap Command

useralarm Command