Opening A Channel For Random Access Data; Block-Read - Commodore 1541 User Manual

Disk drive
Hide thumbs Also See for 1541:
Table of Contents

Advertisement

OPENING A DATA CHANNEL FOR RANDOM ACCESS
When working with random access files, you need to have 2 channels open to the
disk: one for the commands, and the other for the data. The command channel is
OPENed to channel 15, just like other disk commands you've encountered so far. The
data channel for random access files is OPENed by selecting the pound sign (#) as the
file name.
FORMAT FOR OPEN STATEMENT FOR RANDOM ACCESS DATA:
OPEN file#, device#, channel#, "#"
or optionally
OPEN file#, device#, channel#, "#buffer#"
EXAMPLES OF OPENING RANDOM ACCESS DATA CHANNEL:
if
OPEN 5, 8, 5, "#"
^DON'T CARE WHICH BUFFER
OPEN A, B, C, "#2^
_^( PICK BUFFER |
BLOCK-READ
FORMAT FOR BLOCK-READ COMMAND:
PRINT#file#, "BLOCK-READ:" channel; drive; track; block
or abbreviated as
PRINT#file#, "B-R:" channel; drive; track; block
This command will move one block of data from the diskette into the selected
channel. Once this operation has been performed, the INPUT# and GET# statements
can read the information.
SAMPLE PROGRAM TO READ BLOCK 2 FROM TRACK 18: (stores contents in
B$)
^ DRIVE
CHANNEL A
10
OPEN15,8,15
20
OPEN5,8,5,"#"
30
PRINT#15,"B-R:"5;O;1~8;2
40
B$=""
50
FORL = 0TO255
60
GET#5,A$
70
IF ST = 0 THENBS = B$ + A$:NEXTL
80
PRINT "FINISHED"
90
CLOSE5:CLOSE15
\COLLECT ENTIRE
BLOCK: BYTE
BY BYTE

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents