Using KSAM/XL and KSAM 64 (32650-90886)

Appendix B 253
BASIC/V Intrinsics
BKREWRITE
NOTE
Items written to a KSAM file with the BKREWRITE procedure are
concatenated; rounding to halfword boundaries does not occur.
The example in Figure B-9. writes new values to a record originally written in Figure B-13.
and read in Figure B-5. The new values fill an array that had undefined values in the last
five elements, now defined as two arrays A3 and A2 by the
BKREAD
call. The primary key
value 23 in location 2 is unchanged.
The record read by
BKREAD
contained the following values:
Figure B-7. BKREAD values
After being rewritten by BKREWRITE, it contains the following values:
Figure B-8. After BKREWRITE
When access is shared, the call to BKREAD, BKREADBYKEY, or BKSTART that locates the
record to be rewritten should be included in the same pair of BKLOCK/BKUNLOCK calls as the
call to BKREWRITE. This ensures that no other user alters the record pointer between the
call that locates the record and the call that rewrites it.
If you want to sequentially rewrite all records in a chain of records with duplicate keys,
locate the first record in the chain with BKREADBYKEY. Then call BKREWRITE to modify this
record. If no key value (the selected key or any other) is modified, subsequent calls to
BKREWRITE will modify the next sequential records in the chain of duplicate keys. If,
however, any key has been changed, the modified key is written to the end of the chain and
the next sequential record is one with the next higher key value. In this case, to rewrite all
records with duplicate keys, precede each call to BKREWRITE by a call to BKREADBYKEY.
Figure B-9. Rewriting Record in KSAM File with BKREWRITE
2600 REM
2610 REM *********************************************************
2620 REM * REVISE THE CONTENTS OF A RECORD READ FROM A KSAM FILE *
2630 REM **********************************************************