# waitevent

Waits an event.

    waitevent <events>

## Remarks

Pauses until one of the events specified by <events> occurs. <events> can be combination of the following event identifiers.

Event | Event identifier
--- | ---
timeout | 1
unlink | 2
disconnection | 4
connection | 8

The timeout event occurs when <timeout>.<mtimeout> seconds have passed. <timeout> is the value of the system variable "timeout". <mtimeout> is the value of the system variable "mtimeout". If timeout is less than or equal to zero, this event never occurs.

The unlink event occurs when Tera Term is closed.

The disconnection (connection) event occurs when the communication between Tera Term and the host is closed (opend).

These commands return the identifier of the actual event in the system variable "result".

## Example

    ; Wait the disconnection event
    waitevent 4
    ; Wait the unlink or connection events
    waitevent 2 or 8
    ; The unlink event occured
    if result=2 goto label1
    ; The connection event occured
    if result=8 goto label2