NET/MASTER Network Control Language (NCL) Programmer's Guide

Setting UDB Characteristics
Working With Files
12–40 106160 Tandem Computers Incorporated
The name of the file, $DATA2.JOHNNCLS.MYFILE, is entered as the first parameter
to the NCL procedure. The NCL process attempts to use FUP to create the file. If FUP
is able to create the file, the UDBCTL OPEN command opens the file for system-wide
access, the FILE OPEN verbs open the UDB for access from NCL, the FILE SET verb
explicitly assigns new identifiers to the UDB, the FILE CLOSE verb closes the UDB,
and the UDBCTL CLOSE command closes the file for access from
NonStop NET/MASTER MS. If FUP is not able to create the file, that is, the file
already exists, the NCL process terminates.
Two Techniques for Identifying UDBs
There is no practical limit to the number of UDBs or UDB pairs that can be open
concurrently for use by an NCL process. An NCL process can open and close UDBs or
UDB pairs as required, or an NCL process can open many UDBs or UDB pairs using
consecutive FILE OPEN verbs.
If only one UDB or UDB pair is open, NCL assumes that any UDB processing is to be
done on this UDB or UDB pair (the current UDB or UDB pair). An NCL process does
not have to refer to the UDB or UDB pair by its identifier; all FILE verbs automatically
target the open UDB or UDB pair.
If there are many open UDBs or UDB pairs, either individual FILE verbs can explicitly
identify a target UDB or UDB pair as required, or an NCL process can use FILE SET to
identify the current UDB or UDB pair for use by subsequent FILE verbs.
Identifying target UDBs or UDB pairs in individual FILE verbs is more convenient if
the NCL process is targeting a number of different UDBs or UDB pairs in the space of
a few statements. This is the case, for example, when NCL is reading a record from
one UDB or UDB pair, processing the record, and then writing it immediately to
another UDB or UDB pair.
The following code segment uses a DO loop to read every record from a UDB, to
process the record, and to write the record immediately to another UDB:
FILE OPEN ID=INPUT_1
FILE OPEN ID=OUTPUT_1
FILE GET ID=INPUT_1 OPT=SEQ VARS=&A*
DO WHILE &SYS.FILE.RC = 0
/* do some processing */
FILE PUT ID=OUTPUT_1 VARS=&A*
FILE GET ID=INPUT_1 OPT=SEQ VARS=&A*
END /*do*/
FILE CLOSE ID=INPUT_1
FILE CLOSE ID=OUTPUT_1
Each FILE verb in this example explicitly identifies a target UDB as required.