Enscribe Programmer's Guide

The KEYPOSITION call sets the current position at the first record in the primary data file that
contains the value SMITH as the first five characters in the primary-key field. Access is by the
primary-key access path.
Exact positioning by a primary-key value always gives you access to only one record in the primary
data file: the record at the current position after the KEYPOSITION call.
The read loop is executed twice. The first time through the loop, the read call returns the specified
data record and sets the condition code to CCE, indicating successful completion. The second time
through the loop, the read call 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:
SMITH DAYTON, OH NO 0010.00 0500.00
1
2
EOF
Primary-Key
Field
Example 6: Generic Subset by Nonentity Alternate Key
This sample TAL code shows how to perform generic positioning by the alternate-key value NO
within the RG access path:
! blank the key
key ':=' " ";
key[1] ':=' key FOR name^len - 1 BYTES;
key ':=' "NO";
generic = 1;
CALL KEYPOSITION ( cust^filenum, key, "RG",, 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 NO as the first two characters in the region (RG) field. Access is by the
alternate-key access path RG.
Successive read calls within the read loop access all of the records in the primary data file that
contain the value NO as the first two characters in the RG 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:
94 Key-Sequenced Files