EasyManua.ls Logo

Commodore 1570 - Page 79

Commodore 1570
132 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
THE BUFFER POINTER
The buffer pointer points to where the next READ or WRITE will begin within a disk
memory buffer.
By
moving the buffer pointer, you can access individual bytes within a
block
in
any order. This allows you to edit any portion of a sector, or organize
it
into
fields, like a relative record.
FORMAT FOR THE BUFFER-POINTER COMMAND:
PRINT # IS,
"B
UFFER -POINTER" ;channel # ;byte
usually abbreviated
as:
PRINT#
IS,
"B-P"
;channel #;byte
where "channel
#"
is
the channel number specified when the
file
reserving the buffer
was opened, and
"byte"
is
the character number within the buffer
at
which to point.
ALTERNATE FORMATS:
PRINT#
IS, "B-P: "channel #;byte
PRINT#
IS, "B-P:channel
#;byte"
EXAMPLE:
Here
is
a program that locks the first program or
file
on a diskette.
It
works
by
reading the start
of
the directory (Track 18, Sector
1)
into disk memory, setting the buffer
pointer to the first
file
type byte (see Appendix C for details of directory organization),
locking it
by
setting bit 6 and rewriting it.
110 OPEN
IS,8,IS
120 OPEN
S,8,S,"#"
130
PRINT#IS,"UI";S;0;18;1
140
PRINT#IS,"B-P";S;2
ISOGET#S,A$:IF
A$=""
THEN A$=CHR$(O)
160
A=ASqA$)
OR 64
170
PRINT#IS,"B-P";S;2
180
PRINT#S,CHR$(A);
190
PRINT#IS,"U2";S;0;18;1
200 CLOSE S
210 CLOSE
IS
220 END
Open command channel.
Open direct access channel.
Read Track 18, Sector I.
Point to Byte 2 of the buffer.
Read
it
into memory.
Turn
on
bit 6 to lock.
Point to Byte 2 again.
Overwrite
it
in
buffer.
Rewrite buffer to diskette.
Tidy up after.
After the above program
is
run, the first
file
on that diskette can no longer be erased. If
you later need to erase that file, rerun the same program, but substitute the revised line
160 below to unlock the
file
again:
160
A=ASC(A$)
AND
191
Turn off bit 6
to
unlock
71

Related product manuals