EasyManua.ls Logo

Commodore 1570 - Page 52

Commodore 1570
132 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...
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 wasted on the diskette, and may create more problems when reading the file
back into the computer. Therefore, follow the following format precisely when sending
data to a disk file.
FORMAT FOR
THE
PRINT#
COMMAND:
PRINT#file # ,data list
where
"file
#"
is
the same file number given
in
the desired file's current OPEN
statement. During any given access
of
a particular file, the
file
number must remain
constant because it serves as a shorthand way
of
relating all other file-handling commands
back to the correct OPEN statement. Given a
file
number, the computer can look up
everything else about a file that matters.
The
"data
list"
is
the same as for a PRINT statement - a list
of
constants, variables
and/or expressions, including numbers, strings or both. However, it's better
if
each
PRINT#
statement to disk include only one data item. If you wish
to
include more items,
they should be separated by a carriage return character, not a comma. Semicolons are
permitted, but not recorded
in
the tile, and do not result
in
any added spaces in the file.
Use them
to
separate items
in
the list that might otherwise be confused, such as a string
variable immediately following a numeric variable.
NOTE: Do not leave a space between PRINT and
#,
and do not abbreviate the
command as
?#.
The correct abbreviation for
PRINT#
is
pRo
EXAMPLES:
To record a
few
grades for John Paul Jones, using a sequential disk file # I previously
opened for writing, use:
200 FOR CLASS
= 1 TO COURSES
210
PRINT#I.GRADE$(CLASS)
220 GOSUB 59990:REM CHECK FOR DISK ERRORS
320 NEXT CLASS
assuming your program includes an error check subroutine like the one
in
the last chapter.
In
using
PRINT#,
there
is
an exception to the requirement
to
check for disk errors
after every file-handling statement. When using
PRINT#,
a single check after an entire
set
of
data has been written will still detect the error,
so
long as the check is made before
any
other file-handling statement or disk command
is
used. You may be familiar with
PRINT statements
in
which several items follow each other:
44

Related product manuals