%WAIT

Suspend program execution

WSupported on Windows
USupported on Unix
VSupported on OpenVMS

 

event = %WAIT(parameters[, seconds])

or

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

Return value

event

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

Arguments

parameters

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.

seconds

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

Discussion

%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. If you are running a detached job and you specify position 2 or 3, Synergy DBL will return position 2 in the event argument (which indicates that input is pending). The same value is returned if you redirect SYS$INPUT from a command file and system option #39 is set.

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

The non-interactive runtimes (dbs, dbssvc, and dbspriv) do not support %WAIT, nor will %WAIT work on a detached program.

Examples

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 Enter to continue” message, then waits for the user to press a record terminator.

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