400 PRINT NAME$,STREET$,CITY$
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$
4\0
PRINT#5,STREET$
420
PRINT#5,CITY$
If you need to combine them, here
is
a safe way to do
it:
400
PRINT#5
,NAME$;CHR$(
13
);STREET$;CHR$( 13);CITY$
CHR$(l3)
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):
10
CR$=CHR$(13)
400 PRINT#5,NAME$;CR$;STREET$;CR$;CITY$
The basic idea is that a proper sequential disk-tile 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
After you tinish using a data file, it
is
extremcly 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 tills.
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
sectnrs used by the current tile, which are
not performed during the ordinary course
of
writing a Iile. 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 arc donc using it. Failure to do so may cause
loss
of
the entire tlle.
However, do not close the disk command channel until all other files have been
closed. The command channel should be the tirst
file
opened, and the last
file
closed
in
any program.
FORMAT FOR THE CLOSE STATEMENT
BASIC 7.0:
DCLOSE#file#
[,Udevice#J
BASIC 2.0: CLOSE file #
where
"tile
#"
is the same
flle
number given
in
the desired
lik's
current OPEN
statement.
45