text stringlengths 0 406 |
|---|
--- |
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.3 | **Author:** Kristian Virtanen (EkBass) | **Platform:** Windows x64 |
**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 |
--- |
## ⚠️ 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...` | |
--- |
## 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. |
## STORY |
Although over the years, as my own skills have grown, I have moved on to more versatile and modern languages, BASIC has always been something that has been fun to try out many different things with. |
Sometimes it's great to just make a simple adventure game again, a lottery machine, a quiz, or even just those balls bouncing on the screen. |
BazzBasic was created with this in mind. |
I wanted to create a language that makes it easy for you to give free rein to your curiosity and program something. |
And when you finish your first little game, you may crave something bigger and better. |
Maybe one day you will move on to another programming language, but then BazzBasic will have succeeded in doing what it was intended for. |
To arouse your curiosity. |
## Variables & Constants |
```basic |
LET a$ ' Declare without value |
LET name$ = "Alice" ' String variable |
LET score$ = 0 ' Numeric variable |
LET x$, y$, z$ = 10 ' Multiple declaration |
LET PI# = 3.14159 ' Constant (immutable) |
LET TITLE# = "My Game" ' String constant |
``` |
**Compound assignment operators** (variables only — **not** allowed with `#` constants): |
```basic |
x$ += 5 ' add |
x$ -= 3 ' subtract |
x$ *= 2 ' multiply |
x$ /= 4 ' divide |
s$ += " World" ' string concatenation |
``` |
**Scope:** All main-code variables share one scope (even inside IF blocks). |
`DEF FN` functions are fully isolated — only global constants (`#`) accessible inside. |
**Comparison:** `"123" = 123` is TRUE (cross-type), but keep types consistent for speed. |
### Built-in Constants |
- **Boolean:** `TRUE`, `FALSE` |
- **Math:** `PI#`, `HPI#` (π/2 = 90°), `QPI#` (π/4 = 45°), `TAU#` (2π = 360°), `EULER#` (e) — `#` suffix required |
- **System:** `PRG_ROOT#` (program base directory path) |
- **Keyboard:** `KEY_ESC#`, `KEY_ENTER#`, `KEY_SPACE#`, `KEY_UP#`, `KEY_DOWN#`, `KEY_LEFT#`, `KEY_RIGHT#`, `KEY_F1#`…`KEY_F12#`, `KEY_A#`…`KEY_Z#`, `KEY_0#`…`KEY_9#`, `KEY_LSHIFT#`, `KEY_LCTRL#`, etc. |
--- |
## Arrays |
```basic |
DIM scores$ ' Declare (required before use) |
DIM a$, b$, c$ ' Multiple |
scores$(0) = 95 ' Numeric index (0-based) |
scores$("name") = "Alice" ' String key (associative) |
matrix$(0, 1) = "A2" ' Multi-dimensional |
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.