Create A Relative File - Commodore 1541 User Manual

Hide thumbs Also See for 1541:
Table of Contents

Advertisement

8005
PRINT#l,"P1'CHRS<2 + 96>CHRS(I)CHRS(0)CHR$<25) :REM POSITION FILE
POINTER
8007
PRINT#2,CS(I)
8009
PR1NT"RECORD#";1;"HAS BEEN REPLACED"
8010
RETURN
CREATE A RELATIVE FILE
The program below, creates a relative file with 2 fields. The first field starts in
position 1 of the record and the second field starts in position 25.
LINE 8: Create the file. Make room for records of 50 characters with the CHR$(50).
Use the Z$ as a file, input variable in LINE 6, you can then press the fl function key to
create a file.
LINE 30: Point to the first character position of a file. P tells the disk drive to point to
the position in the record that corresponds to the optionaJ, CHR$(1).
NOTE: If the CHRS is not specified, character position defaults to ].
LINE 65: Point to the twenty-fifth character position of a file. P tells the disk drive to
point to the position in the record that corresponds to the CHR$(25).
NOTE: The POSITION command docs NOT write anything to, or read anything
from the file. It just points to the position specified in the record.
WRITE TO A RELATIVE FILE
LINE 60: Use the PRINTS statement after ihe POSITION command to move to
character position I, as specified in LINE 30 — CHR$(1).
READ FROM A RELATIVE FILE
LINE 130: Specify the character position using the POSITION command. Then follow
it with LINE 160, the INPUT/* statement.
SUMMARY
In this program, you press the fl key and a RELative file is created on disk. You
can type RUN and press the D key to READ the previous RELative file. If an error
condition exists (flashing red light on the disk drive) you can hit the RUN/STOP key,
type RUN and press the f5 key. This reads the ERROR CHANNEL from the drive,
shows the enor number and message, as well as the track and sector of the error. It
then resets the drive for use. Later on the program asks if the file should be printed. To
print the file, press the 17 key when prompted, or press C to continue.
43

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents