
RPBASIC-52 PROGRAMMING GUIDE
1-4
Variables and Con stants
More than 25,000 unique variable or constant names
may be defined. Names may be up to eight
characters in length and must begin with a letter
between A -Z (no numbers or special chara cters).
The rest of the name may contain numbers or letters
and include the underline character.
All numeric variables are floating point. Variables
cannot be declared as inte ger or double precision.
RPBASIC-52 supports eight digits plus sign and
exponent. Extra digits are simply discarded. The
range of valid values is ± 1E-127 to
±0.99999999E+127.
Names are identified by the first and last characters
and its length. Identical length names with identical
first and last characte rs are considered the same.
PUM P_42 and PRIM ER2 are considered the same.
The way to correct this is to change the nam e length
or first or last character.
Variable names longer than two characters require
more time to process. Once a variable name is
declared, it can only be erased by the CLEAR
statement or by LOADing in a new program.
It is possible to have variable names longer than 8
characters. A problem is the name length is stored
partly as a modulo 256 number. What it boils down
to is a variable may or may not be recognized as
unique. The Basic considers FEED_BIN_01 and
FEED_BIN_11 as the same variable.
The original B ASIC-5 2 had a bug where the variable
name 'F' was erased if it was the last letter in a
variable followed by a space. RPBASIC-52
corrected this.
Watch out for comm ands embedded in variable
names. FO RM_5 con tains the com mand FOR. A
BAD SYNTAX error is usually returned in these
instances. The statement FORM_5=BOTTOM does
not return an error but interprets it as
FOR M_5=BOT TO M
The key is to look at your statem ents as they are
printed on the screen and make sure they are what
you intended.
Valid variables names are:
CA5, DA15_679, PUMP_A, VALVE02, A(10),
SIZE(5), ABC_
Invalid variables, which may include embedded
commands include:
4C, C$0, GOTOE, FORM, #XYZ, _ABC
Constants are literal values. These are "known"
values as opposed to variables which can be
assigned any value, usually by a function. Constants
may be numeric or string. To RPBASIC, there is no
difference between the two.
Constants are expressed as integer, decimal,
hexadecimal or exponential floating-point. The
range of valid values are:
± 1E-127 to ± .99999999e+127
Using constants instead of a number speeds up
execution by at least 5%. For exam ple, use
10 CH = 5
20 A = AIN(CH)
instead of
20 A = AIN(5)
Variables and constants are expressed as follows:
A = 5 Integer format
A = 5.3 Decimal format
A = 0ACH Hexadecimal format
A = 1.4E3 Exponential
RPBASIC-52 supports eight significant digits plus
and exponen t and truncate s any extra digits.
Hexadecimal constants with a leading alpha
character must be preceded by a leading zero. If you
fail to do this, RPBASIC-52 interprets them as
variable nam es.
All hexadecimal constants are followed by a trailing
"H" (0FFH for exam ple). A "0" prefix is necessary
when the first num ber is a letter (A -F).
Certain logic al operators, su ch as .N OT., .A ND.,
.XOR., and .OR., assume a 16-bit argument such as
0FFFFH. If you supply fewer than 16 bits, it returns
a 16-bit value based on the assumption the
unsupplied most significant bits are zero.
Subroutines
Use of subroutines tends to make programming
more modular and easier to follow. The number of
Kommentare zu diesen Handbüchern