EasyManua.ls Logo

Commodore Plus 4 - Page 352

Commodore Plus 4
464 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...
340
Using
Peripheral
Devices
Example:
This
example
should
be
run
only
on
a
formatted
disk
containing
no
information
you
want
to
preserve.
It
allocates
the
desired
block.
Unless
the
block
you
specify
was
already
allocated,
a
DIRECTORY
performed
prior
to
running
the
program
shows
one
more
free
block
than
one
performed
after
running
the
program.
10
0PEliri5,8,15,"I"
20
IFDSO0THEUPRI]SrTDS$:G0T080
30
OPEN1,8,2,"#"
40
IFDSO0THElSrPRINTDS$:G0T080
50
PRINT"WHICH
TRACK,
SECTOR"
;:INPUTT,S
60
PRINT#15/'B-A:'';0;T;S
70
IFDSOOTHENPRIITTDSI
80
CLOSE1:CLOSE15
Example:
Line-by-Line
Explanation
10
Open
the
command
channel
and
initialize
the
disk.
20
Check
for
error.
If
one
is
found,
exit.
30
Open
the
direct
access
channel.
40
Check
for
error.
If
one
is
found,
exit.
50
Ask
which
track
and
sector
to
use.
60
Allocate
the
specified
sector.
70
Check
for
error.
If
one
is
found,
exit.
80
Close
the
files.
Block
Free
(B-F)
The
block
free
command
updates
the
BAM
to
show
the
designated
sector
as
not
used.
The
BAM
is
actually
written
out
to
the
disk
when
a
direct-access
channel
is
closed,
so
it
is
a
good
idea
to
open
and
close
a
direct-access
channel
when
freeing
a
block,
even
if
it
is
not
needed
for
any
other
purpose.
The
syntax
for
a
block
free
is
PRINT*
filenumber,"B-'F:";
drive;track;seotor
where
filenumber
is
the
logical
file
number
of
the
command
channel
and
drive
is
the
drive
number.
The
track
can
be
any
track
on
the
diskette
(1
to
35)
and
the
sector
any
sector
of
that
track.
This
example
should
be
run
only
on
a
formatted
disk
containing
no
information
you
want
to
preserve.
It
frees
the
desired
block.
Unless
the
block
you
specify
was