Suspend program execution

WTSupported in traditional Synergy on Windows


USupported on UNIX
VSupported on OpenVMS
event = %WAIT(parameters[, seconds])


xcall WAIT([seconds], parameters[, event])

Return value


%WAIT returns a numeric specification of the event that caused program execution to resume. (i)



An expression that specifies the event(s) for which to wait. Each event is indicated by a nonzero number in a specific position, as follows: (n)

Position 4

Wait for a message.

Position 3, 2

Wait for terminal input at any of the keyboards opened by the program.

Position 1

Wait for the amount of time specified by the seconds argument to expire.


(optional) An expression that specifies the number of seconds for which program execution should be suspended. (n)


%WAIT suspends program execution until a specified event occurs and indicates the event that caused execution to resume.

The parameters digits are numbered from right to left, as shown in figure 1.

1. %WAIT parameters.

If parameters contains a value of 0001, for example, %WAIT suspends program execution for the specified number of seconds. If more than one event is specified (in other words, more than one digit in the parameters argument is nonzero), the first event to occur causes the program to resume execution.

Positions 2 and 3 perform the same function. If position 2 or 3 is set, the WAIT subroutine waits for terminal input on one or more channels opened to terminal or serial devices. (These settings perform identical functions.) The first five channels (in numerical channel order) opened to such devices are checked. If there is any type-ahead data, the routine will return immediately, regardless of timeout.

On Windows, %WAIT has limited functionality due to mouse and sizing events, and there is no wait on message. We recommend using WD_ACCEPT/WD_READS with WD_WAIT instead. If you're not using the Synergy windowing API, the ACCEPT statement with the WAIT qualifier is another alternative.

Except on some older UNIX systems, a WAIT subroutine that waits for time and keyboard input (xcall wait(1, 321)) tests for input every 1/10 second.

On OpenVMS, the WAIT subroutine has always performed a test for time and input every 1/10 second; however, this shows up as DIO in the process statistics for each interval.

The seconds argument is only required when digit position 1 in the parameters argument is nonzero.


The following example sets wait flag 4. The routine continues after the message manager receives a message for the suspended program.

xcall wait(, 4000)

The following example causes the program to sleep for five seconds before continuing execution.

xcall wait(5, 1)

The following example displays a “Press RETURN to continue” message, then waits for the user to press a record terminator.

open(1, o, "tt:")
display(1, "Press RETURN to continue")
xcall wait(, 300)
display(1, $scr_clr(line))