text
stringlengths
0
595
# METADATA:
**Name:** BazzBasic-AI-guide.txt
**Description:** BazzBasic BASIC interpreter language reference for AI. Use BazzBasic to write, debug, or teach code.
**File extensions:*** ".bas"*, *".bb"*
**Version:** This guide is written for BazzBasic version 1.2 and is updated 01.04.26 (ddmmyy)
**URL:** This guide is stored and updated at https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide
# END METADATA
---
## BazzBasic details
**Version:** 1.2
**Author:** Kristian Virtanen (EkBass)
**Platform:** Windows x64
**License:** MIT
## BazzBasic www-references
**Homepage:** https://ekbass.github.io/BazzBasic/
**GitHub:** https://github.com/EkBass/BazzBasic
**Manual:** https://ekbass.github.io/BazzBasic/manual/#/
**Common examples:** https://github.com/EkBass/BazzBasic/tree/main/Examples
**Rosetta Code:** https://rosettacode.org/wiki/Category:BazzBasic
**Rosetta-Code examples:** https://github.com/EkBass/BazzBasic/tree/main/Examples/rosetta-code
---
## ⚠️ 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 | Pass individual elements by value |
| Case-insensitive | `PRINT`, `print`, `Print` all work |
| `+` operator does both add and concatenate | `"Hi" + " " + name$` |
| Division always returns float | `10 / 3` → `3.333...` |
---
## For context from the author:
**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.*
- Kristian Virtanen (EkBass), author of BazzBasic
## Variables & Constants
```basic
' variables
LET a$ ' Declare without value
LET name$ = "Alice" ' String variable
LET score$ = 0 ' Numeric variable
LET x$, y$, z$ = 10 ' Multiple declaration
' x$ & y$ has value of 0 while z$ has 10
' constants
LET TITLE# = "My Game" ' String constant
```
**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)
- **System:** `PRG_ROOT#` (program base directory path), `BBVER#` (interpreter version as text, e.g. `"1.1"`)
- **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
```
| Function/Command | Description |
|-----------------|-------------|
| `LEN(arr$())` | Element count (note empty parens) |
| `HASKEY(arr$(key))` | 1 if exists, 0 if not |
| `DELKEY arr$(key)` | Remove one element |
| `DELARRAY arr$` | Remove entire array (can re-DIM after) |
| `JOIN dest$, src1$, src2$` | Merge two arrays into dest$; src2$ keys overwrite src1$ on conflict |
**Always check with `HASKEY` before reading uninitialized elements.**