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

Update BazzBasic-AI-guide.md

Browse files
Files changed (1) hide show
  1. BazzBasic-AI-guide.md +244 -227
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
- ## ⚠\u{fe0f} 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,135 +59,137 @@ 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
  ## 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,15 +199,15 @@ x$ /= 4 ' divide
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,40 +215,41 @@ Main-code variables ($) and arrays are NOT accessible inside DEF FN.
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,17 +259,17 @@ NEXT i$
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,34 +279,34 @@ ELSEIF score$ >= 80 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,9 +314,9 @@ 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,31 +331,32 @@ Whitespace is trimmed. Everything between "[" and "]" is treated as the label na
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,13 +371,13 @@ layout: never bind controls to `ASC("+")` or `ASC("-")`. Use letters or
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,7 +385,7 @@ When a user reports a pad not being detected, wrong button mapping or odd axis v
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,14 +398,15 @@ When a user reports a pad not being detected, wrong button mapping or odd axis v
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,12 +414,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,10 +437,11 @@ 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
  ## String Functions
438
-
439
  | Function | Description |
440
  |----------|-------------|
441
  | `ASC(s$)` | ASCII code of first char |
@@ -458,30 +464,30 @@ FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
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,40 +497,42 @@ The triple-character markers `{{-` and `-}}` are deliberately unusual so they wi
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,43 +540,43 @@ 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,19 +604,19 @@ Pi is roughly 3.14
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,18 +632,19 @@ Pi is roughly 3.14
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,7 +652,7 @@ SCREEN 0, 1024, 768, "My Game" ' Custom size + title
643
  FULLSCREEN TRUE ' Borderless fullscreen (graphics only)
644
  FULLSCREEN FALSE ' Windowed
645
  ```
646
-
647
  | Mode | Resolution |
648
  |------|-----------|
649
  | 1 | 320×200 |
@@ -652,7 +661,7 @@ FULLSCREEN FALSE ' Windowed
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,13 +674,13 @@ PAINT (x, y), fillColor, borderColor ' Flood fill
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,7 +691,7 @@ CLS ' Clear screen
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,12 +700,12 @@ CLS ' Clear screen
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,32 +716,32 @@ DRAWSHAPE RECT# ' Render to buffer
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,13 +752,13 @@ SOUNDREPEAT(SND_JUMP#) ' Loop continuously
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,48 +769,48 @@ FILEDELETE "temp.dat" ' Delete file
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,9 +818,9 @@ LET body$ = GETREQUEST() ' POST/PUT/PATCH body, or GET query strin
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,48 +828,49 @@ Important rules:
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,25 +878,25 @@ LET y$ = FastSin(90)
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,77 +906,79 @@ WHILE running$
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,20 +986,20 @@ 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,13 +1010,13 @@ END DEF
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,28 +1024,30 @@ RETURN
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,10 +1058,11 @@ Things to be aware of — most are deliberate design decisions, a few are practi
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,27 +1072,29 @@ Things to be aware of — most are deliberate design decisions, a few are practi
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)
1083
-
 
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
+ ## ⚠️ 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
+
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
  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
  - **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
  | `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
  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
  **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
  | `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
  `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
+
377
  > **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.
378
+
379
  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.
380
+
381
  | Function | Returns | Notes |
382
  |----------|---------|-------|
383
  | `GAMEPADS()` | Number of connected pads | Parentheses optional |
 
385
  | `PADAXIS(pad, axis)` | Number | Sticks -1.0…1.0, triggers 0.0…1.0, built-in dead zone |
386
  | `PADNAME(pad)` | String | e.g. `"PS4 Controller"`, `""` if not connected |
387
  | `PADRUMBLE pad, strength, ms` | — (statement) | strength 0.0…1.0, non-blocking, parentheses optional |
388
+
389
  - Pad index is **0-based**, max 8 pads. A pad keeps its number while connected (stable slots, not re-packed on disconnect).
390
  - **No `SCREEN` needed** — unlike `KEYDOWN`/mouse, gamepad functions work in console programs too.
391
  - **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.
 
398
  - Stick as digital direction: `IF PADAXIS(0, PAD_LX#) < -0.5 THEN ...`
399
  - Typical game input = pad OR keyboard: `IF PADBUTTON(0, PAD_LEFT#) OR KEYDOWN(KEY_LEFT#) THEN dx$ = -1`
400
  - Many third-party pads identify as PS4/Xbox controllers — normal, mapping still correct.
401
+
402
  ### Console Read
403
  Returns numeric or character depending on type parameter
404
  `GETCONSOLE(row, col, type)` — type: 0=char (ASCII), 1=fg color, 2=bg color
405
+
406
  ---
407
+
408
  ## User-Defined Functions
409
+
410
  ```basic
411
  ' Define BEFORE calling. Name must end with $.
412
  DEF FN Clamp$(val$, lo$, hi$)
 
414
  IF val$ > hi$ THEN RETURN hi$
415
  RETURN val$
416
  END DEF
417
+
418
  PRINT FN Clamp$(5, 1, 10) ' ✓ OK — return value used
419
  LET v$ = FN Clamp$(15, 0, 10) ' ✓ OK
420
  FN Clamp$(5, 1, 10) ' ✗ ERROR — return value unused
421
  ```
422
+
423
  - 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()`
424
  - **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:
425
  ```basic
 
437
  - 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.
438
  - Arrays as parameters not allowed. Use ASJSON to make array as JSON-string to pass it.
439
  - Use `INCLUDE` to load functions from separate files if many
440
+
441
  ---
442
+
443
  ## String Functions
444
+
445
  | Function | Description |
446
  |----------|-------------|
447
  | `ASC(s$)` | ASCII code of first char |
 
464
  | `VAL(s$)` | String to number |
465
  | `SHA256(s$)` | SHA256 hash (64-char hex) |
466
  | `BASE64ENCODE(s$)` / `BASE64DECODE(s$)` | Base64 encode/decode |
467
+
468
  > `SRAND(n)` with `n < 0` throws an unhandled arithmetic error (`n = 0` is safe, returns `""`). Never pass an unvalidated or negative length.
469
  > ```basic
470
  > PRINT SRAND(-1)
471
  > ' Error: Arithmetic operation resulted in an overflow.
472
  > ```
473
+
474
  ---
475
+
476
  ## FSTRING — String Interpolation
477
+
478
  `FSTRING(template$)` substitutes `{{-name-}}` placeholders inside a template string with the value of variables, constants, or array elements. Preferred over long `+` concatenation chains.
479
+
480
  ```basic
481
  LET name$ = "Krisu"
482
  LET LEVEL# = 5
483
  PRINT FSTRING("Hello {{-name$-}}, level {{-LEVEL#-}}")
484
  ' Output: Hello Krisu, level 5
485
  ```
486
+
487
  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.
488
+
489
  ### Placeholder forms
490
+
491
  | Form | Resolves to |
492
  |------|-------------|
493
  | `{{-var$-}}` | Value of variable `var$` |
 
497
  | `{{-arr$(KEY#)-}}` | Array element at index taken from constant `KEY#` |
498
  | `{{-arr$(name)-}}` | Array element at literal string key `"name"` (no quotes inside FSTRING) |
499
  | `{{-arr$(0, i$)-}}` | Multidimensional element, mixed literal and variable indices |
500
+
501
  ### Index resolution rule (array access)
502
+
503
  For each comma-separated index, FSTRING looks at the last character:
504
+
505
  1. Ends with `$` or `#` → variable / constant lookup. Halts if undefined.
506
  2. Parses as a number (`0`, `1.5`, `-3`) → numeric index. `arr$(01)` and `arr$(1.0)` both resolve to key `1`.
507
  3. Otherwise → literal string key. This is what lets `{{-player$(name)-}}` read what was stored with `player$("name") = ...`.
508
+
509
  ### Notes
510
+
511
  - Whitespace inside placeholders is trimmed: `{{- name$ -}}` ≡ `{{-name$-}}`.
512
  - 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".)
513
  - Numbers auto-stringify — no `STR()` needed for numeric variables, constants, or array elements.
514
  - FSTRING returns a value; you must use it (`LET`, `PRINT`, pass to function). Calling it as a bare statement is an error.
515
  - Errors halt the program with a line-numbered message: undefined variable, missing closing `-}}`, empty placeholder `{{--}}`, malformed array access, uninitialized array element.
516
+
517
  ### Not supported (intentional)
518
+
519
  No arithmetic, function calls, nested lookups, or quoted string literals inside placeholders. Pre-compute into a variable and reference that:
520
+
521
  ```basic
522
  ' ❌ WRONG
523
  PRINT FSTRING("Total: {{-a$ + 5-}}")
524
  PRINT FSTRING("Name: {{-UCASE(name$)-}}")
525
  PRINT FSTRING("{{-arr$(arr2$(0))-}}")
526
+
527
  ' ✓ RIGHT
528
  LET total$ = a$ + 5
529
  LET upper$ = UCASE(name$)
530
  LET k$ = arr2$(0)
531
  PRINT FSTRING("Total: {{-total$-}}, Name: {{-upper$-}}, Item: {{-arr$(k$)-}}")
532
  ```
533
+
534
  ### Common AI mistakes with FSTRING
535
+
536
  ```basic
537
  ' ❌ WRONG ' ✓ CORRECT
538
  FSTRING("Hi {{name$}}") FSTRING("Hi {{-name$-}}")
 
540
  FSTRING("Hi {{-name-}}") ' array key FSTRING("Hi {{-name$-}}")
541
  FSTRING("Hi {{-name$-}}") ' as stmt LET s$ = FSTRING("Hi {{-name$-}}")
542
  ```
543
+
544
  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.
545
+
546
  ### Full working example
547
+
548
  ```basic
549
  DIM player$
550
  player$("name") = "Krisu"
551
  player$("class") = "Bass"
552
  player$("level") = 99
553
+
554
  DIM grid$
555
  grid$(0, 0) = "X"
556
  grid$(0, 1) = "O"
557
  grid$(1, 0) = "."
558
  grid$(1, 1) = "X"
559
+
560
  LET row$ = 1
561
  LET PI# = 3.14
562
+
563
  PRINT FSTRING("{{-player$(name)-}} the {{-player$(class)-}}, lvl {{-player$(level)-}}")
564
  PRINT FSTRING("Row {{-row$-}}: [{{-grid$(row$, 0)-}}{{-grid$(row$, 1)-}}]")
565
  PRINT FSTRING("Pi is roughly {{-PI#-}}")
566
  END
567
  ```
568
+
569
  Output:
570
  ```
571
  Krisu the Bass, lvl 99
572
  Row 1: [.X]
573
  Pi is roughly 3.14
574
  ```
575
+
576
  ---
577
+
578
  ## Math Functions
579
+
580
  | Function | Description |
581
  |----------|-------------|
582
  | `ABS(n)` | Absolute value |
 
604
  | `ROUND(n)` | Rounds to nearest integer, half rounds away from zero (`0.5→1`, `-0.5→-1`) — NOT banker's rounding |
605
  | `SGN(n)` | Sign: -1, 0, or 1 |
606
  | `SQR(n)` | Square root |
607
+
608
  **Math constants:** `PI#`, `HPI#` (PI/2), `QPI#` (PI/4), `TAU#` (PI*2), `EULER#`
609
+
610
  ---
611
+
612
  ## Variable Functions
613
+
614
  | Function | Description |
615
  |----------|-------------|
616
  | `ISSET(name)` | `1` if the named variable (`$`) or constant (`#`) is declared, `0` otherwise. Argument is **not evaluated** — `ISSET(undef$)` safely returns `0`. |
617
+
618
  `ISSET` is the only language-introspection function and it has tight rules:
619
+
620
  - **Scalars only.** Variables (`$`) and constants (`#`). Arrays and array elements are stored separately — `ISSET(arr$)` and `ISSET(arr$(0))` always return `0`, never an error.
621
  - **Bare name only.** No expressions, no string literals, no numbers. These all error with "invalid parameter":
622
  ```basic
 
632
  PRINT ISSET(A#) ' 0
633
  ```
634
  - **`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".
635
+
636
  Typical use is guarding optional setup:
637
+
638
  ```basic
639
  IF NOT ISSET(playerName$) THEN
640
  LET playerName$ = "Anonymous"
641
  END IF
642
  ```
643
+
644
  ---
645
+
646
  ## Graphics
647
+
648
  ```basic
649
  SCREEN 12 ' 640×480 VGA
650
  SCREEN 0, 800, 600 ' Custom size
 
652
  FULLSCREEN TRUE ' Borderless fullscreen (graphics only)
653
  FULLSCREEN FALSE ' Windowed
654
  ```
655
+
656
  | Mode | Resolution |
657
  |------|-----------|
658
  | 1 | 320×200 |
 
661
  | 9 | 640×350 |
662
  | 12 | 640×480 ← recommended |
663
  | 13 | 320×200 |
664
+
665
  ### Drawing Primitives
666
  ```basic
667
  PSET (x, y), color ' Pixel
 
674
  LET c$ = POINT(x, y) ' Read pixel color
675
  LET col$ = RGB(r, g, b) ' Create color (0–255 each)
676
  ```
677
+
678
  **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.
679
+
680
  **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
681
+
682
  > 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)`.
683
+
684
  ### Screen Control
685
  ```basic
686
  SCREENLOCK ON ' Buffer drawing (start frame)
 
691
  ' Use CLS only with console, in graphics screen its slow
692
  ' With graphics screen, prefer LINE BF
693
  ```
694
+
695
  ### Shapes & Images
696
  ```basic
697
  ' Create shape
 
700
  LET RECT# = LOADSHAPE("RECTANGLE", w, h, color) ' or "CIRCLE", "TRIANGLE"
701
  LET IMG_PLAYER# = LOADIMAGE("player.png") ' PNG (alpha) or BMP
702
  LET IMG_REMOTE# = LOADIMAGE("https://example.com/a.png") ' Download + load
703
+
704
  ' Sprite sheet — sprites indexed 0-based
705
  DIM sprites$
706
  LOADSHEET sprites$, 128, 128, "sheet.png" ' tileW, tileH, file
707
  MOVESHAPE sprites$(0), x, y ' sprites$(0) = first sprite
708
+
709
  ' Transform
710
  ' NOTE: anchor point differs by type — LOADSHAPE primitives (RECTANGLE/CIRCLE/TRIANGLE)
711
  ' are center-anchored; LOADIMAGE images are top-left-anchored.
 
716
  SHOWSHAPE RECT# / HIDESHAPE RECT# ' Toggle visibility
717
  REMOVESHAPE RECT# ' Free memory (always clean up)
718
  ```
719
+
720
+
721
  ---
722
+
723
  ### Text Rendering (SDL2_ttf.dll required)
724
  #### DRAWSTRING & LOADFONT
725
+
726
+
727
  ```basic
728
  ' Default font: Arial, 16px
729
  DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
730
+
731
  ' Load alternative font — becomes the new default
732
  LOADFONT "comic.ttf", 24
733
  DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)
734
+
735
  ' Reset to Arial, 16px
736
  LOADFONT
737
  ```
738
+
739
  `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.
740
+
741
  ---
742
+
743
  ## Sound
744
+
745
  ```basic
746
  ' LOADSOUND returns a stable integer handle — SDL2 manages the resource.
747
  ' The handle never changes; store it in a constant to protect it from accidental reassignment.
 
752
  SOUNDSTOP(SND_JUMP#) ' Stop specific sound
753
  SOUNDSTOPALL ' Stop all sounds
754
  ```
755
+
756
  Load all sounds at startup. Call `SOUNDSTOPALL` before `END`.
757
+
758
  ---
759
+
760
  ## File I/O
761
+
762
  ```basic
763
  LET data$ = FileRead("file.txt") ' Read as string
764
  DIM cfg$ : LET cfg$ = FileRead("settings.txt") ' Read as key=value array
 
769
  DIM files$
770
  LET n$ = FILELIST(files$, "levels", "*.txt") ' File names into files$(0..n-1), returns n
771
  ```
772
+
773
  **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.
774
+
775
  **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.
776
+
777
  ```basic
778
  DIM env$
779
  LET env$ = FileRead(".env")
780
  LET API_KEY# = env$("OPENAI_API_KEY")
781
  ```
782
+
783
  **Paths:** Use `/` or `\\` — never single `\` (it's an escape char). Relative paths are from `PRG_ROOT#`.
784
  `PRG_ROOT#` already ends with a directory separator — concatenate directly, don't add your own `/`:
785
  ```basic
786
  LET path$ = PRG_ROOT# + "data.txt"
787
  ```
788
  **FileWrite with array** saves in key=value format (round-trips with FileRead).
789
+
790
  ---
791
+
792
  ## Network
793
+
794
  ```basic
795
  LET res$ = HTTPGET("https://api.example.com/data")
796
  LET res$ = HTTPPOST("https://api.example.com/submit", "{""key"":""val""}")
797
+
798
  ' With headers (optional)
799
  DIM headers$
800
  headers$("Authorization") = "Bearer mytoken"
801
  headers$("Content-Type") = "application/json"
802
  LET res$ = HTTPGET("https://api.example.com/data", headers$)
803
  LET res$ = HTTPPOST("https://api.example.com/data", body$, headers$)
804
+
805
  ' With timeout in seconds (optional, comes AFTER headers; default 30, 0 = no limit)
806
  LET res$ = HTTPGET("https://api.example.com/data", headers$, 60)
807
  LET res$ = HTTPPOST("http://localhost:11434/v1/chat/completions", body$, headers$, 120)
808
  ```
809
+
810
  ### Local HTTP server (LISTEN)
811
+
812
  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.
813
+
814
  ```basic
815
  STARTLISTEN 8080 ' bind 127.0.0.1:8080, no admin needed
816
  STARTLISTEN 8080, 5000 ' optional timeout in ms
 
818
  SENDRESPONSE "{""status"":""ok""}" ' must be called or browser hangs
819
  STOPLISTEN
820
  ```
821
+
822
  Important rules:
823
+
824
  - **Always pair `GETREQUEST()` with `SENDRESPONSE`.** The browser is waiting on the response. Forgetting `SENDRESPONSE` makes the page hang.
825
  - **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.
826
  - **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$)`.
 
828
  - **CORS is automatic.** Every response carries `Access-Control-Allow-Origin: *`. No need to set it manually.
829
  - **One listener at a time.** Calling `STARTLISTEN` while one is already active is an error. Call `STOPLISTEN` first.
830
  - **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.
831
+
832
  Typical receive-and-process pattern:
833
+
834
  ```basic
835
  STARTLISTEN 8080
836
  PRINT "Waiting for browser..."
837
+
838
  LET json$ = GETREQUEST()
839
  DIM data$
840
  LET data$ = ASARRAY(json$)
841
+
842
  PRINT "Got name: " + data$("name")
843
+
844
  SENDRESPONSE "{""status"":""ok""}"
845
  STOPLISTEN
846
  END
847
  ```
848
+
849
  ---
850
+
851
  ## Arrays & JSON
852
+
853
  Nested JSON maps to comma-separated keys: `data$("player,name")`, `data$("skills,0")`
854
+
855
  ```basic
856
  ' Array → JSON string
857
  LET json$ = ASJSON(arr$)
858
+
859
  ' JSON string → array (returns element count)
860
  DIM data$
861
  LET count$ = ASARRAY(data$, json$)
862
+
863
  ' Load/save JSON files
864
  LOADJSON arr$, "file.json"
865
  SAVEJSON arr$, "file.json"
866
  ```
867
+
868
  ---
869
+
870
  ## Fast Trigonometry
871
+
872
  ~20× faster than `SIN(RAD(x))`, 1-degree precision. Uses ~5.6 KB memory.
873
+
874
  ```basic
875
  FastTrig(TRUE) ' Enable lookup tables (must call first)
876
  LET x$ = FastCos(45) ' Degrees, auto-normalized 0–359
 
878
  LET r$ = FastRad(180) ' Deg→rad (no FastTrig needed)
879
  FastTrig(FALSE) ' Free memory
880
  ```
881
+
882
  Use for raycasting, sprite rotation, particle systems, any high-freq trig.
883
+
884
  ---
885
+
886
  ## Date & Time
887
+
888
  ```basic
889
  LET t$ = TIME() ' Current time, default format "HH:mm:ss" -> "15:21:22"
890
  LET t2$ = TIME("dd.MM.yyyy") ' .NET DateTime format string -> "04.09.2026"
891
  LET t3$ = TIME("dddd") ' -> "Friday"
892
+
893
  LET start$ = TICKS ' Milliseconds since program start
894
  ' ... later in a loop ...
895
  LET elapsed$ = TICKS - start$ ' Delta time — use for frame-independent movement
896
  ```
897
+
898
  `TICKS` is the standard way to do frame-independent (delta-time) movement in a game loop — prefer it over counting fixed `SLEEP` increments.
899
+
900
  ```basic
901
  ' ✅ Preferred: frame-independent movement
902
  LET lastTick$ = TICKS
 
906
  x$ = x$ + speed$ * delta$ / 16 ' normalize to ~60 FPS baseline
907
  GOSUB [sub:draw]
908
  WEND
909
+
910
  ' ❌ Avoid: fixed SLEEP without delta — speed varies with actual frame rate
911
  SLEEP 16
912
  x$ = x$ + speed$
913
  ```
914
+
915
  ---
916
+
917
  ## Command-Line Arguments
918
+
919
  ```basic
920
  ' bazzbasic.exe myprog.bas arg1 arg2
921
  PRINT ARGCOUNT ' number of args (2 in this example)
922
  PRINT ARGS(0) ' first arg → "arg1"
923
  PRINT ARGS(1) ' second arg → "arg2"
924
  ```
925
+
926
  `ARGCOUNT` and `ARGS(n)` are 0-based; ARGS does not include the interpreter or script name.
927
+
928
  ---
929
+
930
  ## Libraries & INCLUDE
931
+
932
  ```basic
933
  INCLUDE "helpers.bas" ' Insert source at this point
934
  INCLUDE "MathLib.bb" ' Load compiled library
935
+
936
  ' Compile library (functions only — no loose code)
937
  ' bazzbasic.exe -lib MathLib.bas → MathLib.bb
938
  ' Function names auto-prefixed: MATHLIB_functionname$
939
  PRINT FN MATHLIB_add$(5, 3)
940
  ```
941
+
942
  Library functions can read main-program constants (`#`). `.bb` files are version-locked.
943
+
944
  - **No extension fallback.** `INCLUDE "helpers"` does NOT try `helpers.bas` automatically — give the exact filename, extension included.
945
  - **Path resolution order:** relative to the *including file's own directory* first, then relative to the program's base path.
946
  - **Circular includes are detected** and halt with `Circular INCLUDE detected: <file>`.
947
+
948
  ---
949
+
950
  ## Passing Arrays to Functions
951
+
952
  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+.
953
+
954
  ```basic
955
  DEF FN ProcessPlayer$(data$)
956
  DIM arr$
957
  LET count$ = ASARRAY(arr$, data$)
958
  RETURN arr$("name") + " score:" + arr$("score")
959
  END DEF
960
+
961
  [inits]
962
  DIM player$
963
  player$("name") = "Alice"
964
  player$("score") = 9999
965
  player$("address,city") = "New York"
966
+
967
  [main]
968
  LET json$ = ASJSON(player$)
969
  PRINT FN ProcessPlayer$(json$)
970
  END
971
  ```
972
+
973
  **Notes:**
974
  - The function receives a full independent copy — changes inside do not affect the original array
975
  - Nested keys work normally: `arr$("address,city")` etc.
976
  - Overhead is similar to copying an array manually; acceptable for most use cases
977
+
978
  ---
979
+
980
  ## Program Structure
981
+
982
  ```basic
983
  ' ---- 1. FUNCTIONS (or INCLUDE "functions.bas/bb") ----
984
  DEF FN Clamp$(v$, lo$, hi$)
 
986
  IF v$ > hi$ THEN RETURN hi$
987
  RETURN v$
988
  END DEF
989
+
990
  ' ---- 2. INIT (declare ALL constants & variables here, not inside loops) ----
991
  ' Performance: variables declared outside loops avoid repeated existence checks.
992
  [inits]
993
  LET SCREEN_W# = 640
994
  LET SCREEN_H# = 480
995
  LET MAX_SPEED# = 5
996
+
997
  SCREEN 0, SCREEN_W#, SCREEN_H#, "My Game"
998
+
999
  LET x$ = 320
1000
  LET y$ = 240
1001
  LET running$ = TRUE
1002
+
1003
  ' ---- 3. MAIN LOOP ----
1004
  [main]
1005
  WHILE running$
 
1010
  WEND
1011
  SOUNDSTOPALL
1012
  END ' place at the end of main program so BazzBasic wont fall to subs in runtime
1013
+
1014
  ' ---- 4. SUBROUTINES (or INCLUDE "subs.bas") ----
1015
  [sub:update]
1016
  IF KEYDOWN(KEY_LEFT#) THEN x$ = x$ - MAX_SPEED#
1017
  IF KEYDOWN(KEY_RIGHT#) THEN x$ = x$ + MAX_SPEED#
1018
  RETURN
1019
+
1020
  [sub:draw]
1021
  SCREENLOCK ON
1022
  LINE (0,0)-(SCREEN_W#, SCREEN_H#), 0, BF
 
1024
  SCREENLOCK OFF
1025
  RETURN
1026
  ```
1027
+
1028
  **Key conventions:**
1029
  - Variables: `camelCase$` | Constants: `UPPER_SNAKE_CASE#` | Functions: `PascalCase$`
1030
  - Labels: `[gameLoop]` for jump targets, `[sub:name]` for subroutines
1031
  - Image/sound/shape IDs are stable integer handles — **always** store as constants: `LET MY_IMG# = LOADIMAGE("x.png")` — never use `$` variables for these
1032
  - Group many IDs → use arrays: `DIM sprites$` / `sprites$("player") = LOADIMAGE(...)` — but prefer named constants when count is small
1033
+
1034
  ---
1035
+
1036
  ## Performance Tips
1037
+
1038
  - `LINE (0,0)-(W,H), 0, BF` to clear — much faster than `CLS`
1039
  - Always wrap draw code in `SCREENLOCK ON` / `SCREENLOCK OFF`
1040
  - Store `RGB()` results in constants/variables — don't call RGB in hot loops
1041
  - Declare all variables in `[inits]`, not inside loops or subroutines
1042
  - Use `FastTrig` for any loop calling trig hundreds of times per frame
1043
  - `SLEEP 16` in game loop → ~60 FPS
1044
+
1045
  ---
1046
+
1047
  ## Known Limitations
1048
+
1049
  Things to be aware of — most are deliberate design decisions, a few are practical constraints.
1050
+
1051
  - **No line numbers.** Never supported, never will be.
1052
  - **Platform: Windows x64 only.** Linux and macOS are not supported. Browser/Android are not feasible — the runtime depends on SDL2 via P/Invoke.
1053
  - **Arrays cannot be passed to functions.** Use the `ASJSON` / `ASARRAY` round-trip pattern. The function receives an independent copy.
 
1058
  - **No integer-division operator.** Use `INT(a / b)`, `FLOOR(a / b)`, or `CINT(a / b)` depending on the rounding behavior you need.
1059
  - **Compiled `.bb` libraries are version-locked** to the BazzBasic build that produced them. Recompile after upgrading the interpreter.
1060
  - **`DEF FN` definitions must precede their first call** in source order. Forward references don't resolve.
1061
+
1062
  ---
1063
+
1064
  ## IDE Features
1065
+
1066
  ### Menus
1067
  | Menu | Items |
1068
  |------|-------|
 
1072
  | **View** | Light Mode, Dark Mode (experimental; choice saved to `%AppData%\BazzBasic\ide.json`) |
1073
  | **Run** | Run Program (F5), Compile as Exe, Compile as Library (.bb) |
1074
  | **Help** | About, Online Manual, Beginner's Guide, Rosetta Code, Check for Updates |
1075
+
1076
  **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.
1077
+
1078
  ### New File Template
1079
  When the IDE opens with no file (or a new file), this template is auto-inserted:
1080
  ```basic
1081
  ' BazzBasic version {ver_num}
1082
  ' https://ekbass.github.io/BazzBasic/
1083
  ```
1084
+
1085
  ### Beginner's Guide
1086
  - **IDE:** Menu → **Help** → **Beginner's Guide** — opens `https://github.com/EkBass/BazzBasic-Beginners-Guide/releases` in default browser
1087
  - **CLI:** `bazzbasic.exe -guide` or `bazzbasic.exe -help` — prints URL to terminal
1088
+
1089
  ### Online Manual and Rosetta Code
1090
  - **IDE:** Menu → **Help** → **Online Manual** — opens `https://ekbass.github.io/BazzBasic/manual/#/` in default browser
1091
  - **IDE:** Menu → **Help** → **Rosetta Code** — opens `https://rosettacode.org/wiki/Category:BazzBasic` in default browser
1092
  - No CLI equivalents
1093
+
1094
  ### Check for Updates
1095
  - **IDE:** Menu → **Help** → **Check for Updates...** — IDE reports if a newer version is available
1096
  - **CLI:** `bazzbasic.exe -checkupdates`
1097
+
1098
  ### Compile via IDE
1099
  - **Menu → Run → Compile as Exe** — compiles open file to standalone `.exe` (auto-saves first)
1100
+ - **Menu → Run → Compile as Library (.bb)** — compiles open file as reusable `.bb` library (auto-saves first)