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

Chapter 3 57
Common Device Control Functions
Opening Asynchronous Devicefiles
File Open Intrinsics
The way in which file characteristics are specified differs depending on
whether you are calling FOPEN or HPFOPEN. The parameters of the
FOPEN intrinsic are positional. The file system expects to see them in a
certain order and will not accept any specifications that fail to conform.
An FOPEN call to open $STDIN for reading might be coded as:
fileid_in:=FOPEN(,octal(‘444’),0,-80);
HPFOPEN provides a superset of the features provided by FOPEN and
uses combinations of
itemnum/item
pairs to specify file
characteristics. An HPFOPEN call performing the same function as the
FOPEN call above (and returning any error information in a variable
called “status”) might be coded as:
HPFOPEN(fileid_in,status, 53,1,
5,4,
6,2,
7,1,
11,0,
19,-80);
HPFOPEN can be used in native mode only. None of the extended
features provided by this intrinsic apply specifically to asynchronous
devicefiles. For consistency, the examples that follow will show the use
of FOPEN exclusively. Be aware, however, that, in native mode,
HPFOPEN calls can be used instead.
Your program may open multiple files on the same device, each with its
own set of characteristics, logically separate access, and unique file
number. Such files opened on a device are often referred to as ports.
The code fragments shown in Figure 3-1 open a read port and a write
port on a terminal device. The parameters specify 80 byte ASCII
records and carriage control. Condition codes are checked in the
example through the Pascal/iX ccode function, which will return a
value of CCE if no errors occur during the opens, or of CCG or CCL if
errors do occur.