Notes on PRINT and INPUT
Because the PRINT and INPUT statements are designed mainly for use with
the screen and keyboard, you must take care when using them with files.
The PRINT statement uses three forms of separator:
- the ; (semi colon) prints nothing,
- the, (comma) takes you to the start of the next half line,
-
the ’ (apostrophe) gives a new line (the ENTER code).
The INPUT statement always expects you to type ENTER after a number or
a string. So. when you are printing to any file from which you expect to INPUT,
you must either:
- print the items singly, e.g.
10 PRINT #4;2
20 PRINT #4;3
- separate them with an apostrophe, e.g.
10 PRINT#4;2’3
You must also take care when using separators in an INPUT statement. As you
know, INPUT can print to the bottom half of the screen anything that you
can put in a PRINT statement. But when you INPUT from a file, the file is
only open for reading. So, if you include anything that would be printed when
using the screen, you will get the error report Writing to a ‘read’ file. This
means that items in the INPUT statement should be separated with a semi
colon, e.g.
10 INPUT #4:a:b
Be careful also when you INPUT a string containing ” (quotes), because the
INPUT will think that the ” is the end of the string. The way round this is to
replace, for example:
10 INPUT#4;a$
with
10 INPUT#4; LINE a$
25