RBASIC™ Expressions and Variables
RBASIC supports two types of variables: Numeric and string type. It does not bother you with integer or real variable types, it handles numbers automatically allowing a precision of 15 significant digits. RBASIC handles numbers as small as 10 powered to -300 and as large as 10 powered to 300.
All string variables are terminated the by $ sign. For example:
a, count, number are numeric variables.
a$, name$, FILE$ are string variables.
RBASIC places no limit on the length of your variables. (That's right; their length is unlimited.)
Logical (Boolean) values in RBASIC are represented by number values: Value 0 (zero) means "false", any other value means "true". This can be used in expressions which use relational operators. For example, expression 10.5<5 gives 0 as the result (because the comparison is false, 10.5 is obviously not smaller than 5), while expression 100<1000 yields 1 as the result, because 100 is smaller than 1000.
RBASIC also supports string and numeric arrays. Arrays are created by the DIM ("dimension") command. Individual aray items are accesed by their index. For example, the command
creates an array called "a" with 10 elements. Indexes are assumed to start with 0, so you can access this array for example like this:
This will assign 100 to a, 200 to a and 1000 to a, leaving the other array elements unassigned.
Note that you can conserve space by using the ":" symbol, all into one line:
a=100: a=200: a=1000
String arrays are handled in the similar way. For example, the following line creates a three-dimentional areay with 60 elements (3x4x5), and assigns the first element to "This is the first string".
DIM a$(3,4,5): a$[0,0,0]="This is the first string"
An advanced use of the DIM statement is to add a new variable to the stack (DIM a). This allows you to have more than one variables with same names (only the last one will be accessible). This is useful in recursive algorithms, where a recursive function can define new variable, use it and remove it from the stack using the RETURN statement.
RBASIC supports the following operators (sorted by priority, 1 is the lowest):
The number of nested parentheses in expressions is unlimited.
The only string operation is adding. For example "word"+"word" means the string "wordword". The length of string is unlimited, but number values are limited to absolute value 1e300 (10 powered to 300). Numbers with absolute value smaller than 1e-300 can vanish.
RBASIC programs can use files to store information. Files are accessed by their path name. See more details in the Files chapter.
Graphics window variables
RBASIC can open a graphic window and assign it a name and dimensions X,Y. Such windows are accessed by their names. (More details in the separate chapter dedicated to Graphics.)
In RBASIC, all variables are case-insensitive, so for example
are all considered equal. The same applies to RBASIC keywords.
beep : message "Hello!"
will cause the same action as
BEEP : MESSAGE "Hello!".