Enscribe Programmer's Guide

Example 1: Creating an Entry-Sequenced File
This example shows how to create a file for logging summary records of financial transactions as
they occur. Because the records will always be written to the file sequentially in the order in which
they are generated, it is reasonable to use an entry-sequenced file for storing them.
Assume that the desired record format is:
Byte Offset:
0 10 16 24
06555404
transid date time-stamp account-number
trans-type amount-transacted terminal-number
With a record size of 60, selecting a block size of 4096 results in a blocking factor of 65 records
per block:
N = (B - 22) / (R + 2)
65 = (4096 - 22) / (60 + 2)
If you designate the primary extent size as 1000 pages and the secondary extent size as 500
pages, then the primary extent can accommodate 32,500 transaction summary records and each
secondary extent can accommodate 16,250 transaction summary records. If all 16 extents are
eventually used, the file will accommodate a total of 276,250 transaction summary records
You could create the file by using these FUP commands:
>volume $store1.svol1
>fup
-set type e
-set ext (1000,500)
-set rec 60
-set block 4096
-show
TYPE E
EXT ( 1000 PAGES, 500 PAGES )
REC 60
BLOCK 4096
-create tranfile
CREATED - $STORE1.SVOL1.TRANFILE
Using the FILE_CREATE_ system procedure, you could create the file by including this TAL code in
one of your application modules:
LITERAL name^length = 22,
pri^extent = 1000,
sec^extent = 500,
rec^len = 60,
data^block^len = 4096,
file^type = 2; ! entry-sequenced
INT filenum;
INT error;
INT namelen;
STRING .filename [0:21] := "$STORE1.SVOL1.TRANFILE";
?NOLIST
?SOURCE $SYSTEM.SYSTEM.EXTDECS0(FILE_CLOSE_,
? FILE_OPEN_,
? FILE_CREATE_,
126 Entry-Sequenced Files