Chapter
10
I
BASIC
Keywords
The comma tells BASIC
to
tab between
A
and B, which creates
10
extra spaces in the file. Generally you do not want
to
use up
storage space this way,
so
you use semicolons instead
of
commas.
PRINT# 1,
A;
”
,
‘I*
This time BASIC writes the data as:
123.45,l .303
An INPUT# statement reads this as
2
separate fields.
If string variables contain commas, semicolons,
or
leading
blanks, enclose them in quotation marks. For example:
A$
=
CAMERA, AUTOMATIC
E$
=
102382
PRINT#
1,
A$;
E$
writes the data as:
CAMERAMMM~MMMM~~AUTOMATICl82382
An INPUT# statement reads this as
2
separate fields
A$
=
CAMERA
E$
=
AUTOMATIC182382
To separate these
2
strings properly in the file, write quotation
marks using the hexadecimal representation CHR$(34). For
example
:
PRINT# 1, CHR$(34);
A$;
CHR$(34);
E$;
CHRs(34)
BASIC writes the following image
to
the file:
“CAMERA, AUTOMATIC”1 02382”
The statement INPUT#
1,
A$,
B$
reads
“CAM-
ERA,AUTOMATIC” into A$ and
“102382”
into B$.
277