Enscribe Programmer's Guide
The data record written from the application buffer to the disk file is:
HARTLEY CHICAGO, IL NO 0463.29 0500.00
Example 9: Random Update of a Nonexistent Record
This example shows an attempt to update a nonexistent record. Because the KEYPOSITION
procedure does no searching of indexes, the attempt to access the nonexistent record is not
discovered until the subsequent READUPDATE call.
The first four records in the primary data file are:
ADAMS
BROWN, A
BROWN, B
EVANS
MIAMI, FL
REEDLEY, CA
BOSTON, MA
BUTTE, MT
SO
WE
EA
WE
0000.00
0256.95
0301.00
0010.00
0500.00
0300.00
1000.00
0100.00
This sample TAL code tries to set the current position at the data record that contains the value
BROWN,C in the primary-key field, and then tries to read that record into the application buffer
in preparation for an update operation:
! blank the key
key ':=' " ";
key[1] ':=' key FOR name^len - 1 BYTES;
key ':=' "BROWN,C";
exact := 2;
CALL KEYPOSITION (cust^filenum, key, , , exact );
IF <> THEN ...
CALL READUPDATE (cust^filenum, cust^rec, $LEN(cust^rec) );
IF < THEN
BEGIN
status := FILE_GETINFO_ (cust^filenum, error);
IF error = 11 THEN ... ! record not found
:
END;
The attempt to read the nonexistent record fails with a condition code of CCL and a file-system
error code 11.
Example 10: Sequential Reading via Primary Key With Updating
This sample TAL code changes the content of the limit field to 2000.00 within any data record
whose limit field value is currently >= 1000.00 and < 2000.00:
! position to the first record by primary key
compare^len := 0;
CALL KEYPOSITION ( cust^filenum, key, , compare^len);
cust^eof := 0;
WHILE NOT cust^eof DO
BEGIN ! read loop
CALL READ ( cust^filenum, cust^rec, $LEN(cust^rec) );
IF > THEN cust^eof := 1 ! end-of-file
ELSE
Accessing Key-Sequenced Files 97