text stringlengths 0 721 |
|---|
GOTO target$ |
' Other |
SLEEP 2000 ' Pause for milliseconds |
END ' Terminate program |
``` |
**Note:** Labels are case-insensitive and may contain almost any printable character. |
Whitespace is trimmed. Everything between "[" and "]" is treated as the label name. |
--- |
## I/O |
| Command | Description | |
|---------|-------------| |
| `PRINT expr; expr` | `;` = no space, `,` = tab | |
| `PRINT "text";` | Trailing `;` suppresses newline | |
| `INPUT "prompt", var$` | Splits on whitespace/comma | |
| `INPUT "prompt", a$, b$` | Multiple values | |
| `LINE INPUT "prompt", var$` | Read entire line with spaces | |
| `CLS` | Clear screen | |
| `LOCATE row, col` | Move cursor (1-based) | |
| `CURPOS("row")` / `CURPOS("col")` | Read cursor row or col (1-based, matches LOCATE) | |
| `CURPOS()` | Read cursor as `"row,col"` string | |
| `COLOR fg, bg` | Text colors (0–15 palette) | |
| `SHELL("cmd")` | Run shell command, returns output | |
| `SHELL("cmd", ms)` | With timeout in ms (default 5000) | |
' ; prints without spacing |
' , prints tab separation |
' Both can be mixed in a single PRINT statement |
' INPUT splits on whitespace and comma; quoted strings are treated as single values |
**Escape sequences in strings:** `\"` `\n` `\t` `\\` |
**SHELL + SQLite.** SQLite (the `sqlite3` CLI tool) is the recommended way to add a real database to a BazzBasic script — see the *SQLite Database* page in the manual for the full guide. Three things to remember when generating SHELL commands that wrap SQL: |
- Always append `2>&1` to the command, or SQL errors disappear silently. |
- Use `\"` (BazzBasic escape) to wrap the SQL for the OS shell: `SHELL("sqlite3 db.sqlite \"SELECT * FROM users\" 2>&1")`. |
- In paths use `/` or `\\` — never a single `\`. |
### Keyboard Input |
| Function | Returns | Notes | |
|----------|---------|-------| |
| `INKEY` | Key value or 0 | Non-blocking | |
| `KEYDOWN(key#)` | TRUE/FALSE | Held-key detection; KEYDOWN only works in graphics mode | |
| `WAITKEY(key#, ...)` | Key value | Blocks until key pressed; `WAITKEY()` = any key | |
### Mouse (graphics mode only) |
`MOUSEX`, `MOUSEY` — cursor position |
`MOUSELEFT`, MOUSERIGHT, MOUSEMIDDLE — return 1 if pressed, 0 otherwise |
`MOUSEHIDE` — hide the mouse cursor (graphics screen only) |
`MOUSESHOW` — restore the mouse cursor (graphics screen only) |
### Console Read |
Returns numeric or character depending on type parameter |
`GETCONSOLE(row, col, type)` — type: 0=char (ASCII), 1=fg color, 2=bg color |
--- |
## User-Defined Functions |
```basic |
' Define BEFORE calling. Name must end with $. |
DEF FN Clamp$(val$, lo$, hi$) |
IF val$ < lo$ THEN RETURN lo$ |
IF val$ > hi$ THEN RETURN hi$ |
RETURN val$ |
END DEF |
PRINT FN Clamp$(5, 1, 10) ' ✓ OK — return value used |
LET v$ = FN Clamp$(15, 0, 10) ' ✓ OK |
FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused |
' Return value must be assigned with LET or consumed by PRINT — there is no way to silently discard it. |
``` |
- Isolated scope: no access to global variables, only global constants (`#`) |
- Parameters passed **by value** |
- Labels inside functions are local — GOTO/GOSUB cannot jump outside |
- Supports recursion |
- Arrays as parameters not allowed. Use ASJSON to make array as JSON-string to pass it. |
- Use `INCLUDE` to load functions from separate files if many |
--- |
## String Functions |
| Function | Description | |
|----------|-------------| |
| `ASC(s$)` | ASCII code of first char | |
| `CHR(n)` | Character from ASCII code | |
| `INSTR(s$, search$)` | Position (1-based), 0=not found; case-sensitive by default | |
| `INSTR(s$, search$, mode)` | mode: 0=case-insensitive, 1=case-sensitive | |
| `INSTR(start, s$, search$)` | Search from position (case-sensitive) | |
| `INVERT(s$)` | Reverse string | |
| `LCASE(s$)` / `UCASE(s$)` | Lower / upper case | |
| `LEFT(s$, n)` / `RIGHT(s$, n)` | First/last n chars | |
| `LEN(s$)` | String length | |
| `LTRIM(s$)` / `RTRIM(s$)` / `TRIM(s$)` | Strip whitespace | |
| `MID(s$, start)` | Substring from start (1-based) | |
| `MID(s$, start, len)` | Substring with length | |
| `REPEAT(s$, n)` | Repeat string n times | |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.