Commodore 2040 User Manual page 75

Cbm 5 1/4-inch dual floppy disk drives
Hide thumbs Also See for 2040:
Table of Contents

Advertisement

The following program illustrates the feature which permits access to individual bytes within
a record:
110 DOPEN#1,"FILE1",DO
120 GOSUB 900
130 RECORD#1,25,1
140 GOSUB 900
150 PRINT#l,"FIELD 1"
160 GOSUB 900
170 RECORD#1,25,10
180 GOSUB 900
190 PRINT#l,"FIELD 2"
200 GOSUB 900
210 RECORD#1,25,30
220 GOSUB 900
230 PRINT#l,"FIELD 3"
240 GOSUB 900
250 DCLOSE#l
260 END
900 IF DS<20 THEN RETURN
910 PRINT DS$
920 STOP
Lines 130, 170, and 210 cause the file pointer to be moved to different places within record
number 25. The following illustration is a representation of the contents of record number
25 after the above example is executed:
1
2 3 4
5
12345678901234567890123456789012345678901234567890
FIELD 1* FIELD 2*
FIELD 3*
74
Where * represents a carriage return ( CHR$(13) ).
NOTE:
It
is important that the fields be written in sequence, since writing to a byte at the
beginning of the record destroys the rest of the record in memory. For example, this means
that while it is possible to position and write first to byte 1 and then to byte 20, it is NOT
possible to first write byte 20 and then byte 1.
Since the carriage return is recognized as a terminator by the BASIC INPUT statement, the
data may be retrieved by the following sequence:
110 DOPEN#1,"FILE1",DO
120 GOSUB 290
130 RECORD#1,25
140 GOSUB 290
150 RECORD#I,25,I:GOSUB 290
160 INPUT#I,A$:GOSUB 290
170 RECORD#1,25,10:GOSUB 290
180 INPUT#l,B$:GOSUB 290
190 RECORD#I,25,30:GOSUB 290
200 INPUT#I,C$:GOSUB 290
210 DCLOSE#1
220 END
290 IF DS<20 THEN RETURN
300 PRINT DS$
320 STOP

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

304040408050

Table of Contents