This is an old revision of the document!
Table of Contents
SmileBASIC API Reference
This page is a series of notes gathered while reading the official SmileBASIC documentation and their Instruction List. It's not as clear to read as other code documentation sites out there, so my intent is to consolidate it to something easy to browse and reference.
Function names will be listed alphabetically. Feature-related lists of links will be provided as a convenience.
NOTE In case it's not obvious, this is a work in progress. NOTE
Names and Variables
SmileBASIC supports variable names that are alphanumeric, with optional underscores. Anything that matches this regex should do: [a-zA-Z0-9_]+
System Variables
Types
When defining a variable, you encode its type along with its name.
Strings
Strings are defined via the $
sigil:
A$ = "HELLO WORLD" PRINT A$ ' outputs 'HELLO WORLD'
Numbers
Numbers can be integers, or floating point numbers. Variables are integers by default.
B# = 4 PRINT B# ' outputs '4'
Operators
Logic and Control Flow
Input
Graphics Layering
Sound Effects and Music
DIRECT Mode Commands
Function Reference
This section is where all the "proper" content lives. Other parts of the page should link back here where relevant.
CLEAR
CLEAR
Initializes the internal BASIC memory.
TODO: Does this also erase/initialize variables away?
LOCATE
LOCATE [X coord][, Y coord][, Z coord]
Position the text cursor at the given (X,Y) coordinates (in character cell units instead of pixels), with an optional Z coordinate if the Nintendo 3DS is in 3D Mode.
Value Ranges
Axis | Range |
---|---|
X | 0-49 |
Y | 0-29 |
Z | -256-1024 |
The Z axis is remembered from the last LOCATE call if not specified, and defaults to 0.
Any missing axes from a LOCATE call will be filled in with the last value used for that axis. All axes default to 0 if LOCATE is called after a CLEAR.
PRINT [expression[; expression || : expression …]]
Output the given expression
to the screen. Using a semicolon (;
) as delimiter concatenates expressions without spaces between them, while the comma (,
) adds TABSTEP spaces.
Using a question mark before an expression is a shorthand for calling PRINT:
?(7 + 2) ' outputs 9