The Value Of Index Files; Chapter 7: Direct Access Commands; Diskette Organization - Commodore 1541 User Manual

Hide thumbs Also See for 1541:
Table of Contents

Advertisement

3030
GOSUB 59990
3040
INPUT# l
,NA$,SA$,CS$,ZP$
3050 GOSUB 59990
3060
PRINT#l5,
"P" +CHR$(96+ 3) +
CHR$(RL)
+
CHR$(RH)
Check for disk
errors
Read
in
fields
Re-position for
safety
Here are the Jines needed to read back the version with fixed length
fields
:
3000
RH= INT(RFJ256)
3010 RL=RE-256*RH
3020
PRINT#l5,"P"
+CHR$(96+3) +CHR$
(
RL)
+
CHR$(RH)
3030
GOSUB 59990
3040
INPUT# l
,DA$
3050 GOSUB 59990
3060 PRINT#l5,
"P" +
CHR$(96+
3) +
CHR$(RL)
+
CHR$(RH)
3070 NA$= LEFf$(DA$,27)
3080
SA$= MID$(DA$
,28 ,27)
3090 CS$= MID$(DA$,55,23)
3100
ZP$
=
RIGHT$(DA$, 10)
Read in entire record
Split data
into fields
This ends our discussion
of
n·l
.111ve
files
.
A complete
"RELA
TIY~
FILE"
program
.
similar
to the examples
in
this
ch.ipt~r.
is included on the Test/Demo diskette
.
CHAPTER 7
DIRECT ACCESS COMMANDS
~
fOOL
FOR ADVANCED USERS
Direct
access commands specify individual sectors on the diskette, reading and
..nung information
entirely
under your
direction
.
This
gives them almost complete
~bility
in data-handling proerams, but
also imposes tremendous responsibilities on the
~er,
to be
sure
nothing
goes awry.
As
a result, they are normally used only
in
tdl!Plex commercial programs
able to
properly
organize
data
without
help
from the
disk
,JIVC
itself.
A
far more
common
use of direct
access commands is in
utility
programs
used
to
fl(9I
and
alter parts
of
the diskette that
are
not normally
seen
directly
.
For instance
.
such
,1Jflll1lllnds can
be used to
change the
name
of a
diskette
without erasing all of its
~s,
to lock a program
so
it
can't be erased
,
or
hide
your
name in
a location where it
'°"'t be expected
.
DISKETTE ORGANIZATION
There
are a total of 683 blocks on a 1541 diskene
,
of which 664 are available for use,
itb
the rest
reserved
for
the
BAM
(Block Availability Map) and
the
Directory
.
The diske!!e's
surface is
divided
into
tracks,
which are
laid
out as concentric circles
111
lhe
surface
of
the diskette
.
There are 35 different
tracks
,
starting with track I at
the
ldlide of the diske!!e to
track 35 at
the
center.
Track 18
is
used
for the directory, and the
DOS
fills up the diskette from the
center outward
,
alternately in
both
directions.
THE VALUE OF INDEX FILES
(ADVANCED
USERS)
Each track is
subdivided
into
sectors (also called
blocks)
.
Because
there is more
.
d
1
.
fil
room
on the
outer
tracks, there are more
sectors
per track there. The
outermost
tracks
In the last two chapters we have learned how to use sequential an re
katlve b
.Cl
1
.mn 21
sectors each
,
while the
innermost ones only
have 17
sectors each
.
The table
ft
d
th
·
th the
sequential
file used to
eep
ne
separately.
But they are o en use toge
.
e r• wi
.
Th
wa the
!Jclow
shows the number of
sectors
per track
.
records of which name in the relative file 1s
stored
m
each
record number.
al
.
Y
1
.
d
·
tri
array and
sorted alphabetical
Y
contents
of the
sequential
file can be rea mto as ng
.
fi
d
an
Table 6.1: Track and Sector Format
After
sorting,
a technique known as
a
binary
search
can be used to
v~ry quic~y·
n
file
TRACK
NUMBER
SECTOR NUMBERS
TOTAL
SECTORS
entered name in the array' and read in or write the associated record m.
the.
re
~uve
21
Ad vanced programs can maintain two or more
such
index files, sorted m
d1ffenng
ways
I to 17
0 through
20
19
18 to
24
0 through 18
simultaneously.
25
to
30
O
through 17
18
64
31 to
35
0 through 16
17
In
this
chapter we
will describe the DOS
commands
for directly
reading and writing
:nylrack
and block
on
the diskette,
as
well as the
commands
used to mark blocks
as
used
llllused. Unless otherwise notes, all direct
access
commands
are the same in both Basic
·and
Basic
3.5
.
OitNiNG
A DATA CHANNEL FOR DIRECT ACCESS
When
working with direct
access
data, you -need two
channels open to
the
disk:
the
' d
channel
we've used throughout the
book, and another for data
.
The command
illne1 is
opened
with the usual OPEN 15,8,15
or equivalent. A direct access data
65

Advertisement

Table of Contents
loading

Table of Contents