Download FLEX Advanced Programmer`s Manual

Transcript
FLEX Advanced Programmer’s Guide
Function 21 ($15 hex) - Position to Record N
This is one of the 2 function codes provided for random file
accessing by sector.
The desired record number to be accessed
should be stored in the FCB location Current Record Number (a 16
bit binary value). The file must be open for read or update before
using this function code. The first data record of a file is
record number one. Positioning to record 0 will read in the first
sector of the File Sector Map.
After a successful Position
operation, the first character read with a sequential read will be
the first data byte of the specified record.
An attempt to
position to a nonexistent record will cause an error. For more
information on random files see the section titled ’Random Files’.
Example:
To position to record #6
LDX #FCB
Point to FCB
LDA #6
Set position
STA 33,X
Put in FCB
CLR 32,X
Set M.S.B. to 0
LDA #21
Setup function code
STA 0,X
Store in FCB
JSR FMS
Call FMS
BNE ERROR
Check for errors
Record ready to be read
Function 22 ($0A hex) - Backup One Record
This is also used for random file accessing. This function takes
the Current Record Number in the FCB and decrements it by one.
A
Position to the new record is performed. This has the effect of
back spacing one full record. For example, if the Current Record
Number is 16 and the Backup One Record function is performed, the
file would be positioned to read the first byte of record #15. The
file must be open for read or update before this function may be
used. See ’Random Files’ section for details.
-36-