NET/MASTER Network Control Language (NCL) Programmer's Guide
Working With KeySequenced Files in a UDB Pair
Working With Files
12–92 106160 Tandem Computers Incorporated
Example—Getting Records From the Read-Only File in a UDB Pair
The following NCL procedure gets records from a key-sequenced file (before the file is
opened as the read-only file in a UDB pair):
zex1212n: PROCEDURE
/* Reads records from a mapped key-sequenced UDB */
IF &1 = "" THEN DO
SAY "Must enter a file name"
EXIT
END /*do*/
ELSE
&distfile = &1
&id = UDBPAIR
CALL open_file SHARE &distfile,&id
CALL get_records SHARE &distfile,&id
CALL close_file SHARE &distfile,&id
EXIT
/* ==================== OPEN FILE ==================== */
open_file: PROCEDURE SHARE &distfile,&id
/* Open file for NonStop NET/MASTER and NCL */
SAY "Opening "&distfile
INTCMD "UDBCTL OPEN="&distfile" ID="&id
INTREAD
INTCONT
FILE OPEN ID=&id FORMAT=MAPPED MAP=$NCL
SELECT &SYS.FILE.RC
WHEN 0 THEN SAY "0 Read-only access"
WHEN 4 THEN SAY "4 Read and write access"
WHEN 8 THEN SAY "8 Read, write, and delete access"
WHEN 12 THEN SAY "12 No access"
WHEN 16 THEN SAY "16 "&SYSMSG
OTHERWISE
SAY Unexpected error
END /*select*/
END open_file
/* ==================== GET RECORDS ==================== */
get_records: PROCEDURE SHARE &distfile,&id
/* Get records and display them on OCS window */
ASSIGN MDO=&rec. MAP=$NCL
FILE GET OPT=SEQ MDO=&rec.
SELECT &SYS.FILE.RC
WHEN 0 THEN DO
SAY "0 Record retrieved"
SAY "Key is "&SYS.FILE.KEY
END /*do*/
WHEN 4 THEN SAY "4 Record not found or EOF"
WHEN 8 THEN SAY "8 Error "&SYS.FILE.ERROR
WHEN 16 THEN SAY "16 "&SYSMSG
OTHERWISE
SAY Unexpected error
END /*select*/
DO WHILE &SYS.FILE.RC = 0
ASSIGN VARS=&field* FROM MDO=&rec.
DO &fno = 1 TO &SYS.VARCNT