EasyManua.ls Logo

Commodore 1541-II - Closing a File

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...
However,
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
redirected
to
the
screen,
will
display
only
one
data
item
per
line,
with
each
succeeding
item
on
the
next
line.
CLOSING
A
FILE
WHEN
YOU
ARE
DONE
USING
IT
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
physical
cassette
or
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
or
cassette
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
performed
during
the
ordinary
course
of
writing
a
file.
This
is
the
reason
for
having
a
Close
statement.
When
we
know we
are
done
with
a
file,
the
Close
statement
will
write the
rest
of
the
data
buffer
out
to
cassette
or
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
(described
in
the
last
chapter),
when
used,
should
be
the
first
file
Opened,
and
the
last
file
Closed
in
any
program.
Otherwise,
remaining
files
may
be
closed
automatically.
As
also
described
there,
this
may
be used
to
advantage
if
a
program
halts
on
an
error
while
disk
files
are
open.
FORMAT
FOR
THE
CLOSE
STATEMENT
CLOSE
file
#
where
"file
#"
is
the
same
file
number
given
in
the
desired
file's
current
Open
statement.
EXAMPLES:
To
close
the
data
file
#5
used
as
an
example
on
the
previous
page,
we
would
use
CLOSE
5
In
Commodore's
CBM
and
PET
computers,
there
is
a
Dclose
statement,
that,
when
used
alone,
closes
all
disk
files
at
once.
With
a
bit
of
planning,
the
same
can
be
done
in
Basic
2
and
3.5
via
a
program
loop.
Since
there
is
no
harm
in
closing
a
file
that
wasn't
48

Table of Contents

Related product manuals