Original Author Paul Laughton, 2011
Page 39
De Re BASIC!
Upper case characters can be used in variable names but they will be converted to lower case characters
when the program is run. The variable name "gLoP" is the same as the name "glop" to BASIC!
You should avoid using variable names that start with BASIC! command keywords. Such variables are
valid under most conditions, as will be explained later in ths manual, but their use may cause confusion
or errors. For example, Donut = 5 is interpreted as Do Nut=5. BASIC! thus expects this Do statement to
be followed by an Until statement somewhere before the program ends. A list of BASIC! commands can
be found in Appendix A. See also the Let command and the Expressions
Parentheses section.
BASIC! statement labels and the names of user-defined functions, both described later in this manual,
follow the same naming rules as BASIC! variables.
Variable Types
There are two types of variables: Variables that hold numbers and variables that hold strings. Variables
that hold strings end with the character "$". Variables that hold numbers do not end in "$".
Age, amount and height are all numeric variable names.
First_Name$, Street$ and A$ are all string variable names.
If you use a numeric variable without assigning it a value, it has the value 0.0. If you use a string variable
without assigning it a value, its value is the empty string, "".
Scalar and Array Variables
There are two classes of variables: Scalars and Arrays.
Scalars
A scalar is a variable that can hold only one value. When a scalar is created it is assigned a default value.
Numeric scalars are initialized to 0.0. String scalars are initialized to an empty, zero-length string, "".
You create a scalar variable just by using its name. You do not need to predeclare scalars.
Arrays
An array is variable that can hold many values organized in a systematically arranged way. The simplest
array is the linear array. It can be thought of as a list of values. The array A[index] is a linear array. It can
hold values that can accessed as A[1], A[2],...,A[n]. The number (variable or constant) inside the square
brackets is called the index.
If you wanted to keep a list of ten animals, you could use an array called Animals$[] that can be accessed
with an index of 1 to 10. For example: Animals$[5] = "Cat"
Arrays can have more than one index or dimension. An array with two dimensions can be thought of as
a list of lists. Let's assume that we wanted to assign a list of three traits to every animal in the list of
animals. Such a list for a "Cat" might be "Purrs", "Has four legs" and "Has Tail". We could set up the