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

Working With Entry-Sequenced Files
Working With Files
106160 Tandem Computers Incorporated 12–43
Working With Entry-
Sequenced Files
The structure of records in an entry-sequenced file is briefly described earlier in this
section. This subsection describes how to work with entry-sequenced files from an
NCL process. It does so by presenting a series of code segments that you can use
when you create your own NCL procedures. The code segments show the following:
How to create an entry-sequenced file from an NCL process.
How to open an entry-sequenced file for system-wide access from an NCL process.
How to open an entry-sequenced file for use by an NCL process and specify how
its data is organized.
How to add a record to an entry-sequenced file.
How to get (retrieve) a record from an entry-sequenced file.
Comments throughout each code segment describe how it works. Complete examples
of NCL procedures that work with entry-sequenced files are included at the end of this
subsection.
Note You cannot update or delete a record in an entry-sequenced file from an NCL process.
Creating the File You can use FUP to create an entry-sequenced file. The following code segment uses
FUP to create an entry-sequenced file with a record length of 512 bytes from an NCL
process:
create_file: PROCEDURE SHARE &filename
/* Use FUP to create new entry-sequenced file */
SAY "Creating file "&filename
INTCMD "OPSYS SEND FUP CREATE "&filename", TYPE E,",
"REC 512"
DO UNTIL &msgno = NNM0999
INTREAD VARS=(&msgno(7),*,&text) TYPE=ANY PARSE=NO
IF POS("ERR 10",&text) > 0 THEN DO
/* File exists, so flush NCL process */
SAY "Must enter new file name"
FLUSH
END /*do*/
END /*do until*/
INTCMD "OPSYS KILL FUP"
INTREAD
END create_file