Enscribe Programmer's Guide

INT num^alt^key^files;
STRUCT name^length^info [ 0:num^altkey^files-1];
BEGIN
INT file^name^len;
END;
STRING file^names [0:9];
END;
?NOLIST
?SOURCE $SYSTEM.ZSYSDEFS.ZSYSTAL(FILESYSTEM^ITEMCODES)
?SOURCE $SYSTEM.SYSTEM.EXTDECS0(FILE_CLOSE_,
? FILE_OPEN_,
? FILE_CREATELIST_,
? READ)
?LIST
PROC DO^THE^WORK MAIN;
BEGIN
namelen := name^length;
item^list ':=' [ZSYS^VAL^FCREAT^FILETYPE,
ZSYS^VAL^FCREAT^LOGICALRECLEN,
ZSYS^VAL^FCREAT^BLOCKLEN,
ZSYS^VAL^FCREAT^PRIMEXTENTSIZE,
ZSYS^VAL^FCREAT^SCNDEXTENTSIZE,
ZSYS^VAL^FCREAT^NUMALTKEYS,
ZSYS^VAL^FCREAT^ALTKEYDESC,
ZSYS^VAL^FCREAT^NUMALTKEYFILES,
ZSYS^VAL^FCREAT^ALTFILELEN,
ZSYS^VAL^FCREAT^ALTFILENAMES ];
value^list.file^type := 1; ! relative
value^list.logical^reclen := 112;
value^list.block^length := 4096;
value^list.pri^extent := 60;
value^list.sec^extent := 30;
value^list.altkeys := num^altkeys;
value^list.altkey^descr[0].key^specifier ':=' "DP";
value^list.altkey^descr[0].key^length := 5;
value^list.altkey^descr[0].key^offset := 80;
value^list.altkey^descr[0].key^filenum := 0;
value^list.altkey^descr[0].null^value := 0;
value^list.altkey^descr[0].attributes := 0;
value^list.num^alt^key^files := num^altkey^files;
value^list.name^length^info[0].file^name^len := 10;
value^list.file^names ':=' "SVOL1.DEPT";
ERROR := FILE_CREATELIST_ (filename:name^length,namelen,
item^list, item^list^len, value^list,
$LEN(value^list), error2);
END;
Note that you must then create the alternate-key file separately. For more information see the
following section.
Example 3: Creating an Alternate-Key File
When you use FUP to create the primary file, FUP automatically creates any required alternate-key
files. If you create the primary file programmatically, however, you must create the alternate-key
file yourself as a separate operation. This example assumes the use of a format 1 file. To see the
difference with a format 2 file, see “Example 3: Creating a Key-Sequenced Format 2 File With
Alternate Keys” (page 80).
You could create the alternate-key file for “Example 2: Creating a Relative File With Alternate
Keys” (page 139) by including the TAL code in one of your application modules. Again, the node
name is obtained from the current value of the VOLUME attribute of the =_DEFAULTS DEFINE.
Creating Relative Files 141