EasyManua.ls Logo

Commodore 1570 - Page 56

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...
COMMAS (,) AND COLONS (:)
As
suggested before, commas and colons can cause trouble in a file, because they
delimit (end) the data element in which they appear and cause any remaining characters in
the data element to be read into the next
INPUT#
variable. They have the same effect in
an INPUT statement, causing the common
"EXTRA
IGNORED" error message. How-
ever, sometimes you really need a comma or colon within a data element, such
as
a name
written as
"Last,
First." The cure
is
to
precede such data elements with a quotation mark.
After a quotation mark,
in
either an INPUT or INPUT# statement, all other characters
except a carriage return or another quotation mark are accepted
as
part
of
the current data
element.
EXAMPLES:
To force a quotation mark into a data element going
to
a file, append a CHR$(34)
to
the start
of
the data element. For example:
PRINT#2,CHR$(34)
+
"DOE,
JOHN"
or
PRINT#2,CHR$(34);"DOE,
JOHN"
If you do this often, some space and time may be saved
by
previously defining a variable
as equal
to
CHR$(34)
as
we
did earlier with CHR$(l3):
20 QT$ = CHR$(34)
400 PRINT#5,QT$
+ NAME$
In
each case, the added quotation mark will be stripped from the data
by
the Input or
INPUT# statement, but the comma or colon will remain part
of
the data.
NUMERIC
DATA
STORAGE
ON
DISKETTE
Up
to
this point
we
have discussed string data storage, now let's look at numeric
storage.
Inside the computer, the space occupied
by
a numeric variable depends only on
its
type. Simple numeric variables use seven bytes (character locations) of memory. Real
array variables use
five
bytes per array element, and integer array elements use two bytes
each.
In
contrast, when a numeric variable or any type
is
written
to
a file,
the
space it
occupies depends entirely on its length,
not
its
type. This
is
because numeric data
is
written
to
a file
in
the form of a string,
as
if the STR$O function had been performed on
it.
The first character will
be
a blank space if the number
is
positive, and a minus sign ( - ) if
the number
is
negative. Then comes the number, digit-by-digit. The last character
is
a
cursor right character.
This format allows the disk data to be read back into a string or numeric variable
later. It is, however, wasteful
of
disk space, and
it
can
be
difficult
to
anticipate the space
required
by
numbers
of
unknown length. For this reason, some programs convert
all
48

Related product manuals