EasyManua.ls Logo

Commodore 1570 - Page 75

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...
CHAPTER 7
DIRECT ACCESS COMMANDS
A
TOOL
FOR
ADVANCED USERS
Direct access commands specify individual sectors on the diskette, reading and
writing information entirely under your direction. This gives them almost complete
flexibility
in
data-handling programs, but imposes tremendous responsibilities on the
programmer, to be sure nothing goes awry.
As
a result. they are normally used only
in
complex commercial programs able to properly organize data without help from th" disk
drive itself.
A far more common use
of
direct access commands
is
in
utility programs used to
view and alter parts
of
the diskette that are not nonnally seen directly. For instance, such
commands can be used to change the name
of
a diskette without erasing
all
of
its
programs, to lock a program so
it
can't
be
erased, or hide your name
in
a location where
it
won't be expected.
In
this chapter we will describe the DOS commands for directly reading and writing
any track and block on the diskette,
as
well
as
the commands used
to
mark blocks
as
used
or unused.
OPENING A DATA CHANNEL FOR DIRECT ACCESS
When working with direct access data, you need two channels open to the disk: the
command channel we've used throughout
the
book, and another for data. The command
channel
is
opened with the usual OPEN 15,8,15 or equivalent. A direct access data
channel
is
opened much like other files, except that the pound sign
(#),
optionally
followed by a memory buffer number,
is
used
as
a
file
name.
FORMAT FOR DIRECT ACCESS FILE OPEN STATEMENTS:
OPEN file # ,device
#,
channel
#,
"#buffer
#"
where "file
#"
is
the
file
number, "device
#"
is
the disk's device number, nonnally
8;
"channel
#"
is
the channel number, a number between 2 and
14
that
is
not used
by
othe~
files open
at
the same time; and "buffer
#,"
if present,
is
a 0,
I,
2, or 3, specifying the
memory buffer within the
1571
to
use for this file's data.
EXAMPLES:
If we don't specify which disk buffer to use, the
1571
will select one:
OPEN
5,8,5,"
#"
Or we can make the choice ourselves:
OPEN
4,8,4,"#2"
67

Related product manuals