EasyManua.ls Logo

Commodore 1570 - Page 55

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...
assuming your program includes an error check subroutine like the one
in
the last chapter.
usc:
To read back
in
the address data written by another
PRINT#
example,
it
is
safest to
800INPUT#5,NAME$
810 GOSUB 59990:REM CHECK FOR DISK ERRORS
820INPUT#5,STREET$
830 GOSUB 59990:REM CHECK FOR DISK ERRORS
840INPUT#5,CITY$
850 GOSUB 59990:REM CHECK FOR DISK ERRORS
but many programs cheat on safety a bit and use
800INPUT#5,NAME$,STREET$,CITY$
810 GOSUB 59990:REM CHECK FOR DISK ERRORS
This
is
done primarily when top speed
in
the program
is
essential, and there
is
little risk
of
reading improper data from the file.
MORE ABOUT
INPUT#
(ADVANCED USERS)
Troublesome Characters
After you begin using data files regularly, you may encounter two BASIC error
messages. They are
"STRING
TOO LONG
ERROR"
and
"FILE
DATA
ERROR".
Both are likely to halt your program at an
INPUT#
statement, but may also have been
caused by errors
in
a
PRINT#
statement when the file was written.
"STRING
TOO
LONG"
ERRORS
A BASIC string may be up to 255 character, long, although the longest string you
can enter via a single Input statement is just under two lines
of
text. This lower limitation
is
due to the size
of
the input buffer
in
Commodore's serial bus computers. The same limit
applies to
INPUT#
statements.
If
a single data element (string or number) being read
from a disk file into an
INPUT#
statement contains more than 88 (BASIC
2)
and 160
(BASIC
7)
characters, BASIC will halt with a
"STRING
TOO LONG
ERROR."
"FILE
DATA"
ERRORS
The other error message
"FILE
DATA
ERROR"
is
caused
by
attempting to read a
non-numeric character into a numeric variable. To a computer, a number
IS the characters
o through 9,
the"
+"
and"
-"
signs, the decimal point (
).
the SPACE character. and
the letter
"E"
used
in
scientific notation.
If
any other character appears
in
an
INPUT#
to
a numeric variable,
"FILE
DATA
ERROR"
will be displayed and the program will halt.
The usual causes
of
this error are a mismatch between the order m which variables are
written to and read from a
me.
a missing carriage return within a
PRINT#
statemcnt that
writes more than one data item. or a data item Ihat includes cither a comma or a colon
without a preceding quotation mark. Oncc a
tile data error has occurred. you should
correct it by reading the data item into a string
variabk.
and
CtlllvCrt1l1g
it
hack
to
a
number with the BASIC V
AU)
,talemcnl aftcr rcmovll1g
nOn-IlUTllCrIC
characters with the
string functions described
in
your computer uscr's manual
47

Related product manuals