EasyManua.ls Logo

Commodore 1541-II - Reading a Relative Record

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...
2030
IF
LEN(SA$)>27
THEN
2020
2035
SA$
=
SA$
+
LEFT$(BL$,27-LN)
2040
INPUT"CITY
&
STATE";CS$
2045LN
=
LEN(CS$)
2050
IF
LEN(CS$)>23
THEN
2040
2055
CSS
=
CSS
+
LEFT$(BL$,23
-LN)
2060
ENfPUT'ZIP
CODE";ZP$
2065LN
=
LEN(ZP$)
2070
IF
LEN(ZP$)>
10
THEN
2060
2075
ZP$
=
ZP$
+
LEFT$(BL$,10-LN)
2080
DAS = NAS
+
SAS
+
CSS+ZPS
Note
lack
of
separators
2120RH
=
INT(RE/256)
2130RL
=
RE-256*RH
2140PRINT#15,"P"+CHR$(96
+
3)
+
CHRS(RL)
+
CHRS(RH)+CHRS
(1)
2150
GOSUB
59990
2160
PRINT#3
,DA$;
Note
added
semicolon
2170
GOSUB
59990
2180
PRINT#
15,"P"
+
CHR$(96
+
3)
+
CHRS(RL)
+
CHRS(RH)
+
CHRS
(1)
2190
GOSUB
59990
If
field
contents
vary
in
length,
variable
field
lengths
are
often
preferable.
On
the
other
hand,
if
the
field
lengths
are
stable,
fixed
field
lengths
are
preferable.
Fixed
length
fields
are
also
required
if
you
want
to
use
the
optional
offset
parameter
of
the
Record#
command
to
point
at
a
particular
byte
within
a
record.
However,
one
warning
must
be
made
about
using
the
offset
this
way.
When
any
part
of a
record
is
written,
DOS
overwrites
any
remaining
spaces
in
the
record.
Thus,
if
you
must
use
the
offset
option,
never
update
any
field
in
a
record
other
than
the
last
one
unless
all
succeeding
fields
will
also
be
updated
from
memory
later.
The
above
programs
are
careful
to
match
record
lengths
exactly
to
the
space
available.
Programs
that
don't
do
so
will
discover
that
DOS
pads
short
records
out
to
full
size
with
fill
characters,
and
truncates
overlong
records
to
fill
only
their
allotted
space.
When
a
record
is
truncated,
DOS
will
indicate
error
51,''RECORD
OVERFLOW'',
but
short
records
will
be
accepted
without
a
DOS
error
message.
READING
A
RELATIVE
RECORD
Once
a
relative
record
has
been
written
properly
to
diskette,
reading
it
back
into
computer
memory
is
fairly
simple,
but
the
procedure
again
varies,
depending
on
whether
it
uses
fixed
or
variable
length
fields.
Here
are
the
program
lines
needed
to
read
back
the
variable
fields
created
above
from
record
number
RE
in
file
and
channel
3:
3000
RH
=
INT(RE/256)
Calculate
record
number
3010RL
=
RE-256*RH
3020
PRINT#15,ttP"+CHR$(96
+
3)
+
CHRS(RL)
+
CHR$(RH)
+
CHRS
(1)
Position
to
record
number
RE
63

Table of Contents

Related product manuals