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

Working With Edit Files
Working With Files
106160 Tandem Computers Incorporated 12–105
Example of Working With
an Edit File
The following NCL procedure gets records from an edit file and displays them at an
OCS window. Comments throughout the NCL procedure describe how it works. The
edit file must exist before you attempt to read it. You must specify the file name as the
first parameter when you execute the NCL procedure, for example:
START ZEX1210N $DATA2.JOHNNCLS.EDITFILE
Note Before executing the example, you should use the SHOW UDB command to ensure that UTEDIT is not
being used as a UDB ID at your installation. If it is, edit the example so that it uses a different UDB ID.
zex1210n: PROCEDURE
/* Reads records from unmapped entry-sequenced UDB */
/* In this case, the file is a TEDIT file */
ON ERROR FLUSH
IF &1 = "" THEN DO
SAY "Must enter file name as first parameter"
FLUSH
END /*do*/
ELSE
&filename = &1
&id = UTEDIT
CALL open_file SHARE &filename,&id
CALL get_records SHARE &filename,&id
CALL close_file SHARE &filename,&id
EXIT
/* ==================== OPEN FILE ==================== */
open_file: PROCEDURE SHARE &filename,&id
/* Opens file for NonStop NET/MASTER and NCL */
SAY "Opening "&filename
INTCMD "UDBCTL OPEN="&filename" ID="&id
INTREAD
FILE OPEN ID=&id FORMAT=UNMAPPED
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 &filename,&id
/* Get records and displays them on OCS window */
FILE GET VARS=&record
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