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

Working With Single Key-Sequenced Files
Working With Files
106160 Tandem Computers Incorporated 12–57
Working With Single
Key-Sequenced Files
The structure of records in a key-sequenced file is briefly described earlier in this
section. This subsection describes how to work with single key-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 a key-sequenced file from an NCL process.
How to open a key-sequenced file for system-wide access from an NCL process.
How to open a key-sequenced file for use by an NCL process and specify how
data is organized.
How to add a record to a key-sequenced file.
How to get (retrieve) a record from a key-sequenced file.
How to put (update) a record in a key-sequenced file.
How to delete a record in a key-sequenced file.
Comments throughout each code segment describe how it works. Complete examples
of NCL procedures that work with key-sequenced files are included at the end of this
subsection.
Working with key-sequenced files in a UDB pair is discussed later in this section.
Creating the File You can use FUP to create a key-sequenced file. The following code segment uses FUP
to create a key-sequenced file with a record length of 512 bytes and a key length of 6
bytes from an NCL process:
create_file: PROCEDURE SHARE &filename
/* Use FUP to create new key-sequenced file */
SAY "Creating file "&filename
INTCMD "OPSYS SEND FUP CREATE "&filename", TYPE K,",
"REC 512, KEYLEN 6"
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