Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 48
Opening Key-Sequenced Files
The following example creates a key-sequenced file interactively using the FUP
CREATE command. The new file has a block size of 4096 bytes, maximum record
length of 128 bytes, and key length of 16 bytes, and the key offset is zero.
1> FUP
-SET TYPE K
-SET BLOCK 4096
-SET REC 128
-SET IBLOCK 2048
-SET KEYLEN 16
-SHOW
TYPE K
EXT ( 1 PAGES, 1 PAGES )
REC 128
BLOCK 4096
IBLOCK 2048
KEYLEN 16
KEYOFF 0
MAXEXTENTS 16
-CREATE \SYS.$MANUF.RECORDS.INVENTRY
CREATED - \SYS.$MANUF.RECORDS.INVENTRY
-EXIT
2>
Refer to the File Utility Program (FUP) Reference Manual for more details on how to
create files using the FUP CREATE command.
The following example creates the same key-sequenced file programmatically using
the FILE_CREATE_ procedure:
NAME ':=' "\SYS.$MANUF.RECORDS.INVENTRY" -> @S^PTR;
NAME^LENGTH := @S^PTR '-' @NAME;
FILE^TYPE := 3;
RECORD^LENGTH := 128;
BLOCK^LENGTH := 4096;
KEY^LENGTH := 16;
KEY^OFFSET := 0;
CALL FILE_CREATE_(NAME:ZSYS^VAL^LEN^FILENAME,
NAME^LENGTH,
!file^code!,
!primary^extent^size!,
!secondary^extent^size!,
!max^extents!,
FILE^TYPE,
!options!,
RECORD^LENGTH,
BLOCK^LENGTH,
KEY^LENGTH,
KEY^OFFSET);
Opening Key-Sequenced Files
You open a key-sequenced file as you would any file, by using the FILE_OPEN_
procedure. See Using Unstructured Files earlier in this section for an example.