EasyManua.ls Logo

Commodore 1581 - Closing a File

Commodore 1581
138 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...
To
get
those
same
variables
onto
sequential
disk
file
number
5
instead
of
the
screen,
the
best
approach
would
be
to
use
three
separate
PRINT#
statements,
as
follows:
400
PRINT#5,NAME$
410
PRINT#5,STREET$
420
PRINT#5,CITY$
If
you
need
to
combine
them,
here
is
a
safe
way
to
do
it:
400PRINT#5,NAME$;CHR$(13);STREET$;CHR$(13);CITY$
CHR$(13)
is
the
carriage
return
character,
and
has
the
same
effect
as
putting
the
print
items
in
separate
lines.
If
you
do
this
often,
some
space
and
time
may
be
saved
by
previously
defining
a
variable
as
equal
to
CHR$(13):
10CR$
=
CHR$(13)
400PRINT#5,NAME$;CR$;STREET$;CR$;CITY$
The
basic
idea
is
that
a
proper
sequential
disk-file
write,
if
redir
ected
to
the
screen,
will
display
only
one
data
item
per
line,
with
each
succeeding
item
on
the
next
line.
CLOSING
A
FILE
After
you
finish
using
a
data
file,
it
is
extremely
important
that
you
CLOSE
it.
During
the
process
of
writing
a
file,
data
is
accumulated
in
a
memory
buffer,
and
only
written
out
to
the
diskette
when
the
buffer
fills.
Working
this
way,
there
is
almost
always
a
small
amount
of
data
in
the
buffer
that
has not
been
written
to
diskette
yet,
and
which
would
simply
be
lost
if
the
computer
system
were
turned
off.
Similarly,
there
are
diskette
housekeeping
matters,
such
as
updating
the
BAM
(Block
Availability
Map)
of
sectors
used
by
the
current
file,
which
are
not
per
formed
during
the
ordinary
course
of
writing
a
file.
This
is
the
reason
for
having
a
CLOSE
statement.
When
you
are
done
with
a
file,
the
CLOSE
statement
will
write the
rest
of
the
data
buffer
out
to
diskette,
update
the
BAM,
and
complete
the
file's
entry
in
the
directory.
Always
close
a
data
file
when
you
are
done
using
it.
Failure
to
do
so
may
cause
loss
of
the
entire
file.
However,
do
not
close
the
disk
command
channel
until
all
other
files
have
been
closed.
The
command
channel
should
be
the
first
file
opened,
and
the
last
file
closed
in
any
program.
43

Table of Contents

Other manuals for Commodore 1581

Related product manuals