Sanny Builder
Search…
Built-in Commands
The following commands are built directly into the compiler and serve mostly as syntactic sugar.

INC

Increments the first parameter by the second one. The first parameter is a variable.
1
Inc($IntVariable, $Value)
2
=
3
$IntVariable += $Value
Copied!
The second parameter is equal to 1 if isn't specified.
Since the version 3.06 it's possible to use the ++ operator that can be applied to variables and increments their value by one.
1
$var++
2
=
3
$var += 1
Copied!

DEC

Decrements the first parameter by the second one. The first parameter is a variable.
1
Dec($IntVariable, $Value)
2
=
3
$IntVariable -= $Value
Copied!
The second parameter is equal to 1 if isn't specified.
Since the version 3.06 it's possible to use the -- operator that can be applied to variables and decrements their value by one.
1
$var--
2
=
3
$var -= 1
Copied!

MUL

Multiplies the first parameter by the second one. The first parameter is a variable.
1
Mul($IntVariable, $Value)
2
=
3
$IntVariable = $IntVariable * $Value
Copied!
The second parameter is equal to 2 if isn't specified.

DIV

Divides the first parameter by the second one. The first parameter is a variable.
1
Div($IntVariable, $Value)
2
=
3
$IntVariable = $IntVariable / $Value
Copied!
The second parameter is equal to 2 if isn't specified.

ALLOC

This function sets the offset of a global variable at the global variable space that exists in the beginning of the main.scm header.
It's only meaningful for custom variables (e.g. $text) not defined in the CustomVariables.ini. DMA-variables always get their offset based on the number in their names, e.g the variable $40 always occupies four bytes at the offset 160 (40*4).
The first parameter must be a global variable, the second parameter must be a positive integer number or zero.
1
Alloc($MyVar, 40) - the variable $MyVar will be compiled as $40
Copied!
See also help\examples\alloc.txt

SQR

Multiplies the variable by itself.
1
sqr($var)
2
=
3
$var *= $var
Copied!
The variable type has to be declared.

RANDOM

This function generates a random number within the specified range.
1
$rnd = random(1, $high)
Copied!
This function can be used for both integer and floating-point variables. The opcode is selected based on the type of the result variable ($rnd in this example).
Last modified 1yr ago