Guardian Programmer's Guide

Table Of Contents
Communicating With Terminals
Guardian Programmer’s Guide 421922-014
10 - 7
Transferring Data Between Application and Terminal
Here, the application process reads up to BUFSIZE (the size of SBUFFER) characters
into the buffer and returns the number actually read in the variable COUNT^READ. On
issuing the READX procedure call, the process waits for the read operation to finish,
which is an indefinite time. The read operation finishes when one of the following
conditions is satisfied:
The user issues the line-termination or page-termination character (usually
associated with the RETURN key).
The number of characters specified in BUFSIZE have been read.
Pressing CONTROL/Y or pressing the BREAK key also has the effect of terminating
the input.
Writing to and Reading From a Terminal in One Operation
Use the WRITEREADX procedure to ensure that the system is ready to receive data
from the terminal immediately after you write to the terminal. This feature is useful
when conversationally prompting a terminal user for input. The WRITEREADX
procedure combines a write operation and a read operation in one procedure call.
The following example prompts the terminal user with a colon and then waits for the
reply. Note that the same buffer is used for the prompt as for the reply.
SBUFFER ':=' ": ";
WCOUNT := 1;
CALL WRITEREADX(TERMNUM,
SBUFFER,
WCOUNT,
BUFSIZE,
COUNT^READ);
IF <> THEN ...
This example writes one character (the colon) from the buffer to the terminal. The
application then waits for a response from the terminal. The response in this case is
either BUFSIZE characters of data or fewer than BUFSIZE characters terminated by
the user pressing the line-termination or page-termination key (usually the carriage
return).
Note that WRITEREADX does not issue a carriage return/line feed sequence after the
write operation. The prompt and the response therefore appear on the same line of
the terminal.
The WRITEREADX procedure is also useful for issuing control commands to the
terminal. For example, you can read the seven-character cursor address from a
terminal by issuing an escape sequence as follows: