Overview
A bytecode-compiled line-number BASIC. Programs are written as numbered lines
and compiled through a tokenizer, parser, and compiler into a stack-based VM.
Output from PRINT statements is returned as the result.
Data Types
- Number: 64-bit floating point (
f64). Displayed as integers when whole (e.g., 5 not 5.0)
- String: double-quoted (
"Hello"). String variables end with $ (e.g., N$)
Undefined variables default to 0 (numeric) or "" (string).
Syntax
- Line numbers: every line must begin with a line number (
10 PRINT "Hello")
- Multiple statements: separate with
: (10 X = 1 : Y = 2 : PRINT X + Y)
- Case-insensitive: keywords are converted to uppercase
- LET is optional:
X = 5 is the same as LET X = 5
- Escaped quotes:
"" inside a string literal produces a literal " (e.g., "He said ""hello""" → He said "hello")
Statements
| Statement | Syntax | Description |
LET | LET X = expr or X = expr | Assign a value to a variable (LET keyword is optional) |
PRINT | PRINT expr, expr ... | Print values; semicolon at end suppresses newline |
INPUT | INPUT X | Read a value from input |
IF | IF expr THEN statements | Conditional; also supports IF expr THEN line (implicit GOTO) |
GOTO | GOTO line | Unconditional jump to a line number |
GOSUB | GOSUB line | Call subroutine at line number (saves return address) |
RETURN | RETURN | Return from subroutine |
FOR | FOR I = a TO b [STEP c] | Begin counted loop (default step is 1) |
NEXT | NEXT I | End of FOR loop; increment and test |
END | END | Terminate program |
REM | REM comment text | Comment (rest of line is ignored) |
HTTPHEADER | HTTPHEADER name$, value$ | Set a custom header for the next HTTP request (auto-cleared after use) |
Operators
| Operator | Description | Notes |
+ | Addition / string concatenation | "A" + "B" → "AB" |
- | Subtraction / unary negation | |
* | Multiplication | |
/ | Division | Error if divisor is zero |
% | Modulo (remainder) | |
= | Equal | Returns -1 (true) or 0 (false) |
<> | Not equal | |
< | Less than | |
> | Greater than | |
<= | Less than or equal | |
>= | Greater than or equal | |
Precedence (high to low): unary -, then * / %,
then + -, then comparisons.
Comparisons return -1 (true) or 0 (false),
matching classic BASIC convention.
Built-in Functions
| Function | Syntax | Description |
ABS | ABS(n) | Absolute value |
INT | INT(n) | Floor (truncate toward negative infinity) |
RND | RND(0) | Random number in [0, 1) using xorshift64 PRNG |
LEN | LEN(s$) | String length |
LEFT$ | LEFT$(s$, n) | First n characters |
RIGHT$ | RIGHT$(s$, n) | Last n characters |
MID$ | MID$(s$, start, len) | Substring (1-indexed start position) |
STR$ | STR$(n) | Convert number to string |
VAL | VAL(s$) | Convert string to number (0 if non-numeric) |
CHR$ | CHR$(n) | Character from ASCII/Unicode code |
ASC | ASC(s$) | ASCII/Unicode code of first character (0 if empty) |
INSTR | INSTR(haystack$, needle$) | Find substring position (1-based); returns 0 if not found |
HTTP Outbound
| Function | Syntax | Description |
HTTPGET$ | HTTPGET$("url") | HTTP GET request; returns response body |
HTTPPOST$ | HTTPPOST$("url", "body") | HTTP POST request; returns response body. Sends Content-Type: application/json by default. |
Secrets
| Function | Syntax | Description |
ENV$ | ENV$("KEY") | Read a secret by name; returns its value |
KV Storage
| Function | Syntax | Description |
KVGET$ | KVGET$("key") | Get value for key; returns empty string if not found |
KVSET | KVSET("key", "value") | Set key to value; returns empty string |
KVDEL | KVDEL("key") | Delete key |
KV storage is only available for saved functions (not ad-hoc /api/run).
Examples
Hello World
10 PRINT "Hello, World!"
FizzBuzz with GOSUB
10 FOR I = 1 TO 20
20 GOSUB 100
30 NEXT I
40 END
100 REM FizzBuzz subroutine
110 IF I % 15 = 0 THEN PRINT "FizzBuzz" : RETURN
120 IF I % 3 = 0 THEN PRINT "Fizz" : RETURN
130 IF I % 5 = 0 THEN PRINT "Buzz" : RETURN
140 PRINT I
150 RETURN
String manipulation
10 LET N$ = "Hello, World!"
20 PRINT LEN(N$)
30 PRINT LEFT$(N$, 5)
40 PRINT MID$(N$, 8, 5)
Fibonacci
10 A = 0 : B = 1
20 FOR I = 1 TO 10
30 PRINT A;
40 C = A + B
50 A = B : B = C
60 NEXT I
Constraints
- Numeric type:
f64 (64-bit float, displayed as integer when whole)
- Undefined variables: default to
0 (numeric) or "" (string)
- Comparisons: return
-1 (true) or 0 (false)
- Instruction limit (CLI): 10,000,000
- Instruction limit (API): 500,000
- Division by zero is a runtime error