EasyManua.ls Logo

Commodore Plus 4 - Page 340

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...
328
Using
Peripheral
Devices
Program
Files
The
program
file
type
is
used
for
storage
of
programs.
It
can
also
be
used
for
data
storage
and
is
opened
with
a
file
type
parameter
of
P.
Its
format
is
identical
to
the
sequential
file
format.
When
a
program
file
is
created
by
a
save
command,
the
first
2
bytes
of
the
file
contain
the
address
from
which
the
program
was
saved.
The
following
example
illustrates
this.
Type
in
the
program
and
save
it
with
the
following
command:
DSAVE'TROGRAM"
Then
run
the
program.
It
reads
in
the
load
address
that
was
saved
in
the
file
and
prints
it
out.
Example:
10
0PENl,8,2,"PR0GRAM"
20
IPDS<>OTHEITPRI]SrTDS$:CLOSEl:E]SrD
30
GET#lrAL$:GET#lrAH$
40
A=ASC(AH$)*256+ASC(AL$)
50
PRI^'THE
LOAD
ADDRESS
IS
";A
60
CLOSE1
Line-by-Line
Explanation
10
Open
the
program
file
with
read
access
(the
default).
20
Check
for
errors.
If
there
is
an
error,
quit.
30
Get
the
first
2
bytes
in
the
file.
40
Calculate
the
load
address.
50
Output
the
load
address.
60
Close
the
file.
Relative
Files
The
types
of
files
discussed
previously
store
information
sequentially;
that
is,
to
read
a
single
item
somewhere
in
the
middle
of
the
file,
you
must
first
read
all
the
items
before
it.
To
reread
the
item,
you
must
start
at
the
beginning
again.
When
data
will
be
accessed
in
a
"random"
fashion
(i.e.,
you
are
equally
likely
to
want
to
access
any
piece
of
data),
a
relative
file
can
be
used.
A
relative
file
is
opened
with
a
file-type
parameter
of
L.
A
relative
file
is
a
series
of
"records."
Each
record
contains
the
data
for
one
individual
in
the
database
and
is
of
a
predetermined
length.
When
you
create
a
relative
file,
the
record
length
must
be
specified.
The
syntax
is