Asynchronous Serial Communications Programmer's Reference Manual (32022-90052)

76 Chapter3
Common Device Control Functions
Writing to Asynchronous Devices
Sending Escape Sequences
You can also use FWRITE to send escape sequences to an asynchronous
device. Escape sequences can be used to alter the physical settings of a
device. For example, on most supported terminals you can use escape
sequences to set terminal straps, control the placement of the cursor on
a terminal screen, and set margins. You should consult the manual for
your device for a summary of useful escape sequences.
In the following example the variable
esc_seq
contains the string
’ESC&s1D’
. This escape sequence selects page block mode at the
terminal (opens the “D” strap). The escape sequence can be sent to the
device with the following FWRITE call:
FWRITE(file_num, esc_seq, -5, octal(‘320’));
The length parameter is specified as 5 bytes, the length of the escape
sequence (ESC is one byte). Carriage control is set to %320, so that no
carriage return or linefeed are sent. As a result of this call, the terminal
on which the file specified by file_num is opened will be strapped for
page block mode.
Using PRINT
In much the same way that READ and READX provide a quick method
for reading from the standard input device, PRINT provides a quick
method for writing to the standard output device. PRINT sends a string
of ASCII characters to $STDLIST. The syntax of the call is as follows:
CAI 16V I16V
PRINT(message,length,controlcode);
The message parameter is a character array that holds the string to be
written to the device. It must begin on a halfword boundary, as must all
character arrays.
The length parameter specifies the length of the character string. If
the length of the message exceeds the configured record length of the
terminal, successive records will be written.
The controlcode parameter specifies the carriage control to be applied
when the message is output. Either a 0, 1, or one of the valid carriage
control directives should be passed in this parameter. See the
discussion of the FWRITE intrinsic for more information on
controlcode values.
Like READ and READX, PRINT has a number of limitations on the
way it can be used. Because no file number is available, :FILE
commands are not useful, nor is it possible to use the FCHECK
intrinsic to check error conditions. For permanent programs it is
recommended that FWRITE be used instead.