The following four examples, using an APL shared variable named EXAMPLE,
show how the information required to open a data file or specify printer output
can be entered:
is to be used.
The value TEST2 will be placed
tt
File 3 on tape unit 1 (assumed) is to be opened.
t The value TEST will be compared
I
to the file header field.
File 1 on tape unit 1 is to be opened.
-Data is to be
transferred from tape
into the active workspace.
tFile 3 on tape unit 1 (assumed) is to be opened.
IData is to be transferred into an existing file on tape.
Note: Since the file ID was not specified, no value is compared to the file
header field.
EXAMPI..,E+. PR‘r MSG::-C)I”’t:
tNo error messages will be displayed
for nonzero return codes.
L Data is to be printed.
After the information has been entered, a code (2-element vector) that indicates
whether the operation was successful or not is assigned to the shared variable. A
return code of 0 0 indicates the operation was successful, and a nonzero return
code indicates that the operation failed. See Return Codes in this chapter for a
description of each return code.
1 62
TRANSFERRING DATA
c ':
After the data file has been opened or printer output specified, data can be trans-
ferred using the shared variable. (An example using tape and printer input/output
is shown later in this chapter.)
Transferring Data to Tape (OUT or ADD Operation)
When data is assigned to the shared variable, the data is written on tape and a
return code is assigned to the shared variable. A 0 0 return code means the data
was transferred successfully and a nonzero return code means the transfer of
data failed. See Return Codes in this chapter for a description of each return code.
Transferring Data from Tape (IN Operation)
When data is transferred from tape, the data is read from tape and is assigned to
the shared variable in the same sequence as it was written to tape. New data is
read from the tape file and assigned to the shared variable each time the shared
variable is used. (There is no return code assigned to the shared variable after an
IN operation.)
When doing an IN operation with an interchange data file, the following condi-
tions occur if a cursor return character (X'9C') or end-of-block character (X'FF')
was embedded in a character vector that was written to tape:
0 If a cursor return character was embedded in the character vector, the data
will be read from tape in a different sequence than it was written to tape.
This condition occurs because as the interchange data is written to tape, the
system writes an end-of-record character (X'9C') after each character vector
(record) that was written to tape. The end-of-record character and the cursor
return character are the same. When used on tape, this character separates the
data (records) so that it can be read from tape in the same sequence as it was
written to tape. However, if a cursor return character is embedded in the data
that was written to tape, the system will recognize it as an end-of-record char-
acter when the data is read from tape.
If an end-of-block character was embedded in the character vector, any data
from the embedded end-of-block character to the next physical record is not
read from tape. This condition occurs because the system looks at the tape in
512-byte segments (one physical record). A physical record can be terminated
by an end-of-block character (X'FF'). When the system is reading data from
the tape and an end-of-block character is encountered, the system skips to the
next physical record and continues reading data. Therefore, if an X'FF' char-
acter is embedded in the data that was written to tape, the system recognizes
it as an end-of-block character when the data is read from tape and skips
ahead to the next physical record.
163
Previous Page Next Page