Pinnacle Speakers DEKO500 Portable Generator User Manual


 
Macro Programming Language 126
Deko500 User’s Guide
This macro uses such a loop to test for and skip odd numbers and, as a result, types
only the even numbers from 1 through 10:
$a=0
loop 10
$a = $a+=1
if $a&1
continue # skip odd numbers
end
type $a
end
Conditional loop commands define both the loop and its conditional test.
The while command continues looping as long as its test expression is true.
Deko500 evaluates the test expression prior to each iteration of the loop, and as long
as the result is true, continues the loop:
$a=1
while $a<=5
type "hello";newline
$a+=1
end
The for command, for makes an incremental loop, such as the one above, more
concise:
for $a=1 $a<=5 $a+=1
type "hello";newline
end
The initial expression $a=1 is executed once. The test expression $a<=5 is
evaluated prior to each iteration of the loop; if the test result is true, the loop
continues. The increment expression $a+=1 is executed after each loop iteration.
SUBROUTINES
To a user, there is no practical difference between Deko500’s built-in commands and
the macros that you write and store under file names. You can have one macro run
another macro, simply by using the macro file name in the same way you would use a
command.
When one macro “calls” another, the second macro is considered a subroutine of the
first. You can call an existing macro as a subroutine or create one within your macro.
The command command defines a local subroutine, which ends with the end
command.
The following macro creates, then runs the macros “boy” and “girl” as subroutines.
command boy
type "It’s a boy!"
end