EkBass commited on
Commit
5c351c1
·
verified ·
1 Parent(s): 688d8d3

Update BazzBasic-AI-guide.md

Browse files
Files changed (1) hide show
  1. BazzBasic-AI-guide.md +227 -240
BazzBasic-AI-guide.md CHANGED
@@ -2,7 +2,7 @@
2
  name: bazzbasic
3
  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 question about BazzBasic features. Always use this skill before writing any BazzBasic code."
4
  ---
5
-
6
  # BazzBasic Language Reference
7
  **Version:** 1.5 | **Author:** Kristian Virtanen (EkBass) | **Platform:** Windows x64
8
  **Homepage:** https://ekbass.github.io/BazzBasic/
@@ -14,11 +14,11 @@ description: "BazzBasic BASIC interpreter language reference. Use when writing,
14
  **BazzBasic-AI-Guide:** https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide
15
  **BazzBasic Beginner's Guide:** https://github.com/EkBass/BazzBasic-Beginners-Guide/releases
16
  **Communities:** https://ekbass.github.io/BazzBasic/communities.html
17
-
18
  ---
19
-
20
- ## ⚠️ Critical Rules — Read First
21
-
22
  | Rule | Detail |
23
  |------|--------|
24
  | Variables end with `$` | `name$`, `score$`, `x$` |
@@ -37,13 +37,13 @@ description: "BazzBasic BASIC interpreter language reference. Use when writing,
37
  | No integer-division operator | Use `INT(a / b)`, `FLOOR(a / b)`, or `CINT(a / b)` |
38
  | Errors halt the program | No `TRY`/`CATCH` or `ON ERROR` — line-numbered message printed |
39
  | No line-continuation char | Don't use `_`, `\`, or `&` — lexer continues automatically after operators or open `(` |
40
-
41
  ---
42
-
43
  ## 🚫 Common AI Mistakes (avoid these)
44
-
45
  These are the patterns LLMs most often produce when extrapolating from QBASIC, FreeBASIC, or VB. None of them are valid BazzBasic.
46
-
47
  ```basic
48
  ' ❌ WRONG ' ✓ CORRECT
49
  LET x = 5 LET x$ = 5
@@ -59,137 +59,135 @@ ISSET(arr$(0)) ' expecting error ' returns 0 silently — ISSET only se
59
  LET x$ = a$ + _ ' VBA continuation LET x$ = a$ + ' just leave the operator
60
  LET x$ = a$ + \ ' Python continuation LET x$ = a$ + ' or open a paren — see Line Continuation
61
  ```
62
-
63
  **Two more traps that don't fit the table:**
64
-
65
  - Inside `DEF FN` you can read `#` constants from the outer scope but **not** `$` variables or global arrays. Pass values as parameters.
66
  - Arrays cannot be passed to a function directly, and a function cannot see global arrays. Serialize with `ASJSON()` and rebuild inside the function with `ASARRAY()` — see *Passing Arrays to Functions* below.
67
-
68
  ---
69
-
70
  ## Minimal Valid Program
71
-
72
  ```basic
73
  ' Suggested style to use [subs]
74
  [inits] ' [name] is a plain jump label, not a keyword — see Control Flow
75
  LET name$ = "World"
76
-
77
  [main]
78
  PRINT "Hello, " + name$
79
  END
80
-
81
  ' other subs after END'
82
  [sub:drawScreen]
83
  ' draw
84
  RETURN
85
  ```
86
-
87
  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.
88
-
89
  ---
90
-
91
  ## When Generating BazzBasic Code
92
-
93
  (Suffix and return-value rules are already covered in Critical Rules above — not repeated here.)
94
-
95
  - Prefer `FSTRING` over long `+` concatenation chains for multi-variable strings
96
  - Place `DEF FN` definitions at the top of the file or via `INCLUDE`
97
  - Store every `LOADIMAGE` / `LOADSOUND` / `LOADSHAPE` handle as a `#` constant
98
  - In graphics mode, prefer `LINE (0,0)-(W,H), 0, BF` over `CLS`, and `DRAWSTRING` over `PRINT`
99
  - Wrap each frame's drawing in `SCREENLOCK ON` / `SCREENLOCK OFF`
100
  - 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
101
-
102
  ---
103
-
104
-
105
  ## ABOUT
106
-
107
  BazzBasic is built around one simple idea: starting programming should feel nice, even fun — the ease and small joyful moments of the classic BASICs of decades past, with a fresh, modern feel.
108
-
109
  Over the years my own skills have grown and I've moved on to more versatile languages, but BASIC has always stayed fun for quick experiments — a simple adventure game, a lottery machine, a quiz, or just balls bouncing on the screen. BazzBasic was built with that in mind: a language that gets out of your way so curiosity can run free. And when you finish your first little game and crave something bigger, and eventually move on to another language — that's BazzBasic succeeding at exactly what it was meant to do.
110
-
111
  To arouse your curiosity.
112
-
113
  *EkBass*, author of BazzBasic
114
-
115
  ---
116
-
117
  ## Case sensitivity
118
  BazzBasic is not case-sensitive except with string contents.
119
  ```basic
120
  let blaa$ = "Hello"
121
  PriNT BLAA$ ' output: Hello
122
  ```
123
-
124
  ---
125
-
126
  ## Line Continuation
127
-
128
  BazzBasic has **no line-continuation character**. Do not generate `_` (VBA), `\` (Python), or `&` (other dialects). The lexer figures out continuation automatically using two rules.
129
-
130
  **Rule 1 — operator at end of line.** If a line ends in a token that cannot legally end an expression, the next line continues it:
131
-
132
  ```basic
133
  LET total$ = price$ * count$ -
134
  discount$
135
-
136
  IF score$ >= 0 AND
137
  score$ <= 100 THEN
138
  PRINT "Valid"
139
  END IF
140
-
141
  LET counter$ +=
142
  step$
143
  ```
144
-
145
  Tokens that trigger this: `+ - * / % = <> < <= > >= AND OR += -= *= /= ,`
146
-
147
  > `%` IS a real binary modulo operator (`a % b`, same precedence as `*`/`/`, same result as `MOD(a, b)`) and DOES trigger continuation like the other arithmetic operators above.
148
  > `MOD` is a separate thing — a function `MOD(a, b)` — not a binary operator, so it does NOT trigger continuation (a `)` at line end never continues).
149
-
150
  **Rule 2 — open paren.** Anything inside an unmatched `(` keeps reading until the matching `)`:
151
-
152
  ```basic
153
  LET dist$ = DISTANCE(
154
  x1$, y1$,
155
  x2$, y2$
156
  )
157
  ```
158
-
159
  Both rules combine:
160
-
161
  ```basic
162
  LET total$ = (
163
  base$ +
164
  tax$
165
  )
166
  ```
167
-
168
  **Trap for AI generators.** Do NOT emit a trailing `_`, `\`, `&`, or any other continuation marker — they are not BazzBasic syntax and will produce parse errors. Just leave the operator at the end of the line, or open a paren.
169
-
170
  ---
171
-
172
  ## Variables & Constants
173
  Variables and constants must be declared with LET before they can be used.
174
  BazzBasic variables are not typed, but work the same way as in JavaScript, for example.
175
  A variable needs the suffix $ which often is linked as STRING in traditional basic variants.
176
-
177
  Variables require suffix "$". Constants require suffix "#".
178
  The suffix does not define data type — only "#" indicates immutability.
179
  ```basic
180
  LET a$ ' Declare variable without value
181
  LET b$, c$, d$ ' Multiple variable declarations without value
182
  LET e$, f$ = "foo", g$ = 10 ' Multiple variable declaration, e$ stays empty, f$ and g$ gets values
183
-
184
  LET name$ = "Alice" ' String variable
185
  LET score$ = 0 ' Numeric variable
186
-
187
  LET PI# = 3.14159 ' Constant (immutable)
188
  LET TITLE# = "My Game" ' String constant
189
  ```
190
-
191
  **Compound assignment operators** (variables only — **not** allowed with `#` constants):
192
-
193
  ```basic
194
  LET x$ = 1
195
  x$ += 5 ' add
@@ -199,15 +197,15 @@ x$ /= 4 ' divide
199
  LET s$ = "Hello"
200
  s$ += " World" ' string concatenation
201
  ```
202
-
203
  **Scope:** All main-code variables share one scope (IF, FOR, and WHILE do NOT create new scope).
204
  Main-code variables ($) and arrays are NOT accessible inside DEF FN.
205
  `DEF FN` functions are fully isolated — only global constants (`#`) accessible inside.
206
-
207
  **Comparison:** `"123" = 123` is TRUE (cross-type), but keep types consistent for speed.
208
-
209
  ---
210
-
211
  ### Built-in Constants
212
  - **Boolean:** `TRUE` (`1`), `FALSE` (`0`) — plain numbers, not a separate type. `IF x$ = 1` and `IF x$ = TRUE` are identical.
213
  - **Math:** `PI#`, `HPI#` (π/2 = 90°), `QPI#` (π/4 = 45°), `TAU#` (2π = 360°), `EULER#` (e) — `#` suffix required
@@ -215,41 +213,40 @@ Main-code variables ($) and arrays are NOT accessible inside DEF FN.
215
  - **Version:** `BBVER#` (returns current version of BazzBasic, ie: "1.5")
216
  - **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_NUMPAD0#`…`KEY_NUMPAD9#`, `KEY_NUMPAD_PLUS#`/`_MINUS#`/`_MUL#`/`_DIV#`/`_DOT#`, `KEY_LSHIFT#`, `KEY_LCTRL#`, etc. — see *Keyboard Input*
217
  - **Gamepad:** buttons `PAD_A#`…`PAD_Y#`, `PAD_UP#`/`_DOWN#`/`_LEFT#`/`_RIGHT#`, `PAD_LB#`, `PAD_RB#`, `PAD_START#`, `PAD_BACK#` etc.; axes `PAD_LX#`, `PAD_LY#`, `PAD_RX#`, `PAD_RY#`, `PAD_LT#`, `PAD_RT#` — see *Gamepad*
218
-
219
  ---
220
-
221
  ## Arrays
222
  BazzBasic arrays are fully dynamic and support numeric, string, or mixed indexing.
223
-
224
-
225
  ```basic
226
  DIM scores$ ' Declare (required before use)
227
  DIM a$, b$, c$ ' Multiple
228
  scores$(0) = 95 ' Numeric indices are 0-based.
229
  scores$("name") = "Alice" ' String keys are associative, insertion-ordered.
230
  matrix$(0, 1) = "A2" ' Multi-dimensional
231
-
232
  DIM sounds$
233
  sounds$("guns", "shotgun_shoot") = "shoot_shotgun.wav"
234
  sounds$("guns", "shotgun_reload") = "reload_shotgun.wav"
235
  sounds$("guns", "ak47_shoot") = "shoot_ak47.wav"
236
  sounds$("guns", "ak47_reload") = "reload_ak47.wav"
237
  sounds$("food", "ham_eat") = "eat_ham.wav"
238
-
239
  PRINT LEN(sounds$()) ' 5 - total elements across both "guns" and "food" groups
240
  PRINT ROWCOUNT(sounds$()) ' 2, "guns" & "food"
241
-
242
  DIM car$
243
  car$("manufacturer") = "Ford"
244
  car$("engine") = "1.6 Eco"
245
  car$("color") = "Blue"
246
-
247
  FOR i$ = 0 TO LEN(car$()) - 1 ' Iterate an associative array: LEN + ARRKEY
248
  LET key$ = ARRKEY(car$(), i$) ' No FOREACH in BazzBasic - this is the idiom
249
  PRINT key$; " = "; car$(key$)
250
  NEXT i$
251
  ```
252
-
253
  | Function/Command | Description |
254
  |-----------------|-------------|
255
  | `LEN(arr$())` | Total element count (LEN counts all nested elements across all dimensions) |
@@ -259,17 +256,17 @@ NEXT i$
259
  | `DELKEY arr$(key)` | Remove one element |
260
  | `DELARRAY arr$` | Remove entire array (can re-DIM after) |
261
  | `JOIN dest$, src1$, src2$` | Merge two arrays; `src2$` keys overwrite `src1$`. Use empty `src1$` as `COPYARRAY`. |
262
-
263
  **JOIN** Matching keys from src2$ overwrite src1$ at the same level
264
-
265
  **Always check with `HASKEY` before reading uninitialized elements.**
266
-
267
  > `DIM arr$ = value` (single value, not `key=value` text) stores it at `arr$(0)` — NOT as a scalar. `DIM x$ = 5` does not make `x$` printable as a plain number; it makes `x$(0)` equal `5`. If a scalar is what you want, use `LET`, not `DIM`.
268
-
269
  ---
270
-
271
  ## Control Flow
272
-
273
  ```basic
274
  ' Block IF
275
  IF score$ >= 90 THEN
@@ -279,34 +276,34 @@ ELSEIF score$ >= 80 THEN
279
  ELSE
280
  PRINT "F"
281
  END IF ' ENDIF also works
282
-
283
  ' One-line IF
284
  IF lives$ = 0 THEN GOTO [game_over]
285
  IF key$ = KEY_ESC# THEN GOTO [menu] ELSE GOTO [play]
286
-
287
  ' FOR (auto-declares variable)
288
  FOR i$ = 1 TO 10 STEP 2 : PRINT i$ : NEXT
289
  FOR i$ = 10 TO 1 STEP -1 : PRINT i$ : NEXT
290
-
291
  ' WHILE
292
  WHILE x$ < 100
293
  x$ = x$ * 2
294
  WEND
295
-
296
  ' Labels, GOTO, GOSUB
297
  [start]
298
  GOSUB [sub:init]
299
  ' Avoid jumping into the middle of logical blocks (e.g. inside IF/WHILE)
300
  GOTO [start]
301
-
302
  [sub:init]
303
  LET x$ = 0
304
  RETURN
305
-
306
  ' Dynamic jump (variable must contain "[label]" with brackets)
307
  LET target$ = "[menu]"
308
  GOTO target$
309
-
310
  ' Other
311
  SLEEP 2000 ' Pause for milliseconds
312
  END ' Terminate program
@@ -314,9 +311,9 @@ END ' Terminate program
314
  **Note:** Labels are case-insensitive and may contain almost any printable character.
315
  Whitespace is trimmed. Everything between "[" and "]" is treated as the label name.
316
  ---
317
-
318
  ## I/O
319
-
320
  | Command | Description |
321
  |---------|-------------|
322
  | `PRINT expr; expr` | `;` = no space, `,` = tab |
@@ -331,32 +328,31 @@ Whitespace is trimmed. Everything between "[" and "]" is treated as the label na
331
  | `COLOR fg, bg` | Text colors (0–15 palette) |
332
  | `SHELL("cmd")` | Run shell command, returns output |
333
  | `SHELL("cmd", ms)` | With timeout in ms (default 5000) |
334
-
335
  ' ; prints without spacing
336
  ' , prints tab separation
337
  ' Both can be mixed in a single PRINT statement
338
  ' INPUT splits on whitespace and comma; quoted strings are treated as single values
339
-
340
  **Escape sequences in strings:** `\"` `\n` `\t` `\\`
341
-
342
  **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:
343
  - Always append `2>&1` to the command, or SQL errors disappear silently.
344
  - Use `\"` (BazzBasic escape) to wrap the SQL for the OS shell: `SHELL("sqlite3 db.sqlite \"SELECT * FROM users\" 2>&1")`.
345
  - In paths use `/` or `\\` — never a single `\`.
346
-
347
  ### Keyboard Input
348
  | Function | Returns | Notes |
349
  |----------|---------|-------|
350
  | `INKEY` | Key value or 0 | Non-blocking |
351
  | `KEYDOWN(key#)` | TRUE/FALSE | Held-key detection; KEYDOWN only works in graphics mode |
352
  | `WAITKEY(key#, ...)` | Key value | Blocks until key pressed; `WAITKEY()` = any key |
353
-
354
  **Keyboard layouts.** Letters (`KEY_A#`…`KEY_Z#`), digits, arrows, Space/Enter/Esc, F-keys,
355
  numpad and modifiers are the same on every keyboard layout — use these for controls.
356
  Main-keyboard punctuation (`+ - = , . /` etc. and their `KEY_*#` constants) depends on the
357
  layout: never bind controls to `ASC("+")` or `ASC("-")`. Use letters or
358
  `KEY_NUMPAD_PLUS#` / `KEY_NUMPAD_MINUS#` instead.
359
-
360
  - Letters always return uppercase codes (`"a"` and `"A"` → `KEY_A#`), in both graphics and console mode.
361
  - `KEYDOWN` follows the key *label* on the current layout, same as `INKEY`: `KEYDOWN(KEY_A#)` is the key that types "a" (on AZERTY that is a different physical key than on QWERTY). If no key types a punctuation character without modifiers (e.g. "=" on a Finnish keyboard), `KEYDOWN` of that constant is always FALSE.
362
  - Numpad: `KEY_NUMPAD0#`…`KEY_NUMPAD9#`, `KEY_NUMPAD_PLUS#`, `KEY_NUMPAD_MINUS#`,
@@ -371,8 +367,13 @@ layout: never bind controls to `ASC("+")` or `ASC("-")`. Use letters or
371
  `MOUSELEFT`, MOUSERIGHT, MOUSEMIDDLE — return 1 if pressed, 0 otherwise
372
  `MOUSEHIDE` — hide the mouse cursor (graphics screen only)
373
  `MOUSESHOW` — restore the mouse cursor (graphics screen only)
374
-
375
  ### Gamepad (console AND graphics mode) — added in v1.5
 
 
 
 
 
376
  | Function | Returns | Notes |
377
  |----------|---------|-------|
378
  | `GAMEPADS()` | Number of connected pads | Parentheses optional |
@@ -380,7 +381,7 @@ layout: never bind controls to `ASC("+")` or `ASC("-")`. Use letters or
380
  | `PADAXIS(pad, axis)` | Number | Sticks -1.0…1.0, triggers 0.0…1.0, built-in dead zone |
381
  | `PADNAME(pad)` | String | e.g. `"PS4 Controller"`, `""` if not connected |
382
  | `PADRUMBLE pad, strength, ms` | — (statement) | strength 0.0…1.0, non-blocking, parentheses optional |
383
-
384
  - Pad index is **0-based**, max 8 pads. A pad keeps its number while connected (stable slots, not re-packed on disconnect).
385
  - **No `SCREEN` needed** — unlike `KEYDOWN`/mouse, gamepad functions work in console programs too.
386
  - **Disconnected pad = no input, never an error:** `PADBUTTON` → FALSE, `PADAXIS` → 0, `PADNAME` → `""`. Do not generate guard code like `IF GAMEPADS() > 0 THEN` around every read; use `GAMEPADS()` only to show a "connect a pad" message.
@@ -393,15 +394,14 @@ layout: never bind controls to `ASC("+")` or `ASC("-")`. Use letters or
393
  - Stick as digital direction: `IF PADAXIS(0, PAD_LX#) < -0.5 THEN ...`
394
  - Typical game input = pad OR keyboard: `IF PADBUTTON(0, PAD_LEFT#) OR KEYDOWN(KEY_LEFT#) THEN dx$ = -1`
395
  - Many third-party pads identify as PS4/Xbox controllers — normal, mapping still correct.
396
-
397
  ### Console Read
398
  Returns numeric or character depending on type parameter
399
  `GETCONSOLE(row, col, type)` — type: 0=char (ASCII), 1=fg color, 2=bg color
400
-
401
  ---
402
-
403
  ## User-Defined Functions
404
-
405
  ```basic
406
  ' Define BEFORE calling. Name must end with $.
407
  DEF FN Clamp$(val$, lo$, hi$)
@@ -409,12 +409,12 @@ DEF FN Clamp$(val$, lo$, hi$)
409
  IF val$ > hi$ THEN RETURN hi$
410
  RETURN val$
411
  END DEF
412
-
413
  PRINT FN Clamp$(5, 1, 10) ' ✓ OK — return value used
414
  LET v$ = FN Clamp$(15, 0, 10) ' ✓ OK
415
  FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
416
  ```
417
-
418
  - Isolated scope: no access to global `$` variables or global arrays, only global constants (`#`). Using a global array inside a function is an error: `Global array G$ is not visible inside DEF FN - pass it as a parameter with ASJSON() and rebuild it with ASARRAY()`
419
  - **Arrays inside functions:** `DIM` inside a function always creates a **fresh, empty, local** array on every call (and on every recursion level). Local arrays do not survive between calls:
420
  ```basic
@@ -432,11 +432,10 @@ FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
432
  - Supports recursion — uses the real call stack, so extremely deep recursion (thousands of levels) can overflow it. GOSUB/RETURN uses a separate, heap-based stack with no such limit.
433
  - Arrays as parameters not allowed. Use ASJSON to make array as JSON-string to pass it.
434
  - Use `INCLUDE` to load functions from separate files if many
435
-
436
  ---
437
-
438
  ## String Functions
439
-
440
  | Function | Description |
441
  |----------|-------------|
442
  | `ASC(s$)` | ASCII code of first char |
@@ -459,30 +458,30 @@ FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
459
  | `VAL(s$)` | String to number |
460
  | `SHA256(s$)` | SHA256 hash (64-char hex) |
461
  | `BASE64ENCODE(s$)` / `BASE64DECODE(s$)` | Base64 encode/decode |
462
-
463
  > `SRAND(n)` with `n < 0` throws an unhandled arithmetic error (`n = 0` is safe, returns `""`). Never pass an unvalidated or negative length.
464
  > ```basic
465
  > PRINT SRAND(-1)
466
  > ' Error: Arithmetic operation resulted in an overflow.
467
  > ```
468
-
469
  ---
470
-
471
  ## FSTRING — String Interpolation
472
-
473
  `FSTRING(template$)` substitutes `{{-name-}}` placeholders inside a template string with the value of variables, constants, or array elements. Preferred over long `+` concatenation chains.
474
-
475
  ```basic
476
  LET name$ = "Krisu"
477
  LET LEVEL# = 5
478
  PRINT FSTRING("Hello {{-name$-}}, level {{-LEVEL#-}}")
479
  ' Output: Hello Krisu, level 5
480
  ```
481
-
482
  The triple-character markers `{{-` and `-}}` are deliberately unusual so they will not collide with normal text. There is no escape syntax — literal `{{-...-}}` in the template is always parsed as a placeholder.
483
-
484
  ### Placeholder forms
485
-
486
  | Form | Resolves to |
487
  |------|-------------|
488
  | `{{-var$-}}` | Value of variable `var$` |
@@ -492,42 +491,40 @@ The triple-character markers `{{-` and `-}}` are deliberately unusual so they wi
492
  | `{{-arr$(KEY#)-}}` | Array element at index taken from constant `KEY#` |
493
  | `{{-arr$(name)-}}` | Array element at literal string key `"name"` (no quotes inside FSTRING) |
494
  | `{{-arr$(0, i$)-}}` | Multidimensional element, mixed literal and variable indices |
495
-
496
  ### Index resolution rule (array access)
497
-
498
  For each comma-separated index, FSTRING looks at the last character:
499
-
500
  1. Ends with `$` or `#` → variable / constant lookup. Halts if undefined.
501
  2. Parses as a number (`0`, `1.5`, `-3`) → numeric index. `arr$(01)` and `arr$(1.0)` both resolve to key `1`.
502
  3. Otherwise → literal string key. This is what lets `{{-player$(name)-}}` read what was stored with `player$("name") = ...`.
503
-
504
  ### Notes
505
-
506
  - Whitespace inside placeholders is trimmed: `{{- name$ -}}` ≡ `{{-name$-}}`.
507
  - Built-in constants work too (`{{-PI#-}}`, `{{-EULER#-}}`, `{{-arr$(KEY_A#)-}}`) — checked before user variables, same order as normal expressions. (In v1.4c they failed with "undefined variable".)
508
  - Numbers auto-stringify — no `STR()` needed for numeric variables, constants, or array elements.
509
  - FSTRING returns a value; you must use it (`LET`, `PRINT`, pass to function). Calling it as a bare statement is an error.
510
  - Errors halt the program with a line-numbered message: undefined variable, missing closing `-}}`, empty placeholder `{{--}}`, malformed array access, uninitialized array element.
511
-
512
  ### Not supported (intentional)
513
-
514
  No arithmetic, function calls, nested lookups, or quoted string literals inside placeholders. Pre-compute into a variable and reference that:
515
-
516
  ```basic
517
  ' ❌ WRONG
518
  PRINT FSTRING("Total: {{-a$ + 5-}}")
519
  PRINT FSTRING("Name: {{-UCASE(name$)-}}")
520
  PRINT FSTRING("{{-arr$(arr2$(0))-}}")
521
-
522
  ' ✓ RIGHT
523
  LET total$ = a$ + 5
524
  LET upper$ = UCASE(name$)
525
  LET k$ = arr2$(0)
526
  PRINT FSTRING("Total: {{-total$-}}, Name: {{-upper$-}}, Item: {{-arr$(k$)-}}")
527
  ```
528
-
529
  ### Common AI mistakes with FSTRING
530
-
531
  ```basic
532
  ' ❌ WRONG ' ✓ CORRECT
533
  FSTRING("Hi {{name$}}") FSTRING("Hi {{-name$-}}")
@@ -535,43 +532,43 @@ FSTRING("Hi {-name$-}") FSTRING("Hi {{-name$-}}")
535
  FSTRING("Hi {{-name-}}") ' array key FSTRING("Hi {{-name$-}}")
536
  FSTRING("Hi {{-name$-}}") ' as stmt LET s$ = FSTRING("Hi {{-name$-}}")
537
  ```
538
-
539
  Inside a placeholder, `name` (no suffix) is treated as a literal string key for an array lookup, **not** as a reference to variable `name$`. Always include the suffix.
540
-
541
  ### Full working example
542
-
543
  ```basic
544
  DIM player$
545
  player$("name") = "Krisu"
546
  player$("class") = "Bass"
547
  player$("level") = 99
548
-
549
  DIM grid$
550
  grid$(0, 0) = "X"
551
  grid$(0, 1) = "O"
552
  grid$(1, 0) = "."
553
  grid$(1, 1) = "X"
554
-
555
  LET row$ = 1
556
  LET PI# = 3.14
557
-
558
  PRINT FSTRING("{{-player$(name)-}} the {{-player$(class)-}}, lvl {{-player$(level)-}}")
559
  PRINT FSTRING("Row {{-row$-}}: [{{-grid$(row$, 0)-}}{{-grid$(row$, 1)-}}]")
560
  PRINT FSTRING("Pi is roughly {{-PI#-}}")
561
  END
562
  ```
563
-
564
  Output:
565
  ```
566
  Krisu the Bass, lvl 99
567
  Row 1: [.X]
568
  Pi is roughly 3.14
569
  ```
570
-
571
  ---
572
-
573
  ## Math Functions
574
-
575
  | Function | Description |
576
  |----------|-------------|
577
  | `ABS(n)` | Absolute value |
@@ -599,19 +596,19 @@ Pi is roughly 3.14
599
  | `ROUND(n)` | Rounds to nearest integer, half rounds away from zero (`0.5→1`, `-0.5→-1`) — NOT banker's rounding |
600
  | `SGN(n)` | Sign: -1, 0, or 1 |
601
  | `SQR(n)` | Square root |
602
-
603
  **Math constants:** `PI#`, `HPI#` (PI/2), `QPI#` (PI/4), `TAU#` (PI*2), `EULER#`
604
-
605
  ---
606
-
607
  ## Variable Functions
608
-
609
  | Function | Description |
610
  |----------|-------------|
611
  | `ISSET(name)` | `1` if the named variable (`$`) or constant (`#`) is declared, `0` otherwise. Argument is **not evaluated** — `ISSET(undef$)` safely returns `0`. |
612
-
613
  `ISSET` is the only language-introspection function and it has tight rules:
614
-
615
  - **Scalars only.** Variables (`$`) and constants (`#`). Arrays and array elements are stored separately — `ISSET(arr$)` and `ISSET(arr$(0))` always return `0`, never an error.
616
  - **Bare name only.** No expressions, no string literals, no numbers. These all error with "invalid parameter":
617
  ```basic
@@ -627,19 +624,18 @@ Pi is roughly 3.14
627
  PRINT ISSET(A#) ' 0
628
  ```
629
  - **`LET name$` (no value) still counts as set.** `LET` always registers the variable; the value just defaults to empty string for `$` and zero for numeric. `ISSET` reports declaration, not "has a meaningful value".
630
-
631
  Typical use is guarding optional setup:
632
-
633
  ```basic
634
  IF NOT ISSET(playerName$) THEN
635
  LET playerName$ = "Anonymous"
636
  END IF
637
  ```
638
-
639
  ---
640
-
641
  ## Graphics
642
-
643
  ```basic
644
  SCREEN 12 ' 640×480 VGA
645
  SCREEN 0, 800, 600 ' Custom size
@@ -647,7 +643,7 @@ SCREEN 0, 1024, 768, "My Game" ' Custom size + title
647
  FULLSCREEN TRUE ' Borderless fullscreen (graphics only)
648
  FULLSCREEN FALSE ' Windowed
649
  ```
650
-
651
  | Mode | Resolution |
652
  |------|-----------|
653
  | 1 | 320×200 |
@@ -656,7 +652,7 @@ FULLSCREEN FALSE ' Windowed
656
  | 9 | 640×350 |
657
  | 12 | 640×480 ← recommended |
658
  | 13 | 320×200 |
659
-
660
  ### Drawing Primitives
661
  ```basic
662
  PSET (x, y), color ' Pixel
@@ -669,13 +665,13 @@ PAINT (x, y), fillColor, borderColor ' Flood fill
669
  LET c$ = POINT(x, y) ' Read pixel color
670
  LET col$ = RGB(r, g, b) ' Create color (0–255 each)
671
  ```
672
-
673
  **Color values:** Every drawing primitive (`PSET`, `LINE`, `CIRCLE`, `PAINT`, `DRAWSTRING`, `LOADSHAPE`) accepts a `color` parameter that is either a palette index 0–15 or an `RGB(r, g, b)` value — mix freely. The `COLOR` text command is the exception: it accepts palette indices 0–15 only, so `COLOR RGB(...)` does **not** work.
674
-
675
  **Palette (0–15):** 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, 7=Lt Gray, 8=Dk Gray, 9=Lt Blue, 10=Lt Green, 11=Lt Cyan, 12=Lt Red, 13=Lt Magenta, 14=Yellow, 15=White
676
-
677
  > Do **not** hand-construct packed RGB integers (e.g. `16711680`). `RGB()` tags its return value internally so it can be told apart from a palette index; a raw integer lacks that tag and will be misread as a palette index. Always use `RGB(r, g, b)`.
678
-
679
  ### Screen Control
680
  ```basic
681
  SCREENLOCK ON ' Buffer drawing (start frame)
@@ -686,7 +682,7 @@ CLS ' Clear screen
686
  ' Use CLS only with console, in graphics screen its slow
687
  ' With graphics screen, prefer LINE BF
688
  ```
689
-
690
  ### Shapes & Images
691
  ```basic
692
  ' Create shape
@@ -695,12 +691,12 @@ CLS ' Clear screen
695
  LET RECT# = LOADSHAPE("RECTANGLE", w, h, color) ' or "CIRCLE", "TRIANGLE"
696
  LET IMG_PLAYER# = LOADIMAGE("player.png") ' PNG (alpha) or BMP
697
  LET IMG_REMOTE# = LOADIMAGE("https://example.com/a.png") ' Download + load
698
-
699
  ' Sprite sheet — sprites indexed 0-based
700
  DIM sprites$
701
  LOADSHEET sprites$, 128, 128, "sheet.png" ' tileW, tileH, file
702
  MOVESHAPE sprites$(0), x, y ' sprites$(0) = first sprite
703
-
704
  ' Transform
705
  ' NOTE: anchor point differs by type — LOADSHAPE primitives (RECTANGLE/CIRCLE/TRIANGLE)
706
  ' are center-anchored; LOADIMAGE images are top-left-anchored.
@@ -711,32 +707,32 @@ DRAWSHAPE RECT# ' Render to buffer
711
  SHOWSHAPE RECT# / HIDESHAPE RECT# ' Toggle visibility
712
  REMOVESHAPE RECT# ' Free memory (always clean up)
713
  ```
714
-
715
-
716
  ---
717
-
718
  ### Text Rendering (SDL2_ttf.dll required)
719
  #### DRAWSTRING & LOADFONT
720
-
721
-
722
  ```basic
723
  ' Default font: Arial, 16px
724
  DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
725
-
726
  ' Load alternative font — becomes the new default
727
  LOADFONT "comic.ttf", 24
728
  DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
729
-
730
  ' Reset to Arial, 16px
731
  LOADFONT
732
  ```
733
-
734
  `DRAWSTRING x, y` positions the top-left of the text. Requires `SDL2_ttf.dll` in the same directory as the interpreter. Prefer this over PRINT, which makes graphic screen easily blinking. Default font size is **16px** — not 20px.
735
-
736
  ---
737
-
738
  ## Sound
739
-
740
  ```basic
741
  ' LOADSOUND returns a stable integer handle — SDL2 manages the resource.
742
  ' The handle never changes; store it in a constant to protect it from accidental reassignment.
@@ -747,13 +743,13 @@ SOUNDREPEAT(SND_JUMP#) ' Loop continuously
747
  SOUNDSTOP(SND_JUMP#) ' Stop specific sound
748
  SOUNDSTOPALL ' Stop all sounds
749
  ```
750
-
751
  Load all sounds at startup. Call `SOUNDSTOPALL` before `END`.
752
-
753
  ---
754
-
755
  ## File I/O
756
-
757
  ```basic
758
  LET data$ = FileRead("file.txt") ' Read as string
759
  DIM cfg$ : LET cfg$ = FileRead("settings.txt") ' Read as key=value array
@@ -764,48 +760,48 @@ FILEDELETE "temp.dat" ' Delete file
764
  DIM files$
765
  LET n$ = FILELIST(files$, "levels", "*.txt") ' File names into files$(0..n-1), returns n
766
  ```
767
-
768
  **FILELIST:** `FILELIST(arr$, folder$ [, pattern$])` lists files only (no folders, not recursive), names only (no paths), sorted alphabetically ignoring case. The array is cleared first. `pattern$` supports `*` and `?`, default all files. Hidden/system files are skipped. Missing folder → returns `0`. To open a listed file, prepend the folder: `FILEREAD("levels/" + files$(i$))`. Added after v1.4c.
769
-
770
  **key=value parsing:** When `FileRead` assigns to a `DIM`'d array, lines `key=value` become `arr$("key")`. Lines starting with `#` are comments. Perfect for `.env` files.
771
-
772
  ```basic
773
  DIM env$
774
  LET env$ = FileRead(".env")
775
  LET API_KEY# = env$("OPENAI_API_KEY")
776
  ```
777
-
778
  **Paths:** Use `/` or `\\` — never single `\` (it's an escape char). Relative paths are from `PRG_ROOT#`.
779
  `PRG_ROOT#` already ends with a directory separator — concatenate directly, don't add your own `/`:
780
  ```basic
781
  LET path$ = PRG_ROOT# + "data.txt"
782
  ```
783
  **FileWrite with array** saves in key=value format (round-trips with FileRead).
784
-
785
  ---
786
-
787
  ## Network
788
-
789
  ```basic
790
  LET res$ = HTTPGET("https://api.example.com/data")
791
  LET res$ = HTTPPOST("https://api.example.com/submit", "{""key"":""val""}")
792
-
793
  ' With headers (optional)
794
  DIM headers$
795
  headers$("Authorization") = "Bearer mytoken"
796
  headers$("Content-Type") = "application/json"
797
  LET res$ = HTTPGET("https://api.example.com/data", headers$)
798
  LET res$ = HTTPPOST("https://api.example.com/data", body$, headers$)
799
-
800
  ' With timeout in seconds (optional, comes AFTER headers; default 30, 0 = no limit)
801
  LET res$ = HTTPGET("https://api.example.com/data", headers$, 60)
802
  LET res$ = HTTPPOST("http://localhost:11434/v1/chat/completions", body$, headers$, 120)
803
  ```
804
-
805
  ### Local HTTP server (LISTEN)
806
-
807
  BazzBasic can also receive requests as a local-only HTTP server, typically used as glue between a static HTML page and a BazzBasic script on the same machine.
808
-
809
  ```basic
810
  STARTLISTEN 8080 ' bind 127.0.0.1:8080, no admin needed
811
  STARTLISTEN 8080, 5000 ' optional timeout in ms
@@ -813,9 +809,9 @@ LET body$ = GETREQUEST() ' POST/PUT/PATCH body, or GET query strin
813
  SENDRESPONSE "{""status"":""ok""}" ' must be called or browser hangs
814
  STOPLISTEN
815
  ```
816
-
817
  Important rules:
818
-
819
  - **Always pair `GETREQUEST()` with `SENDRESPONSE`.** The browser is waiting on the response. Forgetting `SENDRESPONSE` makes the page hang.
820
  - **Bound to `127.0.0.1` only.** This is local glue, not a real web server. Do not generate code that tries to expose this on the LAN or internet.
821
  - **Body or query string, not full request.** `GETREQUEST()` returns just the POST body (or the GET query string without `?`). Headers, method, and URL path are NOT exposed in this version. If you need structured data, parse the body with `ASARRAY(body$)`.
@@ -823,49 +819,48 @@ Important rules:
823
  - **CORS is automatic.** Every response carries `Access-Control-Allow-Origin: *`. No need to set it manually.
824
  - **One listener at a time.** Calling `STARTLISTEN` while one is already active is an error. Call `STOPLISTEN` first.
825
  - **Always 200 OK, always `text/plain`.** Custom status codes and content types are not supported in this version. To return JSON, just put JSON text in the body — browser-side `response.json()` still works.
826
-
827
  Typical receive-and-process pattern:
828
-
829
  ```basic
830
  STARTLISTEN 8080
831
  PRINT "Waiting for browser..."
832
-
833
  LET json$ = GETREQUEST()
834
  DIM data$
835
  LET data$ = ASARRAY(json$)
836
-
837
  PRINT "Got name: " + data$("name")
838
-
839
  SENDRESPONSE "{""status"":""ok""}"
840
  STOPLISTEN
841
  END
842
  ```
843
-
844
  ---
845
-
846
  ## Arrays & JSON
847
-
848
  Nested JSON maps to comma-separated keys: `data$("player,name")`, `data$("skills,0")`
849
-
850
  ```basic
851
  ' Array → JSON string
852
  LET json$ = ASJSON(arr$)
853
-
854
  ' JSON string → array (returns element count)
855
  DIM data$
856
  LET count$ = ASARRAY(data$, json$)
857
-
858
  ' Load/save JSON files
859
  LOADJSON arr$, "file.json"
860
  SAVEJSON arr$, "file.json"
861
  ```
862
-
863
  ---
864
-
865
  ## Fast Trigonometry
866
-
867
  ~20× faster than `SIN(RAD(x))`, 1-degree precision. Uses ~5.6 KB memory.
868
-
869
  ```basic
870
  FastTrig(TRUE) ' Enable lookup tables (must call first)
871
  LET x$ = FastCos(45) ' Degrees, auto-normalized 0–359
@@ -873,25 +868,25 @@ LET y$ = FastSin(90)
873
  LET r$ = FastRad(180) ' Deg→rad (no FastTrig needed)
874
  FastTrig(FALSE) ' Free memory
875
  ```
876
-
877
  Use for raycasting, sprite rotation, particle systems, any high-freq trig.
878
-
879
  ---
880
-
881
  ## Date & Time
882
-
883
  ```basic
884
  LET t$ = TIME() ' Current time, default format "HH:mm:ss" -> "15:21:22"
885
  LET t2$ = TIME("dd.MM.yyyy") ' .NET DateTime format string -> "04.09.2026"
886
  LET t3$ = TIME("dddd") ' -> "Friday"
887
-
888
  LET start$ = TICKS ' Milliseconds since program start
889
  ' ... later in a loop ...
890
  LET elapsed$ = TICKS - start$ ' Delta time — use for frame-independent movement
891
  ```
892
-
893
  `TICKS` is the standard way to do frame-independent (delta-time) movement in a game loop — prefer it over counting fixed `SLEEP` increments.
894
-
895
  ```basic
896
  ' ✅ Preferred: frame-independent movement
897
  LET lastTick$ = TICKS
@@ -901,79 +896,77 @@ WHILE running$
901
  x$ = x$ + speed$ * delta$ / 16 ' normalize to ~60 FPS baseline
902
  GOSUB [sub:draw]
903
  WEND
904
-
905
  ' ❌ Avoid: fixed SLEEP without delta — speed varies with actual frame rate
906
  SLEEP 16
907
  x$ = x$ + speed$
908
  ```
909
-
910
  ---
911
-
912
  ## Command-Line Arguments
913
-
914
  ```basic
915
  ' bazzbasic.exe myprog.bas arg1 arg2
916
  PRINT ARGCOUNT ' number of args (2 in this example)
917
  PRINT ARGS(0) ' first arg → "arg1"
918
  PRINT ARGS(1) ' second arg → "arg2"
919
  ```
920
-
921
  `ARGCOUNT` and `ARGS(n)` are 0-based; ARGS does not include the interpreter or script name.
922
-
923
  ---
924
-
925
  ## Libraries & INCLUDE
926
-
927
  ```basic
928
  INCLUDE "helpers.bas" ' Insert source at this point
929
  INCLUDE "MathLib.bb" ' Load compiled library
930
-
931
  ' Compile library (functions only — no loose code)
932
  ' bazzbasic.exe -lib MathLib.bas → MathLib.bb
933
  ' Function names auto-prefixed: MATHLIB_functionname$
934
  PRINT FN MATHLIB_add$(5, 3)
935
  ```
936
-
937
  Library functions can read main-program constants (`#`). `.bb` files are version-locked.
938
-
939
  - **No extension fallback.** `INCLUDE "helpers"` does NOT try `helpers.bas` automatically — give the exact filename, extension included.
940
  - **Path resolution order:** relative to the *including file's own directory* first, then relative to the program's base path.
941
  - **Circular includes are detected** and halt with `Circular INCLUDE detected: <file>`.
942
-
943
  ---
944
-
945
  ## Passing Arrays to Functions
946
-
947
  Arrays cannot be passed directly to `DEF FN` functions, but a clean workaround exists using JSON serialization. Convert the array to a JSON string with `ASJSON`, pass the string as a parameter, then deserialize inside the function with `ASARRAY`. This is the accepted pattern in BazzBasic v1.2+.
948
-
949
  ```basic
950
  DEF FN ProcessPlayer$(data$)
951
  DIM arr$
952
  LET count$ = ASARRAY(arr$, data$)
953
  RETURN arr$("name") + " score:" + arr$("score")
954
  END DEF
955
-
956
  [inits]
957
  DIM player$
958
  player$("name") = "Alice"
959
  player$("score") = 9999
960
  player$("address,city") = "New York"
961
-
962
  [main]
963
  LET json$ = ASJSON(player$)
964
  PRINT FN ProcessPlayer$(json$)
965
  END
966
  ```
967
-
968
  **Notes:**
969
  - The function receives a full independent copy — changes inside do not affect the original array
970
  - Nested keys work normally: `arr$("address,city")` etc.
971
  - Overhead is similar to copying an array manually; acceptable for most use cases
972
-
973
  ---
974
-
975
  ## Program Structure
976
-
977
  ```basic
978
  ' ---- 1. FUNCTIONS (or INCLUDE "functions.bas/bb") ----
979
  DEF FN Clamp$(v$, lo$, hi$)
@@ -981,20 +974,20 @@ DEF FN Clamp$(v$, lo$, hi$)
981
  IF v$ > hi$ THEN RETURN hi$
982
  RETURN v$
983
  END DEF
984
-
985
  ' ---- 2. INIT (declare ALL constants & variables here, not inside loops) ----
986
  ' Performance: variables declared outside loops avoid repeated existence checks.
987
  [inits]
988
  LET SCREEN_W# = 640
989
  LET SCREEN_H# = 480
990
  LET MAX_SPEED# = 5
991
-
992
  SCREEN 0, SCREEN_W#, SCREEN_H#, "My Game"
993
-
994
  LET x$ = 320
995
  LET y$ = 240
996
  LET running$ = TRUE
997
-
998
  ' ---- 3. MAIN LOOP ----
999
  [main]
1000
  WHILE running$
@@ -1005,13 +998,13 @@ END DEF
1005
  WEND
1006
  SOUNDSTOPALL
1007
  END ' place at the end of main program so BazzBasic wont fall to subs in runtime
1008
-
1009
  ' ---- 4. SUBROUTINES (or INCLUDE "subs.bas") ----
1010
  [sub:update]
1011
  IF KEYDOWN(KEY_LEFT#) THEN x$ = x$ - MAX_SPEED#
1012
  IF KEYDOWN(KEY_RIGHT#) THEN x$ = x$ + MAX_SPEED#
1013
  RETURN
1014
-
1015
  [sub:draw]
1016
  SCREENLOCK ON
1017
  LINE (0,0)-(SCREEN_W#, SCREEN_H#), 0, BF
@@ -1019,30 +1012,28 @@ RETURN
1019
  SCREENLOCK OFF
1020
  RETURN
1021
  ```
1022
-
1023
  **Key conventions:**
1024
  - Variables: `camelCase$` | Constants: `UPPER_SNAKE_CASE#` | Functions: `PascalCase$`
1025
  - Labels: `[gameLoop]` for jump targets, `[sub:name]` for subroutines
1026
  - Image/sound/shape IDs are stable integer handles — **always** store as constants: `LET MY_IMG# = LOADIMAGE("x.png")` — never use `$` variables for these
1027
  - Group many IDs → use arrays: `DIM sprites$` / `sprites$("player") = LOADIMAGE(...)` — but prefer named constants when count is small
1028
-
1029
  ---
1030
-
1031
  ## Performance Tips
1032
-
1033
  - `LINE (0,0)-(W,H), 0, BF` to clear — much faster than `CLS`
1034
  - Always wrap draw code in `SCREENLOCK ON` / `SCREENLOCK OFF`
1035
  - Store `RGB()` results in constants/variables — don't call RGB in hot loops
1036
  - Declare all variables in `[inits]`, not inside loops or subroutines
1037
  - Use `FastTrig` for any loop calling trig hundreds of times per frame
1038
  - `SLEEP 16` in game loop → ~60 FPS
1039
-
1040
  ---
1041
-
1042
  ## Known Limitations
1043
-
1044
  Things to be aware of — most are deliberate design decisions, a few are practical constraints.
1045
-
1046
  - **No line numbers.** Never supported, never will be.
1047
  - **Platform: Windows x64 only.** Linux and macOS are not supported. Browser/Android are not feasible — the runtime depends on SDL2 via P/Invoke.
1048
  - **Arrays cannot be passed to functions.** Use the `ASJSON` / `ASARRAY` round-trip pattern. The function receives an independent copy.
@@ -1053,11 +1044,10 @@ Things to be aware of — most are deliberate design decisions, a few are practi
1053
  - **No integer-division operator.** Use `INT(a / b)`, `FLOOR(a / b)`, or `CINT(a / b)` depending on the rounding behavior you need.
1054
  - **Compiled `.bb` libraries are version-locked** to the BazzBasic build that produced them. Recompile after upgrading the interpreter.
1055
  - **`DEF FN` definitions must precede their first call** in source order. Forward references don't resolve.
1056
-
1057
  ---
1058
-
1059
  ## IDE Features
1060
-
1061
  ### Menus
1062
  | Menu | Items |
1063
  |------|-------|
@@ -1067,29 +1057,26 @@ Things to be aware of — most are deliberate design decisions, a few are practi
1067
  | **View** | Light Mode, Dark Mode (experimental; choice saved to `%AppData%\BazzBasic\ide.json`) |
1068
  | **Run** | Run Program (F5), Compile as Exe, Compile as Library (.bb) |
1069
  | **Help** | About, Online Manual, Beginner's Guide, Rosetta Code, Check for Updates |
1070
-
1071
  **Version note:** In v1.4c and older, Find and Replace are under **Edit**, there is no Undo/Redo/Cut/Copy/Paste menu (the shortcuts still work in the editor), there is no View menu or Dark Mode, and Help has no Online Manual or Rosetta Code links. If a user says Find is under Edit, they have an older build.
1072
-
1073
  ### New File Template
1074
  When the IDE opens with no file (or a new file), this template is auto-inserted:
1075
  ```basic
1076
  ' BazzBasic version {ver_num}
1077
  ' https://ekbass.github.io/BazzBasic/
1078
  ```
1079
-
1080
  ### Beginner's Guide
1081
  - **IDE:** Menu → **Help** → **Beginner's Guide** — opens `https://github.com/EkBass/BazzBasic-Beginners-Guide/releases` in default browser
1082
  - **CLI:** `bazzbasic.exe -guide` or `bazzbasic.exe -help` — prints URL to terminal
1083
-
1084
  ### Online Manual and Rosetta Code
1085
  - **IDE:** Menu → **Help** → **Online Manual** — opens `https://ekbass.github.io/BazzBasic/manual/#/` in default browser
1086
  - **IDE:** Menu → **Help** → **Rosetta Code** — opens `https://rosettacode.org/wiki/Category:BazzBasic` in default browser
1087
  - No CLI equivalents
1088
-
1089
  ### Check for Updates
1090
  - **IDE:** Menu → **Help** → **Check for Updates...** — IDE reports if a newer version is available
1091
  - **CLI:** `bazzbasic.exe -checkupdates`
1092
-
1093
  ### Compile via IDE
1094
  - **Menu → Run → Compile as Exe** — compiles open file to standalone `.exe` (auto-saves first)
1095
  - **Menu → Run → Compile as Library (.bb)** — compiles open file as reusable `.bb` library (auto-saves first)
 
2
  name: bazzbasic
3
  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 question about BazzBasic features. Always use this skill before writing any BazzBasic code."
4
  ---
5
+
6
  # BazzBasic Language Reference
7
  **Version:** 1.5 | **Author:** Kristian Virtanen (EkBass) | **Platform:** Windows x64
8
  **Homepage:** https://ekbass.github.io/BazzBasic/
 
14
  **BazzBasic-AI-Guide:** https://huggingface.co/datasets/EkBass/BazzBasic_AI_Guide
15
  **BazzBasic Beginner's Guide:** https://github.com/EkBass/BazzBasic-Beginners-Guide/releases
16
  **Communities:** https://ekbass.github.io/BazzBasic/communities.html
17
+
18
  ---
19
+
20
+ ## ⚠\u{fe0f} Critical Rules — Read First
21
+
22
  | Rule | Detail |
23
  |------|--------|
24
  | Variables end with `$` | `name$`, `score$`, `x$` |
 
37
  | No integer-division operator | Use `INT(a / b)`, `FLOOR(a / b)`, or `CINT(a / b)` |
38
  | Errors halt the program | No `TRY`/`CATCH` or `ON ERROR` — line-numbered message printed |
39
  | No line-continuation char | Don't use `_`, `\`, or `&` — lexer continues automatically after operators or open `(` |
40
+
41
  ---
42
+
43
  ## 🚫 Common AI Mistakes (avoid these)
44
+
45
  These are the patterns LLMs most often produce when extrapolating from QBASIC, FreeBASIC, or VB. None of them are valid BazzBasic.
46
+
47
  ```basic
48
  ' ❌ WRONG ' ✓ CORRECT
49
  LET x = 5 LET x$ = 5
 
59
  LET x$ = a$ + _ ' VBA continuation LET x$ = a$ + ' just leave the operator
60
  LET x$ = a$ + \ ' Python continuation LET x$ = a$ + ' or open a paren — see Line Continuation
61
  ```
62
+
63
  **Two more traps that don't fit the table:**
64
+
65
  - Inside `DEF FN` you can read `#` constants from the outer scope but **not** `$` variables or global arrays. Pass values as parameters.
66
  - Arrays cannot be passed to a function directly, and a function cannot see global arrays. Serialize with `ASJSON()` and rebuild inside the function with `ASARRAY()` — see *Passing Arrays to Functions* below.
 
67
  ---
68
+
69
  ## Minimal Valid Program
70
+
71
  ```basic
72
  ' Suggested style to use [subs]
73
  [inits] ' [name] is a plain jump label, not a keyword — see Control Flow
74
  LET name$ = "World"
75
+
76
  [main]
77
  PRINT "Hello, " + name$
78
  END
79
+
80
  ' other subs after END'
81
  [sub:drawScreen]
82
  ' draw
83
  RETURN
84
  ```
85
+
86
  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.
87
+
88
  ---
89
+
90
  ## When Generating BazzBasic Code
91
+
92
  (Suffix and return-value rules are already covered in Critical Rules above — not repeated here.)
93
+
94
  - Prefer `FSTRING` over long `+` concatenation chains for multi-variable strings
95
  - Place `DEF FN` definitions at the top of the file or via `INCLUDE`
96
  - Store every `LOADIMAGE` / `LOADSOUND` / `LOADSHAPE` handle as a `#` constant
97
  - In graphics mode, prefer `LINE (0,0)-(W,H), 0, BF` over `CLS`, and `DRAWSTRING` over `PRINT`
98
  - Wrap each frame's drawing in `SCREENLOCK ON` / `SCREENLOCK OFF`
99
  - 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
 
100
  ---
101
+
102
+
103
  ## ABOUT
104
+
105
  BazzBasic is built around one simple idea: starting programming should feel nice, even fun — the ease and small joyful moments of the classic BASICs of decades past, with a fresh, modern feel.
106
+
107
  Over the years my own skills have grown and I've moved on to more versatile languages, but BASIC has always stayed fun for quick experiments — a simple adventure game, a lottery machine, a quiz, or just balls bouncing on the screen. BazzBasic was built with that in mind: a language that gets out of your way so curiosity can run free. And when you finish your first little game and crave something bigger, and eventually move on to another language — that's BazzBasic succeeding at exactly what it was meant to do.
108
+
109
  To arouse your curiosity.
110
+
111
  *EkBass*, author of BazzBasic
112
+
113
  ---
114
+
115
  ## Case sensitivity
116
  BazzBasic is not case-sensitive except with string contents.
117
  ```basic
118
  let blaa$ = "Hello"
119
  PriNT BLAA$ ' output: Hello
120
  ```
121
+
122
  ---
123
+
124
  ## Line Continuation
125
+
126
  BazzBasic has **no line-continuation character**. Do not generate `_` (VBA), `\` (Python), or `&` (other dialects). The lexer figures out continuation automatically using two rules.
127
+
128
  **Rule 1 — operator at end of line.** If a line ends in a token that cannot legally end an expression, the next line continues it:
129
+
130
  ```basic
131
  LET total$ = price$ * count$ -
132
  discount$
133
+
134
  IF score$ >= 0 AND
135
  score$ <= 100 THEN
136
  PRINT "Valid"
137
  END IF
138
+
139
  LET counter$ +=
140
  step$
141
  ```
142
+
143
  Tokens that trigger this: `+ - * / % = <> < <= > >= AND OR += -= *= /= ,`
144
+
145
  > `%` IS a real binary modulo operator (`a % b`, same precedence as `*`/`/`, same result as `MOD(a, b)`) and DOES trigger continuation like the other arithmetic operators above.
146
  > `MOD` is a separate thing — a function `MOD(a, b)` — not a binary operator, so it does NOT trigger continuation (a `)` at line end never continues).
147
+
148
  **Rule 2 — open paren.** Anything inside an unmatched `(` keeps reading until the matching `)`:
149
+
150
  ```basic
151
  LET dist$ = DISTANCE(
152
  x1$, y1$,
153
  x2$, y2$
154
  )
155
  ```
156
+
157
  Both rules combine:
158
+
159
  ```basic
160
  LET total$ = (
161
  base$ +
162
  tax$
163
  )
164
  ```
165
+
166
  **Trap for AI generators.** Do NOT emit a trailing `_`, `\`, `&`, or any other continuation marker — they are not BazzBasic syntax and will produce parse errors. Just leave the operator at the end of the line, or open a paren.
167
+
168
  ---
169
+
170
  ## Variables & Constants
171
  Variables and constants must be declared with LET before they can be used.
172
  BazzBasic variables are not typed, but work the same way as in JavaScript, for example.
173
  A variable needs the suffix $ which often is linked as STRING in traditional basic variants.
174
+
175
  Variables require suffix "$". Constants require suffix "#".
176
  The suffix does not define data type — only "#" indicates immutability.
177
  ```basic
178
  LET a$ ' Declare variable without value
179
  LET b$, c$, d$ ' Multiple variable declarations without value
180
  LET e$, f$ = "foo", g$ = 10 ' Multiple variable declaration, e$ stays empty, f$ and g$ gets values
181
+
182
  LET name$ = "Alice" ' String variable
183
  LET score$ = 0 ' Numeric variable
184
+
185
  LET PI# = 3.14159 ' Constant (immutable)
186
  LET TITLE# = "My Game" ' String constant
187
  ```
188
+
189
  **Compound assignment operators** (variables only — **not** allowed with `#` constants):
190
+
191
  ```basic
192
  LET x$ = 1
193
  x$ += 5 ' add
 
197
  LET s$ = "Hello"
198
  s$ += " World" ' string concatenation
199
  ```
200
+
201
  **Scope:** All main-code variables share one scope (IF, FOR, and WHILE do NOT create new scope).
202
  Main-code variables ($) and arrays are NOT accessible inside DEF FN.
203
  `DEF FN` functions are fully isolated — only global constants (`#`) accessible inside.
204
+
205
  **Comparison:** `"123" = 123` is TRUE (cross-type), but keep types consistent for speed.
206
+
207
  ---
208
+
209
  ### Built-in Constants
210
  - **Boolean:** `TRUE` (`1`), `FALSE` (`0`) — plain numbers, not a separate type. `IF x$ = 1` and `IF x$ = TRUE` are identical.
211
  - **Math:** `PI#`, `HPI#` (π/2 = 90°), `QPI#` (π/4 = 45°), `TAU#` (2π = 360°), `EULER#` (e) — `#` suffix required
 
213
  - **Version:** `BBVER#` (returns current version of BazzBasic, ie: "1.5")
214
  - **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_NUMPAD0#`…`KEY_NUMPAD9#`, `KEY_NUMPAD_PLUS#`/`_MINUS#`/`_MUL#`/`_DIV#`/`_DOT#`, `KEY_LSHIFT#`, `KEY_LCTRL#`, etc. — see *Keyboard Input*
215
  - **Gamepad:** buttons `PAD_A#`…`PAD_Y#`, `PAD_UP#`/`_DOWN#`/`_LEFT#`/`_RIGHT#`, `PAD_LB#`, `PAD_RB#`, `PAD_START#`, `PAD_BACK#` etc.; axes `PAD_LX#`, `PAD_LY#`, `PAD_RX#`, `PAD_RY#`, `PAD_LT#`, `PAD_RT#` — see *Gamepad*
 
216
  ---
217
+
218
  ## Arrays
219
  BazzBasic arrays are fully dynamic and support numeric, string, or mixed indexing.
220
+
221
+
222
  ```basic
223
  DIM scores$ ' Declare (required before use)
224
  DIM a$, b$, c$ ' Multiple
225
  scores$(0) = 95 ' Numeric indices are 0-based.
226
  scores$("name") = "Alice" ' String keys are associative, insertion-ordered.
227
  matrix$(0, 1) = "A2" ' Multi-dimensional
228
+
229
  DIM sounds$
230
  sounds$("guns", "shotgun_shoot") = "shoot_shotgun.wav"
231
  sounds$("guns", "shotgun_reload") = "reload_shotgun.wav"
232
  sounds$("guns", "ak47_shoot") = "shoot_ak47.wav"
233
  sounds$("guns", "ak47_reload") = "reload_ak47.wav"
234
  sounds$("food", "ham_eat") = "eat_ham.wav"
235
+
236
  PRINT LEN(sounds$()) ' 5 - total elements across both "guns" and "food" groups
237
  PRINT ROWCOUNT(sounds$()) ' 2, "guns" & "food"
238
+
239
  DIM car$
240
  car$("manufacturer") = "Ford"
241
  car$("engine") = "1.6 Eco"
242
  car$("color") = "Blue"
243
+
244
  FOR i$ = 0 TO LEN(car$()) - 1 ' Iterate an associative array: LEN + ARRKEY
245
  LET key$ = ARRKEY(car$(), i$) ' No FOREACH in BazzBasic - this is the idiom
246
  PRINT key$; " = "; car$(key$)
247
  NEXT i$
248
  ```
249
+
250
  | Function/Command | Description |
251
  |-----------------|-------------|
252
  | `LEN(arr$())` | Total element count (LEN counts all nested elements across all dimensions) |
 
256
  | `DELKEY arr$(key)` | Remove one element |
257
  | `DELARRAY arr$` | Remove entire array (can re-DIM after) |
258
  | `JOIN dest$, src1$, src2$` | Merge two arrays; `src2$` keys overwrite `src1$`. Use empty `src1$` as `COPYARRAY`. |
259
+
260
  **JOIN** Matching keys from src2$ overwrite src1$ at the same level
261
+
262
  **Always check with `HASKEY` before reading uninitialized elements.**
263
+
264
  > `DIM arr$ = value` (single value, not `key=value` text) stores it at `arr$(0)` — NOT as a scalar. `DIM x$ = 5` does not make `x$` printable as a plain number; it makes `x$(0)` equal `5`. If a scalar is what you want, use `LET`, not `DIM`.
265
+
266
  ---
267
+
268
  ## Control Flow
269
+
270
  ```basic
271
  ' Block IF
272
  IF score$ >= 90 THEN
 
276
  ELSE
277
  PRINT "F"
278
  END IF ' ENDIF also works
279
+
280
  ' One-line IF
281
  IF lives$ = 0 THEN GOTO [game_over]
282
  IF key$ = KEY_ESC# THEN GOTO [menu] ELSE GOTO [play]
283
+
284
  ' FOR (auto-declares variable)
285
  FOR i$ = 1 TO 10 STEP 2 : PRINT i$ : NEXT
286
  FOR i$ = 10 TO 1 STEP -1 : PRINT i$ : NEXT
287
+
288
  ' WHILE
289
  WHILE x$ < 100
290
  x$ = x$ * 2
291
  WEND
292
+
293
  ' Labels, GOTO, GOSUB
294
  [start]
295
  GOSUB [sub:init]
296
  ' Avoid jumping into the middle of logical blocks (e.g. inside IF/WHILE)
297
  GOTO [start]
298
+
299
  [sub:init]
300
  LET x$ = 0
301
  RETURN
302
+
303
  ' Dynamic jump (variable must contain "[label]" with brackets)
304
  LET target$ = "[menu]"
305
  GOTO target$
306
+
307
  ' Other
308
  SLEEP 2000 ' Pause for milliseconds
309
  END ' Terminate program
 
311
  **Note:** Labels are case-insensitive and may contain almost any printable character.
312
  Whitespace is trimmed. Everything between "[" and "]" is treated as the label name.
313
  ---
314
+
315
  ## I/O
316
+
317
  | Command | Description |
318
  |---------|-------------|
319
  | `PRINT expr; expr` | `;` = no space, `,` = tab |
 
328
  | `COLOR fg, bg` | Text colors (0–15 palette) |
329
  | `SHELL("cmd")` | Run shell command, returns output |
330
  | `SHELL("cmd", ms)` | With timeout in ms (default 5000) |
331
+
332
  ' ; prints without spacing
333
  ' , prints tab separation
334
  ' Both can be mixed in a single PRINT statement
335
  ' INPUT splits on whitespace and comma; quoted strings are treated as single values
336
+
337
  **Escape sequences in strings:** `\"` `\n` `\t` `\\`
338
+
339
  **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:
340
  - Always append `2>&1` to the command, or SQL errors disappear silently.
341
  - Use `\"` (BazzBasic escape) to wrap the SQL for the OS shell: `SHELL("sqlite3 db.sqlite \"SELECT * FROM users\" 2>&1")`.
342
  - In paths use `/` or `\\` — never a single `\`.
 
343
  ### Keyboard Input
344
  | Function | Returns | Notes |
345
  |----------|---------|-------|
346
  | `INKEY` | Key value or 0 | Non-blocking |
347
  | `KEYDOWN(key#)` | TRUE/FALSE | Held-key detection; KEYDOWN only works in graphics mode |
348
  | `WAITKEY(key#, ...)` | Key value | Blocks until key pressed; `WAITKEY()` = any key |
349
+
350
  **Keyboard layouts.** Letters (`KEY_A#`…`KEY_Z#`), digits, arrows, Space/Enter/Esc, F-keys,
351
  numpad and modifiers are the same on every keyboard layout — use these for controls.
352
  Main-keyboard punctuation (`+ - = , . /` etc. and their `KEY_*#` constants) depends on the
353
  layout: never bind controls to `ASC("+")` or `ASC("-")`. Use letters or
354
  `KEY_NUMPAD_PLUS#` / `KEY_NUMPAD_MINUS#` instead.
355
+
356
  - Letters always return uppercase codes (`"a"` and `"A"` → `KEY_A#`), in both graphics and console mode.
357
  - `KEYDOWN` follows the key *label* on the current layout, same as `INKEY`: `KEYDOWN(KEY_A#)` is the key that types "a" (on AZERTY that is a different physical key than on QWERTY). If no key types a punctuation character without modifiers (e.g. "=" on a Finnish keyboard), `KEYDOWN` of that constant is always FALSE.
358
  - Numpad: `KEY_NUMPAD0#`…`KEY_NUMPAD9#`, `KEY_NUMPAD_PLUS#`, `KEY_NUMPAD_MINUS#`,
 
367
  `MOUSELEFT`, MOUSERIGHT, MOUSEMIDDLE — return 1 if pressed, 0 otherwise
368
  `MOUSEHIDE` — hide the mouse cursor (graphics screen only)
369
  `MOUSESHOW` — restore the mouse cursor (graphics screen only)
370
+
371
  ### Gamepad (console AND graphics mode) — added in v1.5
372
+
373
+ > **DISCLAIMER:** BazzBasic version 1.5 has been tested with only one PS4-compatible Bluetooth controller. Therefore, for the time being, I cannot guarantee that GamePad support will work with all different types of controllers.
374
+
375
+ When a user reports a pad not being detected, wrong button mapping or odd axis values, keep this in mind: it may be an untested-controller issue rather than a bug in their code.
376
+
377
  | Function | Returns | Notes |
378
  |----------|---------|-------|
379
  | `GAMEPADS()` | Number of connected pads | Parentheses optional |
 
381
  | `PADAXIS(pad, axis)` | Number | Sticks -1.0…1.0, triggers 0.0…1.0, built-in dead zone |
382
  | `PADNAME(pad)` | String | e.g. `"PS4 Controller"`, `""` if not connected |
383
  | `PADRUMBLE pad, strength, ms` | — (statement) | strength 0.0…1.0, non-blocking, parentheses optional |
384
+
385
  - Pad index is **0-based**, max 8 pads. A pad keeps its number while connected (stable slots, not re-packed on disconnect).
386
  - **No `SCREEN` needed** — unlike `KEYDOWN`/mouse, gamepad functions work in console programs too.
387
  - **Disconnected pad = no input, never an error:** `PADBUTTON` → FALSE, `PADAXIS` → 0, `PADNAME` → `""`. Do not generate guard code like `IF GAMEPADS() > 0 THEN` around every read; use `GAMEPADS()` only to show a "connect a pad" message.
 
394
  - Stick as digital direction: `IF PADAXIS(0, PAD_LX#) < -0.5 THEN ...`
395
  - Typical game input = pad OR keyboard: `IF PADBUTTON(0, PAD_LEFT#) OR KEYDOWN(KEY_LEFT#) THEN dx$ = -1`
396
  - Many third-party pads identify as PS4/Xbox controllers — normal, mapping still correct.
 
397
  ### Console Read
398
  Returns numeric or character depending on type parameter
399
  `GETCONSOLE(row, col, type)` — type: 0=char (ASCII), 1=fg color, 2=bg color
400
+
401
  ---
402
+
403
  ## User-Defined Functions
404
+
405
  ```basic
406
  ' Define BEFORE calling. Name must end with $.
407
  DEF FN Clamp$(val$, lo$, hi$)
 
409
  IF val$ > hi$ THEN RETURN hi$
410
  RETURN val$
411
  END DEF
412
+
413
  PRINT FN Clamp$(5, 1, 10) ' ✓ OK — return value used
414
  LET v$ = FN Clamp$(15, 0, 10) ' ✓ OK
415
  FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
416
  ```
417
+
418
  - Isolated scope: no access to global `$` variables or global arrays, only global constants (`#`). Using a global array inside a function is an error: `Global array G$ is not visible inside DEF FN - pass it as a parameter with ASJSON() and rebuild it with ASARRAY()`
419
  - **Arrays inside functions:** `DIM` inside a function always creates a **fresh, empty, local** array on every call (and on every recursion level). Local arrays do not survive between calls:
420
  ```basic
 
432
  - Supports recursion — uses the real call stack, so extremely deep recursion (thousands of levels) can overflow it. GOSUB/RETURN uses a separate, heap-based stack with no such limit.
433
  - Arrays as parameters not allowed. Use ASJSON to make array as JSON-string to pass it.
434
  - Use `INCLUDE` to load functions from separate files if many
 
435
  ---
436
+
437
  ## String Functions
438
+
439
  | Function | Description |
440
  |----------|-------------|
441
  | `ASC(s$)` | ASCII code of first char |
 
458
  | `VAL(s$)` | String to number |
459
  | `SHA256(s$)` | SHA256 hash (64-char hex) |
460
  | `BASE64ENCODE(s$)` / `BASE64DECODE(s$)` | Base64 encode/decode |
461
+
462
  > `SRAND(n)` with `n < 0` throws an unhandled arithmetic error (`n = 0` is safe, returns `""`). Never pass an unvalidated or negative length.
463
  > ```basic
464
  > PRINT SRAND(-1)
465
  > ' Error: Arithmetic operation resulted in an overflow.
466
  > ```
467
+
468
  ---
469
+
470
  ## FSTRING — String Interpolation
471
+
472
  `FSTRING(template$)` substitutes `{{-name-}}` placeholders inside a template string with the value of variables, constants, or array elements. Preferred over long `+` concatenation chains.
473
+
474
  ```basic
475
  LET name$ = "Krisu"
476
  LET LEVEL# = 5
477
  PRINT FSTRING("Hello {{-name$-}}, level {{-LEVEL#-}}")
478
  ' Output: Hello Krisu, level 5
479
  ```
480
+
481
  The triple-character markers `{{-` and `-}}` are deliberately unusual so they will not collide with normal text. There is no escape syntax — literal `{{-...-}}` in the template is always parsed as a placeholder.
482
+
483
  ### Placeholder forms
484
+
485
  | Form | Resolves to |
486
  |------|-------------|
487
  | `{{-var$-}}` | Value of variable `var$` |
 
491
  | `{{-arr$(KEY#)-}}` | Array element at index taken from constant `KEY#` |
492
  | `{{-arr$(name)-}}` | Array element at literal string key `"name"` (no quotes inside FSTRING) |
493
  | `{{-arr$(0, i$)-}}` | Multidimensional element, mixed literal and variable indices |
494
+
495
  ### Index resolution rule (array access)
496
+
497
  For each comma-separated index, FSTRING looks at the last character:
498
+
499
  1. Ends with `$` or `#` → variable / constant lookup. Halts if undefined.
500
  2. Parses as a number (`0`, `1.5`, `-3`) → numeric index. `arr$(01)` and `arr$(1.0)` both resolve to key `1`.
501
  3. Otherwise → literal string key. This is what lets `{{-player$(name)-}}` read what was stored with `player$("name") = ...`.
 
502
  ### Notes
503
+
504
  - Whitespace inside placeholders is trimmed: `{{- name$ -}}` ≡ `{{-name$-}}`.
505
  - Built-in constants work too (`{{-PI#-}}`, `{{-EULER#-}}`, `{{-arr$(KEY_A#)-}}`) — checked before user variables, same order as normal expressions. (In v1.4c they failed with "undefined variable".)
506
  - Numbers auto-stringify — no `STR()` needed for numeric variables, constants, or array elements.
507
  - FSTRING returns a value; you must use it (`LET`, `PRINT`, pass to function). Calling it as a bare statement is an error.
508
  - Errors halt the program with a line-numbered message: undefined variable, missing closing `-}}`, empty placeholder `{{--}}`, malformed array access, uninitialized array element.
 
509
  ### Not supported (intentional)
510
+
511
  No arithmetic, function calls, nested lookups, or quoted string literals inside placeholders. Pre-compute into a variable and reference that:
512
+
513
  ```basic
514
  ' ❌ WRONG
515
  PRINT FSTRING("Total: {{-a$ + 5-}}")
516
  PRINT FSTRING("Name: {{-UCASE(name$)-}}")
517
  PRINT FSTRING("{{-arr$(arr2$(0))-}}")
518
+
519
  ' ✓ RIGHT
520
  LET total$ = a$ + 5
521
  LET upper$ = UCASE(name$)
522
  LET k$ = arr2$(0)
523
  PRINT FSTRING("Total: {{-total$-}}, Name: {{-upper$-}}, Item: {{-arr$(k$)-}}")
524
  ```
525
+
526
  ### Common AI mistakes with FSTRING
527
+
528
  ```basic
529
  ' ❌ WRONG ' ✓ CORRECT
530
  FSTRING("Hi {{name$}}") FSTRING("Hi {{-name$-}}")
 
532
  FSTRING("Hi {{-name-}}") ' array key FSTRING("Hi {{-name$-}}")
533
  FSTRING("Hi {{-name$-}}") ' as stmt LET s$ = FSTRING("Hi {{-name$-}}")
534
  ```
535
+
536
  Inside a placeholder, `name` (no suffix) is treated as a literal string key for an array lookup, **not** as a reference to variable `name$`. Always include the suffix.
537
+
538
  ### Full working example
539
+
540
  ```basic
541
  DIM player$
542
  player$("name") = "Krisu"
543
  player$("class") = "Bass"
544
  player$("level") = 99
545
+
546
  DIM grid$
547
  grid$(0, 0) = "X"
548
  grid$(0, 1) = "O"
549
  grid$(1, 0) = "."
550
  grid$(1, 1) = "X"
551
+
552
  LET row$ = 1
553
  LET PI# = 3.14
554
+
555
  PRINT FSTRING("{{-player$(name)-}} the {{-player$(class)-}}, lvl {{-player$(level)-}}")
556
  PRINT FSTRING("Row {{-row$-}}: [{{-grid$(row$, 0)-}}{{-grid$(row$, 1)-}}]")
557
  PRINT FSTRING("Pi is roughly {{-PI#-}}")
558
  END
559
  ```
560
+
561
  Output:
562
  ```
563
  Krisu the Bass, lvl 99
564
  Row 1: [.X]
565
  Pi is roughly 3.14
566
  ```
567
+
568
  ---
569
+
570
  ## Math Functions
571
+
572
  | Function | Description |
573
  |----------|-------------|
574
  | `ABS(n)` | Absolute value |
 
596
  | `ROUND(n)` | Rounds to nearest integer, half rounds away from zero (`0.5→1`, `-0.5→-1`) — NOT banker's rounding |
597
  | `SGN(n)` | Sign: -1, 0, or 1 |
598
  | `SQR(n)` | Square root |
599
+
600
  **Math constants:** `PI#`, `HPI#` (PI/2), `QPI#` (PI/4), `TAU#` (PI*2), `EULER#`
601
+
602
  ---
603
+
604
  ## Variable Functions
605
+
606
  | Function | Description |
607
  |----------|-------------|
608
  | `ISSET(name)` | `1` if the named variable (`$`) or constant (`#`) is declared, `0` otherwise. Argument is **not evaluated** — `ISSET(undef$)` safely returns `0`. |
609
+
610
  `ISSET` is the only language-introspection function and it has tight rules:
611
+
612
  - **Scalars only.** Variables (`$`) and constants (`#`). Arrays and array elements are stored separately — `ISSET(arr$)` and `ISSET(arr$(0))` always return `0`, never an error.
613
  - **Bare name only.** No expressions, no string literals, no numbers. These all error with "invalid parameter":
614
  ```basic
 
624
  PRINT ISSET(A#) ' 0
625
  ```
626
  - **`LET name$` (no value) still counts as set.** `LET` always registers the variable; the value just defaults to empty string for `$` and zero for numeric. `ISSET` reports declaration, not "has a meaningful value".
 
627
  Typical use is guarding optional setup:
628
+
629
  ```basic
630
  IF NOT ISSET(playerName$) THEN
631
  LET playerName$ = "Anonymous"
632
  END IF
633
  ```
634
+
635
  ---
636
+
637
  ## Graphics
638
+
639
  ```basic
640
  SCREEN 12 ' 640×480 VGA
641
  SCREEN 0, 800, 600 ' Custom size
 
643
  FULLSCREEN TRUE ' Borderless fullscreen (graphics only)
644
  FULLSCREEN FALSE ' Windowed
645
  ```
646
+
647
  | Mode | Resolution |
648
  |------|-----------|
649
  | 1 | 320×200 |
 
652
  | 9 | 640×350 |
653
  | 12 | 640×480 ← recommended |
654
  | 13 | 320×200 |
655
+
656
  ### Drawing Primitives
657
  ```basic
658
  PSET (x, y), color ' Pixel
 
665
  LET c$ = POINT(x, y) ' Read pixel color
666
  LET col$ = RGB(r, g, b) ' Create color (0–255 each)
667
  ```
668
+
669
  **Color values:** Every drawing primitive (`PSET`, `LINE`, `CIRCLE`, `PAINT`, `DRAWSTRING`, `LOADSHAPE`) accepts a `color` parameter that is either a palette index 0–15 or an `RGB(r, g, b)` value — mix freely. The `COLOR` text command is the exception: it accepts palette indices 0–15 only, so `COLOR RGB(...)` does **not** work.
670
+
671
  **Palette (0–15):** 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, 7=Lt Gray, 8=Dk Gray, 9=Lt Blue, 10=Lt Green, 11=Lt Cyan, 12=Lt Red, 13=Lt Magenta, 14=Yellow, 15=White
672
+
673
  > Do **not** hand-construct packed RGB integers (e.g. `16711680`). `RGB()` tags its return value internally so it can be told apart from a palette index; a raw integer lacks that tag and will be misread as a palette index. Always use `RGB(r, g, b)`.
674
+
675
  ### Screen Control
676
  ```basic
677
  SCREENLOCK ON ' Buffer drawing (start frame)
 
682
  ' Use CLS only with console, in graphics screen its slow
683
  ' With graphics screen, prefer LINE BF
684
  ```
685
+
686
  ### Shapes & Images
687
  ```basic
688
  ' Create shape
 
691
  LET RECT# = LOADSHAPE("RECTANGLE", w, h, color) ' or "CIRCLE", "TRIANGLE"
692
  LET IMG_PLAYER# = LOADIMAGE("player.png") ' PNG (alpha) or BMP
693
  LET IMG_REMOTE# = LOADIMAGE("https://example.com/a.png") ' Download + load
694
+
695
  ' Sprite sheet — sprites indexed 0-based
696
  DIM sprites$
697
  LOADSHEET sprites$, 128, 128, "sheet.png" ' tileW, tileH, file
698
  MOVESHAPE sprites$(0), x, y ' sprites$(0) = first sprite
699
+
700
  ' Transform
701
  ' NOTE: anchor point differs by type — LOADSHAPE primitives (RECTANGLE/CIRCLE/TRIANGLE)
702
  ' are center-anchored; LOADIMAGE images are top-left-anchored.
 
707
  SHOWSHAPE RECT# / HIDESHAPE RECT# ' Toggle visibility
708
  REMOVESHAPE RECT# ' Free memory (always clean up)
709
  ```
710
+
711
+
712
  ---
713
+
714
  ### Text Rendering (SDL2_ttf.dll required)
715
  #### DRAWSTRING & LOADFONT
716
+
717
+
718
  ```basic
719
  ' Default font: Arial, 16px
720
  DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
721
+
722
  ' Load alternative font — becomes the new default
723
  LOADFONT "comic.ttf", 24
724
  DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
725
+
726
  ' Reset to Arial, 16px
727
  LOADFONT
728
  ```
729
+
730
  `DRAWSTRING x, y` positions the top-left of the text. Requires `SDL2_ttf.dll` in the same directory as the interpreter. Prefer this over PRINT, which makes graphic screen easily blinking. Default font size is **16px** — not 20px.
731
+
732
  ---
733
+
734
  ## Sound
735
+
736
  ```basic
737
  ' LOADSOUND returns a stable integer handle — SDL2 manages the resource.
738
  ' The handle never changes; store it in a constant to protect it from accidental reassignment.
 
743
  SOUNDSTOP(SND_JUMP#) ' Stop specific sound
744
  SOUNDSTOPALL ' Stop all sounds
745
  ```
746
+
747
  Load all sounds at startup. Call `SOUNDSTOPALL` before `END`.
748
+
749
  ---
750
+
751
  ## File I/O
752
+
753
  ```basic
754
  LET data$ = FileRead("file.txt") ' Read as string
755
  DIM cfg$ : LET cfg$ = FileRead("settings.txt") ' Read as key=value array
 
760
  DIM files$
761
  LET n$ = FILELIST(files$, "levels", "*.txt") ' File names into files$(0..n-1), returns n
762
  ```
763
+
764
  **FILELIST:** `FILELIST(arr$, folder$ [, pattern$])` lists files only (no folders, not recursive), names only (no paths), sorted alphabetically ignoring case. The array is cleared first. `pattern$` supports `*` and `?`, default all files. Hidden/system files are skipped. Missing folder → returns `0`. To open a listed file, prepend the folder: `FILEREAD("levels/" + files$(i$))`. Added after v1.4c.
765
+
766
  **key=value parsing:** When `FileRead` assigns to a `DIM`'d array, lines `key=value` become `arr$("key")`. Lines starting with `#` are comments. Perfect for `.env` files.
767
+
768
  ```basic
769
  DIM env$
770
  LET env$ = FileRead(".env")
771
  LET API_KEY# = env$("OPENAI_API_KEY")
772
  ```
773
+
774
  **Paths:** Use `/` or `\\` — never single `\` (it's an escape char). Relative paths are from `PRG_ROOT#`.
775
  `PRG_ROOT#` already ends with a directory separator — concatenate directly, don't add your own `/`:
776
  ```basic
777
  LET path$ = PRG_ROOT# + "data.txt"
778
  ```
779
  **FileWrite with array** saves in key=value format (round-trips with FileRead).
780
+
781
  ---
782
+
783
  ## Network
784
+
785
  ```basic
786
  LET res$ = HTTPGET("https://api.example.com/data")
787
  LET res$ = HTTPPOST("https://api.example.com/submit", "{""key"":""val""}")
788
+
789
  ' With headers (optional)
790
  DIM headers$
791
  headers$("Authorization") = "Bearer mytoken"
792
  headers$("Content-Type") = "application/json"
793
  LET res$ = HTTPGET("https://api.example.com/data", headers$)
794
  LET res$ = HTTPPOST("https://api.example.com/data", body$, headers$)
795
+
796
  ' With timeout in seconds (optional, comes AFTER headers; default 30, 0 = no limit)
797
  LET res$ = HTTPGET("https://api.example.com/data", headers$, 60)
798
  LET res$ = HTTPPOST("http://localhost:11434/v1/chat/completions", body$, headers$, 120)
799
  ```
800
+
801
  ### Local HTTP server (LISTEN)
802
+
803
  BazzBasic can also receive requests as a local-only HTTP server, typically used as glue between a static HTML page and a BazzBasic script on the same machine.
804
+
805
  ```basic
806
  STARTLISTEN 8080 ' bind 127.0.0.1:8080, no admin needed
807
  STARTLISTEN 8080, 5000 ' optional timeout in ms
 
809
  SENDRESPONSE "{""status"":""ok""}" ' must be called or browser hangs
810
  STOPLISTEN
811
  ```
812
+
813
  Important rules:
814
+
815
  - **Always pair `GETREQUEST()` with `SENDRESPONSE`.** The browser is waiting on the response. Forgetting `SENDRESPONSE` makes the page hang.
816
  - **Bound to `127.0.0.1` only.** This is local glue, not a real web server. Do not generate code that tries to expose this on the LAN or internet.
817
  - **Body or query string, not full request.** `GETREQUEST()` returns just the POST body (or the GET query string without `?`). Headers, method, and URL path are NOT exposed in this version. If you need structured data, parse the body with `ASARRAY(body$)`.
 
819
  - **CORS is automatic.** Every response carries `Access-Control-Allow-Origin: *`. No need to set it manually.
820
  - **One listener at a time.** Calling `STARTLISTEN` while one is already active is an error. Call `STOPLISTEN` first.
821
  - **Always 200 OK, always `text/plain`.** Custom status codes and content types are not supported in this version. To return JSON, just put JSON text in the body — browser-side `response.json()` still works.
 
822
  Typical receive-and-process pattern:
823
+
824
  ```basic
825
  STARTLISTEN 8080
826
  PRINT "Waiting for browser..."
827
+
828
  LET json$ = GETREQUEST()
829
  DIM data$
830
  LET data$ = ASARRAY(json$)
831
+
832
  PRINT "Got name: " + data$("name")
833
+
834
  SENDRESPONSE "{""status"":""ok""}"
835
  STOPLISTEN
836
  END
837
  ```
838
+
839
  ---
840
+
841
  ## Arrays & JSON
842
+
843
  Nested JSON maps to comma-separated keys: `data$("player,name")`, `data$("skills,0")`
844
+
845
  ```basic
846
  ' Array → JSON string
847
  LET json$ = ASJSON(arr$)
848
+
849
  ' JSON string → array (returns element count)
850
  DIM data$
851
  LET count$ = ASARRAY(data$, json$)
852
+
853
  ' Load/save JSON files
854
  LOADJSON arr$, "file.json"
855
  SAVEJSON arr$, "file.json"
856
  ```
857
+
858
  ---
859
+
860
  ## Fast Trigonometry
861
+
862
  ~20× faster than `SIN(RAD(x))`, 1-degree precision. Uses ~5.6 KB memory.
863
+
864
  ```basic
865
  FastTrig(TRUE) ' Enable lookup tables (must call first)
866
  LET x$ = FastCos(45) ' Degrees, auto-normalized 0–359
 
868
  LET r$ = FastRad(180) ' Deg→rad (no FastTrig needed)
869
  FastTrig(FALSE) ' Free memory
870
  ```
871
+
872
  Use for raycasting, sprite rotation, particle systems, any high-freq trig.
873
+
874
  ---
875
+
876
  ## Date & Time
877
+
878
  ```basic
879
  LET t$ = TIME() ' Current time, default format "HH:mm:ss" -> "15:21:22"
880
  LET t2$ = TIME("dd.MM.yyyy") ' .NET DateTime format string -> "04.09.2026"
881
  LET t3$ = TIME("dddd") ' -> "Friday"
882
+
883
  LET start$ = TICKS ' Milliseconds since program start
884
  ' ... later in a loop ...
885
  LET elapsed$ = TICKS - start$ ' Delta time — use for frame-independent movement
886
  ```
887
+
888
  `TICKS` is the standard way to do frame-independent (delta-time) movement in a game loop — prefer it over counting fixed `SLEEP` increments.
889
+
890
  ```basic
891
  ' ✅ Preferred: frame-independent movement
892
  LET lastTick$ = TICKS
 
896
  x$ = x$ + speed$ * delta$ / 16 ' normalize to ~60 FPS baseline
897
  GOSUB [sub:draw]
898
  WEND
899
+
900
  ' ❌ Avoid: fixed SLEEP without delta — speed varies with actual frame rate
901
  SLEEP 16
902
  x$ = x$ + speed$
903
  ```
904
+
905
  ---
906
+
907
  ## Command-Line Arguments
908
+
909
  ```basic
910
  ' bazzbasic.exe myprog.bas arg1 arg2
911
  PRINT ARGCOUNT ' number of args (2 in this example)
912
  PRINT ARGS(0) ' first arg → "arg1"
913
  PRINT ARGS(1) ' second arg → "arg2"
914
  ```
915
+
916
  `ARGCOUNT` and `ARGS(n)` are 0-based; ARGS does not include the interpreter or script name.
917
+
918
  ---
919
+
920
  ## Libraries & INCLUDE
921
+
922
  ```basic
923
  INCLUDE "helpers.bas" ' Insert source at this point
924
  INCLUDE "MathLib.bb" ' Load compiled library
925
+
926
  ' Compile library (functions only — no loose code)
927
  ' bazzbasic.exe -lib MathLib.bas → MathLib.bb
928
  ' Function names auto-prefixed: MATHLIB_functionname$
929
  PRINT FN MATHLIB_add$(5, 3)
930
  ```
931
+
932
  Library functions can read main-program constants (`#`). `.bb` files are version-locked.
933
+
934
  - **No extension fallback.** `INCLUDE "helpers"` does NOT try `helpers.bas` automatically — give the exact filename, extension included.
935
  - **Path resolution order:** relative to the *including file's own directory* first, then relative to the program's base path.
936
  - **Circular includes are detected** and halt with `Circular INCLUDE detected: <file>`.
 
937
  ---
938
+
939
  ## Passing Arrays to Functions
940
+
941
  Arrays cannot be passed directly to `DEF FN` functions, but a clean workaround exists using JSON serialization. Convert the array to a JSON string with `ASJSON`, pass the string as a parameter, then deserialize inside the function with `ASARRAY`. This is the accepted pattern in BazzBasic v1.2+.
942
+
943
  ```basic
944
  DEF FN ProcessPlayer$(data$)
945
  DIM arr$
946
  LET count$ = ASARRAY(arr$, data$)
947
  RETURN arr$("name") + " score:" + arr$("score")
948
  END DEF
949
+
950
  [inits]
951
  DIM player$
952
  player$("name") = "Alice"
953
  player$("score") = 9999
954
  player$("address,city") = "New York"
955
+
956
  [main]
957
  LET json$ = ASJSON(player$)
958
  PRINT FN ProcessPlayer$(json$)
959
  END
960
  ```
961
+
962
  **Notes:**
963
  - The function receives a full independent copy — changes inside do not affect the original array
964
  - Nested keys work normally: `arr$("address,city")` etc.
965
  - Overhead is similar to copying an array manually; acceptable for most use cases
 
966
  ---
967
+
968
  ## Program Structure
969
+
970
  ```basic
971
  ' ---- 1. FUNCTIONS (or INCLUDE "functions.bas/bb") ----
972
  DEF FN Clamp$(v$, lo$, hi$)
 
974
  IF v$ > hi$ THEN RETURN hi$
975
  RETURN v$
976
  END DEF
977
+
978
  ' ---- 2. INIT (declare ALL constants & variables here, not inside loops) ----
979
  ' Performance: variables declared outside loops avoid repeated existence checks.
980
  [inits]
981
  LET SCREEN_W# = 640
982
  LET SCREEN_H# = 480
983
  LET MAX_SPEED# = 5
984
+
985
  SCREEN 0, SCREEN_W#, SCREEN_H#, "My Game"
986
+
987
  LET x$ = 320
988
  LET y$ = 240
989
  LET running$ = TRUE
990
+
991
  ' ---- 3. MAIN LOOP ----
992
  [main]
993
  WHILE running$
 
998
  WEND
999
  SOUNDSTOPALL
1000
  END ' place at the end of main program so BazzBasic wont fall to subs in runtime
1001
+
1002
  ' ---- 4. SUBROUTINES (or INCLUDE "subs.bas") ----
1003
  [sub:update]
1004
  IF KEYDOWN(KEY_LEFT#) THEN x$ = x$ - MAX_SPEED#
1005
  IF KEYDOWN(KEY_RIGHT#) THEN x$ = x$ + MAX_SPEED#
1006
  RETURN
1007
+
1008
  [sub:draw]
1009
  SCREENLOCK ON
1010
  LINE (0,0)-(SCREEN_W#, SCREEN_H#), 0, BF
 
1012
  SCREENLOCK OFF
1013
  RETURN
1014
  ```
1015
+
1016
  **Key conventions:**
1017
  - Variables: `camelCase$` | Constants: `UPPER_SNAKE_CASE#` | Functions: `PascalCase$`
1018
  - Labels: `[gameLoop]` for jump targets, `[sub:name]` for subroutines
1019
  - Image/sound/shape IDs are stable integer handles — **always** store as constants: `LET MY_IMG# = LOADIMAGE("x.png")` — never use `$` variables for these
1020
  - Group many IDs → use arrays: `DIM sprites$` / `sprites$("player") = LOADIMAGE(...)` — but prefer named constants when count is small
 
1021
  ---
1022
+
1023
  ## Performance Tips
1024
+
1025
  - `LINE (0,0)-(W,H), 0, BF` to clear — much faster than `CLS`
1026
  - Always wrap draw code in `SCREENLOCK ON` / `SCREENLOCK OFF`
1027
  - Store `RGB()` results in constants/variables — don't call RGB in hot loops
1028
  - Declare all variables in `[inits]`, not inside loops or subroutines
1029
  - Use `FastTrig` for any loop calling trig hundreds of times per frame
1030
  - `SLEEP 16` in game loop → ~60 FPS
 
1031
  ---
1032
+
1033
  ## Known Limitations
1034
+
1035
  Things to be aware of — most are deliberate design decisions, a few are practical constraints.
1036
+
1037
  - **No line numbers.** Never supported, never will be.
1038
  - **Platform: Windows x64 only.** Linux and macOS are not supported. Browser/Android are not feasible — the runtime depends on SDL2 via P/Invoke.
1039
  - **Arrays cannot be passed to functions.** Use the `ASJSON` / `ASARRAY` round-trip pattern. The function receives an independent copy.
 
1044
  - **No integer-division operator.** Use `INT(a / b)`, `FLOOR(a / b)`, or `CINT(a / b)` depending on the rounding behavior you need.
1045
  - **Compiled `.bb` libraries are version-locked** to the BazzBasic build that produced them. Recompile after upgrading the interpreter.
1046
  - **`DEF FN` definitions must precede their first call** in source order. Forward references don't resolve.
 
1047
  ---
1048
+
1049
  ## IDE Features
1050
+
1051
  ### Menus
1052
  | Menu | Items |
1053
  |------|-------|
 
1057
  | **View** | Light Mode, Dark Mode (experimental; choice saved to `%AppData%\BazzBasic\ide.json`) |
1058
  | **Run** | Run Program (F5), Compile as Exe, Compile as Library (.bb) |
1059
  | **Help** | About, Online Manual, Beginner's Guide, Rosetta Code, Check for Updates |
1060
+
1061
  **Version note:** In v1.4c and older, Find and Replace are under **Edit**, there is no Undo/Redo/Cut/Copy/Paste menu (the shortcuts still work in the editor), there is no View menu or Dark Mode, and Help has no Online Manual or Rosetta Code links. If a user says Find is under Edit, they have an older build.
1062
+
1063
  ### New File Template
1064
  When the IDE opens with no file (or a new file), this template is auto-inserted:
1065
  ```basic
1066
  ' BazzBasic version {ver_num}
1067
  ' https://ekbass.github.io/BazzBasic/
1068
  ```
1069
+
1070
  ### Beginner's Guide
1071
  - **IDE:** Menu → **Help** → **Beginner's Guide** — opens `https://github.com/EkBass/BazzBasic-Beginners-Guide/releases` in default browser
1072
  - **CLI:** `bazzbasic.exe -guide` or `bazzbasic.exe -help` — prints URL to terminal
 
1073
  ### Online Manual and Rosetta Code
1074
  - **IDE:** Menu → **Help** → **Online Manual** — opens `https://ekbass.github.io/BazzBasic/manual/#/` in default browser
1075
  - **IDE:** Menu → **Help** → **Rosetta Code** — opens `https://rosettacode.org/wiki/Category:BazzBasic` in default browser
1076
  - No CLI equivalents
 
1077
  ### Check for Updates
1078
  - **IDE:** Menu → **Help** → **Check for Updates...** — IDE reports if a newer version is available
1079
  - **CLI:** `bazzbasic.exe -checkupdates`
 
1080
  ### Compile via IDE
1081
  - **Menu → Run → Compile as Exe** — compiles open file to standalone `.exe` (auto-saves first)
1082
  - **Menu → Run → Compile as Library (.bb)** — compiles open file as reusable `.bb` library (auto-saves first)