Rpbasic-52 programming guide – Remote Processing BASIC 52 User Manual
Page 7

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
betw een A -Z (no num bers or s pecia l chara cters).
The rest of the na me m ay contain nu mbers or letters
and include the underline chara cter.
All numeric variables are floating point. Variables
cann ot be d eclare d as inte ger or d ouble precis ion.
RPBAS IC-52 supports eight digits plus sign and
exponent. Extra digits are simply discarded. The
range of valid va lues is ± 1E-12 7 to
±0.99999999E+127.
Nam es are identified by th e first and last characte rs
and its length. Identical length names with identical
first and last ch aracte rs are c onside red the sam e.
PUM P_42 and P RIM ER2 are co nsider ed the sam e.
The wa y to correct this is to chan ge the nam e length
or first or last character.
Variable na mes longe r than two cha racters require
more tim e to process. On ce a variable na me is
d e c la r ed , it c an o n ly b e er a se d b y t h e C L E A R
s ta t em e n t o r b y LO A D i ng in a ne w p ro g ra m .
It is possible to have variable names longer than 8
characters. A problem is the name length is stored
p a rt l y a s a m o d u lo 2 5 6 n u m b er . W h a t it b oi l s d o w n
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 w here the variable
name 'F' was erased if it was the last letter in a
variable followed by a space. RPBAS IC-52
corrected this.
Watch out for comm ands em bedded in va riable
nam es. FO RM _5 con tains th e com man d FO R. A
BAD SYNT AX error is usually returned in these
instances. The statement FORM_5=BOTTO M does
not return an error but interprets it as
FOR M_5=BOT TO M
The key is to lo ok 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. Consta nts
may be numeric or string. To RPBASIC, there is no
difference between the two.
Constants a re expressed as integer, decim al,
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
RPBAS IC-52 supports eight significant digits plus
and ex ponen t and tru ncate s any e xtra dig its.
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
variab le nam es.
All hexadecimal constants are followed by a trailing
"H" (0FF H for exam ple). A "0" prefix is ne cessary
whe n the firs t num ber is a letter (A -F).
Certa in logic al ope rators, 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