Enscribe Programmer's Guide
compare^len , generic );
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
:
END;
END; ! read loop
The KEYPOSITION call sets the current position at the first record in the primary data file that
contains the value BROWN as the first five characters in the primary-key field. Access is by the
primary-key access path.
Successive read calls within the read loop access all of the records in the primary data file that
contain the value BROWN as the first five characters in the primary-key field. Within that generic
subset, records are accessed in ascending order by the primary key. In addition to returning a
data record, each read call sets the condition code to CCE, indicating successful completion.
The final read call in the read loop returns no data and sets the condition code to CCG, indicating
that the EOF was encountered. This illustration visually represents the results of each read call
executed within the read loop:
BROWN, A
BROWN, B
REEDLEY, CA
BOSTON, MA
WE
EA
0256.95
0301.00
0300.00
1000.00
1
2
3 EOF
Primary-Key
Field
Example 5: Exact Subset by Primary Key
This sample TAL code shows how to perform exact positioning by the primary-key value SMITH:
! blank the key
key ':=' " ";
key[1] ':=' key FOR name^len - 1 BYTES;
key ':=' "SMITH";
exact = 2;
CALL KEYPOSITION ( cust^filenum, key, , , exact );
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
:
END;
END; ! read loop
Accessing Key-Sequenced Files 93