text stringlengths 0 721 |
|---|
--- |
name: bazzbasic |
description: "BazzBasic BASIC interpreter language reference. Use when writing, debugging, or explaining BazzBasic code (.bas files). Triggers on: BazzBasic syntax, $ and # variable suffixes, SDL2 graphics in BASIC, SCREEN/DRAWSHAPE/LOADIMAGE commands, DEF FN functions, BazzBasic file I/O, sound commands, or any questi... |
--- |
# BazzBasic Language Reference |
**Version:** 1.3b | **Author:** Kristian Virtanen (EkBass) | **Platform:** Windows x64 |
**Homepage:** https://ekbass.github.io/BazzBasic/ |
**GitHub:** https://github.com/EkBass/BazzBasic |
**Manual:** https://ekbass.github.io/BazzBasic/manual/#/ |
**Examples:** https://github.com/EkBass/BazzBasic/tree/main/Examples |
**Rosetta Code:** https://rosettacode.org/wiki/Category:BazzBasic |
**Rosetta Code solutions:** https://github.com/EkBass/BazzBasic/tree/main/Examples/rosetta-code |
**BazzBasic-AI-Guide:** https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide |
**BazzBasic Beginner's Guide:** https://github.com/EkBass/BazzBasic-Beginners-Guide/releases |
**Communities:** https://ekbass.github.io/BazzBasic/communities.html |
--- |
## ⚠️ Critical Rules — Read First |
| Rule | Detail | |
|------|--------| |
| Variables end with `$` | `name$`, `score$`, `x$` | |
| Constants end with `#` | `MAX#`, `PI#`, `TITLE#` | |
| Arrays declared with `DIM`, end with `$` | `DIM items$` | |
| First use of variable requires `LET` | `LET x$ = 0` — after that `x$ = x$ + 1` | |
| FOR and INPUT auto-declare, no LET needed | `FOR i$ = 1 TO 10` | |
| Functions defined **before** they are called | Put at top or INCLUDE | |
| Function name ends with `$`, called with `FN` | `FN MyFunc$(a$, b$)` | |
| Function return value **must** be used | `PRINT FN f$()` or `LET v$ = FN f$()` | |
| Arrays **cannot** be passed to functions directly | Pass individual elements, or serialize to JSON string — see *Passing Arrays to Functions* section | |
| Case-insensitive | `PRINT`, `print`, `Print` all work | |
| `+` operator does both add and concatenate | `"Hi" + " " + name$` | |
| Division always returns float | `10 / 3` → `3.333...` | |
| Division by zero returns `0` (no error) | Guard with `IF b$ = 0 THEN ...` if needed | |
| No integer-division operator | Use `INT(a / b)`, `FLOOR(a / b)`, or `CINT(a / b)` | |
| Errors halt the program | No `TRY`/`CATCH` or `ON ERROR` — line-numbered message printed | |
--- |
## 🚫 Common AI Mistakes (avoid these) |
These are the patterns LLMs most often produce when extrapolating from QBASIC, FreeBASIC, or VB. None of them are valid BazzBasic. |
```basic |
' ❌ WRONG ' ✓ CORRECT |
LET x = 5 LET x$ = 5 |
LET MAX = 10 LET MAX# = 10 |
score$ = 0 ' first use LET score$ = 0 |
DEF FN doStuff(a, b) DEF FN DoStuff$(a$, b$) |
FN MyFunc$(5) ' return ignored LET v$ = FN MyFunc$(5) |
LET handle$ = LOADIMAGE("x.png") LET HANDLE# = LOADIMAGE("x.png") |
CLS ' in graphics mode LINE (0,0)-(W,H), 0, BF |
PRINT "x:", x$ ' in graphics mode DRAWSTRING "x:" + STR(x$), 10, 10, RGB(255,255,255) |
``` |
**Two more traps that don't fit the table:** |
- Inside `DEF FN` you can read `#` constants from the outer scope but **not** `$` variables. Pass them as parameters. |
- Arrays cannot be passed to a function. Serialize with `ASJSON()` and rebuild inside the function with `ASARRAY()` — see *Passing Arrays to Functions* below. |
--- |
## Minimal Valid Program |
```basic |
[inits] |
LET name$ = "World" |
[main] |
PRINT "Hello, " + name$ |
END |
``` |
Programs flow top to bottom. `[inits]` and `[main]` are organizational labels, not required syntax — the file would also run without them. `END` halts execution; place it at the end of the main flow so control doesn't fall through into subroutines or function definitions. |
--- |
## When Generating BazzBasic Code |
- Always declare variables with `LET` on first use; subsequent uses don't need it |
- Always include the `$` (variable) or `#` (constant) suffix |
- Place `DEF FN` definitions at the top of the file or via `INCLUDE` |
- Store every `LOADIMAGE` / `LOADSOUND` / `LOADSHAPE` handle as a `#` constant |
- In graphics mode, prefer `LINE (0,0)-(W,H), 0, BF` over `CLS`, and `DRAWSTRING` over `PRINT` |
- Wrap each frame's drawing in `SCREENLOCK ON` / `SCREENLOCK OFF` |
- Always use a function's return value — assign with `LET` or consume with `PRINT` |
- If a feature isn't documented in this guide, say so rather than inventing one — BazzBasic does not silently inherit QBASIC, FreeBASIC, or VB conventions |
--- |
## ABOUT |
BazzBasic is built around one simple idea: starting programming should feel nice and even fun. Ease of learning, comfort of exploration and small but important moments of success. Just like the classic BASICs of decades past, but with a fresh and modern feel. |
### What people have built with it |
BazzBasic is built for beginners, but it isn't a toy. It can carry real 2D games and even 2.5D graphics work. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.