- Bytecode
- Configuration
- Comments
#
- Conditions
if
else
end
- Constants
true
false
HIGH
LOW
INPUT
OUTPUT
- Cycles
for
while
next
break
continue
- Functions
function
locals
return
- Macros
macro
- Numeric variables
@
@[]
- Operators
+
-
*
/
%
==
!=
>
>=
<
<=
&&
||
&
|
^
>>
<<
++
--
~
not
- Strings
:
:[]
- System functions
adc read
args
char
cursor
delay
file close
file open
file read
file write
include
index
input
io open
io read
io write
jump
label
mem
millis
number
numeric
print
random
restart
serial open
serial read
serial write
size
stop
string
system
- Unary operators
++
--
function [name]([parameter], [parameter], locals: [parameter], [parameter])
[statement]
return [expression]
A function is a group of statements identified by a unique name that together perform a task and can return a value. Each function is just an entry of a global array of up to 88 functions, each function stores up to 88 parameters and local variables. A function can be defined using the function
keyword, defining its name and a parameters' list delimited by parentheses used to define which variables are used for function computation. The parameters listed in the function's definition are identified by $
and are set with the value passed by the call.
// Call
print sum(1, 1)
stop // end of the program
// Definition
function sum($a, $b)
return $a + $b
All statements contained in the function definition are executed until return
is encountered. The return
statement must be one and must be the last statement of the function. Function definitions must be placed after stop
.
The following function fibonacci
prints the Fibonacci series. As you can see the local variables must be defined along with the function parameters after the locals:
keyword. The value of uninitialized parameters and local variables is guaranteed to be 0
.
fibonacci(10) // Prints 0 1 1 2 3 5 8
stop
function fibonacci($a, locals: $b, $c)
$b = 1
for #r = 0 to $a
$a = $b
$b = $c
$c = $a + $b
next
return $c