I
Chapter 8. Tape and Printer Input and Output
Input and output involving the tape or printer can be done with an APL shared
variable, which is a specific variable shared between the active workspace and the
tape or printer. During output operations, the data assigned to the shared variable
is printed, or is written on tape. During input operations, data is read from tape
and assigned to the shared variable; the shared variable can then be used in an ex-
pression in the active workspace. To do tape or printer input or output, the
following steps must be performed:
1. Establish a variable to be shared.
2. Open a data file on tape or specify printer output.
3. Transfer the data.
4. Close the data file or terminate the printer output.
5. Retract the variable being shared.
ESTABLISHING A VARIABLE TO BE SHARED
The OSVO function is used to establish the variable name(s) to be shared. The
OSVO function is dyadic (requires two arguments) and is entered as follows:
The left argument must be a 1.
The right argument NAME(S) can be up to eight variables to be shared. If more
than one name is required, the names must be entered as a character matrix with
each row representing a name. For example:
61iRli1..:~-3 Jp ' WNlf:TbJ(3'1'I*~II? '
I.? PI n R
E:
-Each row represents a separate variable name.
ONE
158
c, i
Following are three examples of how the USVO function can be entered:
. :I. I::/ :i; v c1 ' w:r A 'I' A
'
0 Sl-lhRE4-3 :I. fS ' ARI:: ' Establishes three names (A, B,
1 /::I !j v Q !:; 1-1 A I? iii: and C) to be shared.
The 5100 will respond with a 2 for each shared variable that is successfully estab-
lished and a 0 or 1 for each variable that is not. If a 1 is displayed, a value other
than 1 was specified as the left argument for the OSVO function. In this case, the
variable name must be retracted (see Retracting the Variable Name being Shared
later in this chapter) and reestablished as a shared variable before it can be used
for input/output. If a 0 is displayed, an error message (see Chapter 11) will also
be
displayed.
Note: The instruction +/OtOSVO ONL 2 will display the existing number of
shared variables in the system, and the instruction (0t:OSVO ONL 21411 ONL 2
will display the existing shared variable names.
OPENING A DATA FILE OR SPECIFYING PRINTER OUTPUT
The first value assigned to the shared variable must be
information required to
open a data file on tape or to specify printer output. When opening a data file,
this information specifies the following:
Data to be transferred to tape or from tape
Device/file number
File ID
Data format to be used
Note: If this information has already been assigned to a variable name that is
being used as the right argument for the USVO function, the 5100 will establish
the variable name to be shared, then open the data file or specify printer output.
In this case, there is no return code assigned to the shared variable to indicate if the
operation was successful or not. The return codes are described later in this chapter.
159
Previous Page Next Page