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

Working With Single Key-Sequenced Files
Working With Files
106160 Tandem Computers Incorporated 12–59
Adding a Record to a Mapped Key-Sequenced File
The following code segment adds records to a mapped key-sequenced file:
ASSIGN MDO=&rec. MAP=$NCL
/* Allows you to enter 4 fields for 4 records */
DO &rno = 1 TO 4
DO &fno = 1 TO 4
SAY Enter record &rno field &fno
CMDLINE "-GO ID="&SYS.NCLID _
PAUSE VARS=&field&fno PARSE=NO
END /*&fno do*/
ASSIGN MDO=&rec. MAP=$NCL FROM VARS=&field*
SAY "Adding record "&rno" to "&filename
FILE ADD KEY=&rno MDO=&rec.
SAY "Key is "&SYS.FILE.KEY
END /*&rno do*/
The key to each record is the record number. The value of the record number is the
value of the control variable in the DO loop that obtains each record.
Adding a Record to an Unmapped Key-Sequenced File
The following code segment adds records to an unmapped key-sequenced file:
/* Allows you to enter 4 fields for 4 records */
DO &rno = 1 TO 4
DO &fno = 1 TO 4
SAY Enter record &rno field &fno
CMDLINE "-GO ID="&SYS.NCLID _
PAUSE VARS=&field&fno PARSE=NO
/* Fix length of field at 20 bytes */
&field&fno = LEFT(&field&fno,20)
END /*&fno do*/
SAY "Adding record "&rno" to "&filename
FILE ADD KEY=&rno VARS=&field*
SAY "Key is "&SYS.FILE.KEY
END /*&rno do*/
The key to each record is the record number. The value of the record number is the
value of the control variable in the DO loop that obtains each record.