%TTSTS
Determine whether input is pending
WTSupported in traditional Synergy on Windows
|
|
USupported on UNIX
|
VSupported on OpenVMS
|
status = %TTSTS([channel])
or
xcall TTSTS(status[, channel])
Return value
status
%TTSTS returns a value of 0 under the following circumstances:
- No characters are currently pending on the referenced terminal or serial device.
- Channel is not specified and no channel is opened to the terminal or serial device.
If one or more characters are pending on the referenced terminal, %TTSTS returns either a value of 1 or the number of pending characters, depending on what’s available on your system. (i)
Arguments
channel
(optional) The number of a channel opened to a terminal or serial device. (n)
Discussion
%TTSTS determines whether at least one input character is still pending on either the current terminal or another character device or serial device.
If channel is not specified, Synergy DBL looks for the channel opened to the terminal (TT:).
You can use %TTSTS to inspect a terminal during a period of complicated and time-consuming processing. If %TTSTS finds that input is pending, your program can receive it and process it before continuing. By specifying the channel argument, you can check a terminal channel other than TT:. If channel is not a terminal or serial device, %TTSTS returns a value of 1.
When performing an input operation, program execution stops until the operation is completed and the information is transferred. In applications such as unsolicited user status facilities, the program should continue processing until terminal input (the status request) is available. When this input becomes available, the program can receive it and respond to it. If you don’t use %TTSTS, the only way your program can test for user input is to issue an input request, which suspends program processing until the user responds.
On some UNIX systems, and for the keyboard on Windows, the status value is 1 or 0. |
Each call to the TTSTS routine generates an operating system request, which consumes processing time. To avoid wasting processing time, we recommend that you use the TTSTS routine sparingly. If your program loops on the TTSTS routine, the required processing time affects the efficiency of your system. |
Examples
The following subroutine prints a large report and checks after each page prints to see if the user typed a “Q” to quit printing.
subroutine prnt_rpt a_file ,a a_data ,a .define TTCHN ,1 external function get_pg ,d record page ,d3, 1 input ,a1 proc while (%get_pg(page, a_data)) do ;User function that returns 0 begin ; when there is no more data xcall prnt_pg(a_data) if (%ttsts) accept(TTCHN, input) if (input .eq. 'Q') exitloop incr page end xreturn endsubroutine