Substitution Statements - Radio Shack TRS-80 PC-4 Owner's Manual

Trs-80 pc-4
Hide thumbs Also See for TRS-80 PC-4:
Table of Contents

Advertisement

A character variable is not a numerical value - although it may consist of numbers -
but a variable which contains a character string. In other words,
"123"
just happens
to be 1 and 2 and 3 in sequence and is considered the same as "ABC". A character
variable is made by attaching a "$" to a regular variable (A, B, X, Y, etc.).
Example:
AS,BS,CS,XS, YS
Comparison or addition of each character variable 'is possible. Other operations
such as subtraction, multiplication and division, however, cannot be performed.
Example:
If A$
=
"123"
and B$
=
"456"
As a resu It of C$
=
A$
+
8$, C$ becomes
"123456".
(For C$
=
B$
+
A$, C$ becomes
"456123".l
A character variable can contain up to 7 characters.
In addition to these character variables, there is also an exclusive character variable.
The exclusive character variable is "$" and can contain up to 30 characters.
Example:
$=
"1234567890ABCDE FG"
Since this exclusive character variable can use a character function (MID function)
which will be explained later, it is much more convenient than other character variables.
*
Numerical variables and character variables which contain the same letter cannot be
used at the same time since they use the same memory.
For example:
Numerical variable A
J
.
Ch
. bl A$
Cannot be used at the same time.
aracter varia e
5-2-2 Substitution Statements
BASIC substitution statements adhere to the following format:
Variable -:: numerical expression
In a BASIC substitution statement, the right side which may contain addition, sub-
traction, multiplication or division is called a "numerical expression".
Example:
Y=2*X +3
In y= 2*X+3, the left side is the variable and the right side is the numerical expression.
The "=" does not mean "equal", it means "substitute"-
In other words, the meaning is different from normal mathematics where "the left side
(Y) and the right side (2* X+3) are equal"_
It means "input the operation result of the right side
(2*X+3l
into the left side (V)".
It may be easier to understand by thinking of Y
=
2
*
X+3 as Y
+-
2*X+3.
~29-

Advertisement

Table of Contents
loading

Table of Contents