New Commands: (Sapphire 15 and beyond)
Variables
var type(name){value} - Creates a variable (int, flt, str, bol, lst).
Constants
const var type(name){value} - Creates a read-only variable that cannot be changed.
Jumping
jump.n - Immediately stops the current block and starts executing the area named n.
Defining Areas
def area (n) { } - Creates a named logic block for jumps or organization.
Fixed Loops
loop(n) { } - Executes the code inside $n$ times during a single main cycle.
Condition Loops
setLoopUntil(cond) { } - Runs until the condition evaluates to true.
State Loops
setLoopWhen(cond) { } - Runs as long as the condition remains true.
Conversion
convert(type1 var n){type2} - Migrates a variable from one data type to another.
Output
print() and println() - Sends data to the Studio console.
Graphics
set_screen(w, h), draw_rect(COL, x, y, w, h), and update_display().
Core Rules & Logic
Variable Declaration: Only one variable should be declared per set of brackets.
Boolean Syntax: All boolean logic must use lowercase letters (e.g., true, false, &&, ||).
Conditionals: if statements only execute the code block if the condition is strictly true.
Graphics Sequence: You must call set_screen() before using any drawing commands like draw_rect.
Encoding: Your files support full UTF-8, allowing you to use emojis and special symbols in strings.
Workspace Management: Always use the .bat file to ensure the latest library version is copied into your project folder.
Old Basic code structure: Â (before Sapphire 15, not including)
.start.program{}
.setup{}
.main{}
.end.program
Old Commands: (before Sapphire 15, not including)
// - description
setLoop(n){until(a){b}} - same as for(n, a, b) in C++
jump.n - jump to an area named n
def area (n) - create an area n
loop(n) - loop n times in one .main cycle
var int (n){1} - create an integer variable n and n = 1
print() - print something
println() - print something and change line
const var int (n){1} - create a constant integer variable n and n = 1
convert(int var n){str} - convert an integer variable n into string
basic boolean logics
numerical calculations
Rules:
Only one variable in the same brackets
If satements only run if condition = true (not false)
Boolean logics in lowercase letters