EasyManua.ls Logo

Commodore 1541-II - Writing File Data: Print

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...
EXAMPLE:
If
you
are
writing
a
grading
program,
it
would
be
convenient
to
simply
tack
on
each
student's
new
grades
to
the
end
of
their
existing
grade
files.
To
add
data
to
the
"JOHN
PAUL
JONES"
file,
we
could
type
OPEN
1,8,3,"0:JOHN
PAUL
JONES,A"
In
this
case,
DOS
will
allocate
at
least
one
more
sector
(block)
to
the
file
the
first
time
you
append
to
it,
even
if
you
only
add
one
character
of
information.
You
may
also
notice
that
using
the
Collect
or
Validate
command
didn't
correct
the
file
size.
On
the
other
hand,
your
data
is
quite
safe,
and
if
the
wasted
space
becomes
a
problem,
you
can
easily
-correct
it
by
copying
the
file
to
the
same
diskette
or a
different
one,
and
scratching
the
original
file.
Here's
a
sequence
of
commands
that
will
copy
such
files
to
the
original
diskette
under
the
original
name,
for
ease
of
continued
use:
BASIC
2:
PRINT#15,"R0:TEMP
=
JOHN
PAUL
JONES"
PRINT#15,<tC0:JOHN
PAUL
JONES=TEMFf
PRINT#15,"S0:TEMP"
BASIC
3.5:
RENAME
"JOHN
PAUL
JONES"
TO
"TEMP"
COPY
"TEMP"
TO
"JOHN
PAUL
JONES"
SCRATCH
"TEMP"
If
you
are
using
Basic
2,
be
sure
to
open
file
15
to
the
command
channel
beforehand
(i.e.,
with
OPEN
15,8,15)
and
close
it
afterwards
(i.e.,
with
CLOSE
15).
WRITING
FILE
DATA:
USING
PRINT#
After
a
sequential
file
has
been
opened
to
write
(with
a
type
and
direction
of
",S,W"),
we
use
the
Print#
command
to
send
data
to
it
for
storage
on
diskette.
If
you
are
familiar
with
Basic's
Print
statement,
you
will
find
Print#
works
exactly
the
same
way,
except
that
the
list
of
items
following
the
command
word
is
sent
to
a
particular
file,
instead
of
automatically
appearing
on
the
screen.
Even
the
formatting
options
(punctua
tion
and
such)
work
in
much
the
same
way
as
in
Print
statements.
This
means
you
have
to
be
sure
the
items
sent
make
sense
to
the
particular
file
and
device
used.
For
instance,
a
comma
between
variables
in
a
Print
statement
acts
as
a
separator
in
screen
displays,
making
each
successive
item
appear
in
the
next
preset
display
field
(typically
at
the
next
column
whose
number
is
evenly
divisible
by
10).
If
the
same
comma
is
included
between
variables
going
to
a disk
file,
it
will
again
act
as
a
separator,
again
inserting
extra
spaces
into
the
data.
This
time,
however,
it
is
inappropriate,
as
the
extra
spaces
are
simply
wasted
on
the
diskette,
and
may
create
more
problems
when
reading
the
file
back
into
the
computer.
Therefore,
you
are
urged
to
follow
the
following
format
precisely
when
sending
data
to
a
disk
file.
FORMAT
FOR
THE
PRINT
#
STATEMENT
PRINT#file#,data
list
46

Table of Contents

Related product manuals