Macro Programming Language 121
Deko500 User’s Guide
For example, an array named $table might include these elements:
$table[3]
$table[42]
$table[$count+1]
$table[9999]
Deko500 allocates array elements as needed. The subscripted variables in the above
example will occupy only four variable slots, not ten thousand.
By default, most variables are local variables. A local variable is allocated
temporarily during macro playback, then deleted automatically when the macro stops.
One macro cannot reference a second macro’s local variables, even if the second
macro is a subroutine of the first.
Global variables must be declared with the global command, and can be shared
among multiple macros. Once declared, a global variable remains until you either
delete it by using the free command, or exit Deko500.
Deko500 has a set of built-in global variables, known as system variables, which
provide information about the state of your system. System variables are preceded by
the at-sign symbol (@), and are often referred to as at-sign variables.
Some system variables are read-only; you cannot change their values. Examples of
read-only system variables are @lines and @dots, which describe the current video
standard, and the pre-defined colors @red, @blue and @green.
Other system variables may be assigned values. For example, the system variable
@wordwrap can be set to 0 to disable word wrap, or 1 to enable it
OPERATORS
In the previous topic, you saw that variable assignment is indicated by the equal sign
(=), which is just one of many symbols, known as operators, that represent operations
performed on data.
The Deko500 Macro Programming Language uses a subset of the operators available
in C, as well as a few additions specific to Deko500.
Arithmetic operators perform mathematical operations within expressions:
Operator Expression Operation
+ $a + $b adds $a and $b
- $a - $b subtracts $b from $a
* $a * $b multiplies $a by $b
/ $a / $b divides $a by $b
% $a % $b calculates remainder of $a/$b
- -$a negates the value of $a
You can perform arithmetic operations on one-character strings by adding or
subtracting integer values to the character. For example, the expression "A"+1 has
the value "B".
Using single quotation marks in an expression yields the numerical value of the
character key. For example, ’A’+1 has the value 66.