Expanding A Relative File; Expanding A File - Commodore 2031 User Manual

Hide thumbs Also See for 2031:
Table of Contents

Advertisement

Line 130 positions the file pointer to record number 100 which does not yet exist.
The message 50 RECORD NOT PRESENT will occur at this point, but should
be interpreted as a warning rather than an error condition. This message is
normally expected to occur as a warning when a new record is positioned to for
the first time and indicates that no INPUT or GET operation should be attempted.
Line 150 causes record number 100 (because of the pointer positioning by line
130) to be written. During this write operation, the DOS detects that record 1
thru 99 do not already exist, and automatically initializes them by placing
CHR$(255) in the first character.
Line 170 closes the file and causes the space to be allocated in the BAM and file
directory.
Lines 190-220 are the error subroutine. If DS is less than 20, no error condition
exists, so line 190 would return control to the main program. Line 200 prints the
error message, and line 210 returns to the main program if the message was 50
RECORD NOT PRESENT. If some other unexpected error (such as a read error) occurs,
line 220 will halt the program so the user can correct the problem.
After the file has been initialized, data may be written to the file.
Initialization of a file in this manner need be performed only once when the file
is originally created. If the user wishes to expand an existing file, the same
procedure would be used, with the record number (line 130 in the example) changed
to be the new last record.
The following example, when with the disk containing the file FILE1 (with 100
records) in drive 0, will result in the first 100 records remaining unchanged and
records containing only CHR$(255) would be generated for records 101-200.
110 DOPEN#1,"FILE1",D0,L50
120 GOSUB 190
130 RECORD#1,200
140 GOSUB 190
170 DCLOSE#1
180 END
190 IF DS<20 THEN RETURN
200 PRINT DS$
210 IF DS=50 THEN RETURN
220 STOP

EXPANDING A RELATIVE FILE

65

Advertisement

Table of Contents
loading

Table of Contents