EasyManua.ls Logo

Commodore 1541-II - The Value of Index Files

Commodore 1541-II
104 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...
3030
GOSUB
59990 Check
for
disk
errors
3040
INPUT#
1
,NA$,SA$,CS$,ZP$
Read
in
fields
3050
GOSUB
59990
3060
PRINT#15,"P"
+CHR$(96
+
3)
+
CHR$(RL)
+
CHR$(RH)
Re-position
for
safety
Here
are
the
lines
needed
to
read
back
the
version
with
fixed
length
fields:
3000RH
=
INT(RE/256)
3010RL
=
RE-256*RH
3020
PRINT#15,"P"
+
CHR$(96
+
3)
+
CHR$
(RL)
+
CHR$(RH)
3030
GOSUB
59990
3040
INPUT#
1
,DA$
Read
in
entire
record
3050
GOSUB
59990
3060
PRINT#15,"P"
+CHR$(96
+
3)
+
CHR$(RL)
+
CHR$(RH)
3070
NA$ =
LEFT$(DA$,27)
Split
data
into
fields
3080
SA$
=
MID$(DA$,28,27)
3090
CS$
=
MID$(DA$,55,23)
3100
ZP$
=
RIGHT$(DA$,
10)
This
ends
our
discussion
of
relative
files.
A
complete
"RELATIVE
FILE"
program,
similar
to
the
examples
in
this
chapter,
is
included
on
the
Test/Demo
diskette.
THE
VALUE
OF
INDEX
FILES
(ADVANCED
USERS)
In
the
last
two
chapters
we
have
learned
how
to
use
sequential
and
relative
files
separately.
But
they
are
often
used
together,
with
the
sequential
file
used
to
keep
brief
records
of
which
name
in
the
relative
file
is
stored
in
each
record
number.
That
way
the
contents
of
the
sequential
file
can
be
read
into
a
string
array
and
sorted
alphabetically.
After
sorting,
a technique
known
as
a
binary
search
can
be
used
to
very
quickly
find
an
entered
name
in
the
array,
and
read
in
or
write
the
associated
record
in
the
relative
file.
Advanced
programs
can
maintain
two
or
more
such
index
files,
sorted
in
differing
ways
simultaneously.
64

Table of Contents

Related product manuals