Chapter
51
Basic
Concepts
Data
Data is information on which BASIC performs its operations.
Data can be numbers, characters,
or
symbols. BASIC classifies
data into two groups: string and numeric.
String
data
is
a sequence
of
ASCII characters, graphics or non-
ASCII symbols. A string can be a maximum of 255 characters.
If
the string is entered
on
a program
or
command line,
it
must
be enclosed in quotation marks (see “Constants” later in this
section). If the string
is
entered in response
to
a prompt, it is not
enclosed in quotation marks. BASIC does not evaluate string
data;
it
simply stores it for the program
to
use
or
manipulate.
Hint:
ASCII stands for American Standard Code for
Information Interchange. In ASCII, each character has
a unique number that represents it. This is necessary
since computers understand and process only numbers.
Here are some sample strings:
“~1~37
“MAIN STREET” “255 CENTRAL AVE”
“25 dollars” “$250” “2
+
4”
Notice that numbers can be in a string. Remember, BASIC does
not evaluate strings. Type the following line at BASIC’s prompt:
PRINT
“2
+
4”
BASIC does not add 2 and
4.
It
obeys the command PRINT and
displays
2
+
4
on your screen.
Strings use
3
bytes
of
memory plus the number of characters in
the string. For example, the string “CATS” takes up 7 bytes
of
memory:
4
for the string plus 3.
Numeric
data consists
of
positive and negative numbers. BASIC
divides numeric data into 5 groups: integer, single precision,
double precision, hexadecimal, and octal.
Integers
are whole numbers in the range -32768
to
+32767 that
do not contain a decimal point. For example:
1
3200 -2 500 -12345
Integers use the least amount of memory
(2
bytes). Because they
use less memory, BASIC can access them fastest.
44