Enscribe Programmer's Guide

! blank the key
key ':=' " ";
key[1] ':=' key FOR name^len - 1 BYTES;
key ':=' "EVANS";
CALL KEYPOSITION (cust^filenum, key);
CALL WRITEUPDATE (cust^filenum, cust^rec , 0);
IF <> THEN ... ! error
This illustration shows the contents of the applicable portion of the customer file after the deletion:
BROWN, B
HARTLEY
BOSTON, MA
CHICAGO, IL
EA
NO
0301.00
0433.29
2000.00
0500.00
Example 12: Sequential Reading With Deletions Using Primary Key
This sample TAL code reads the customer file sequentially by primary-key value and deletes any
records whose current balance field contains 0.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
IF < THEN ... ! error
ELSE
BEGIN ! process the record
IF cust^rec.cust^curbal = 0.00F THEN
BEGIN
CALL WRITEUPDATE ( cust^filenum, cust^rec, 0 );
IF < THEN ... ! error
:
END;
END;
END; ! read loop
This illustration shows the contents of the customer file after all of the applicable records have been
deleted:
Accessing Key-Sequenced Files 99