Handbook verified ALB surface syntax .alb programs
AdaLogic BASIC (ALB) Handbook
Safe syntax for learners and code-writing tools — based on the current
parser and native backend paths. Everything below is the verified sheet.
Runnable demos: Examples gallery and
docs/examples/*.alb.
General rules
- Keywords are case-insensitive.
- Comments use
--(not classicREM). - Most commands are statement-style.
- Arrays are 1-based; index
0is out of bounds. - Optional but recommended:
VERSION 0.0.0.1right afterBEGINtags your main file's source version — increase it sensibly as the file grows. This version tag is optional. - Never use reserved keywords as identifiers or field names.
Program skeleton
BEGIN
VERSION 0.0.0.1
CREATE_WINDOW "ALB APP", 960, 640
ON TICK
-- update logic
END
ON PAINT
-- draw logic
END
LISTEN
END
Declarations
-- comment
#MAX_ENTITIES = 64
LET score = 0
LET hp AS U16 = 100
LET name AS STRING = "ALB"
TYPE SmallHealth IS U16 RANGE 1 .. 255
TEMPORAL LET px AS I32 HISTORY 16 = 140
Safe declaration types
U0, U8, U16, U32, U64,
S32, I8–I64, F64/REAL,
PURE/RATIONAL, FLOAT2/FLOAT4,
MAT2–MAT4, BOOL, STRING/BINARY,
HW8/HW16/HW32.
Control flow
IF hp > 0 THEN
LET alive = TRUE
ELSE
LET alive = FALSE
END IF
WHILE hp > 0
LET hp = hp - 1
END WHILE
FOR i = 1 TO 10 THEN
PRINT i
END FOR
MATCH mode
0 => state = 1
ELSE => state = 99
END MATCH
MATCH uses => arms (no CASE).
SELECT uses CASE. Prefer multiline IF for multi-action branches.
Functions & modules
FUNCTION Twice(x AS U32) AS U32
RETURN x + x
END FUNCTION
FUNCTION PCT_X(percent AS S32) AS S32
RETURN CAST((S32(VIRTUAL_WIDTH) * percent) / 100 AS S32)
END FUNCTION
MODULE MathKit BEGIN
FUNCTION Add2(x AS U32) AS U32
RETURN x + 2
END FUNCTION
END MODULE
IMPORT MathKit
Arrays (1-based)
STRICT cells[64] AS U16
LET cells[1] = 10
PARALLEL swarm[128]
x AS S32
y AS S32
hp AS U16
END PARALLEL
LET swarm[1].x = 100
SWAPPOP swarm[dead_slot], active_count
Graphics
CREATE_WINDOW "Demo", 320, 200
CLEAR $050511
COLOR $FF3300
FILL RECT x, y, w, h
DRAW LINE x1, y1, x2, y2
TEXT 8, 8, "HELLO"
DRAW TEXT 8, 24, "SCORE: " | score_s
| and & concatenate strings (not bitwise OR).
Bitwise ops use OR / XOR / AND.
Input & environment
PRINT "HP=" | hp
INPUT "Name", player_name
LET pressed = KEY(4)
LET mx = MOUSE_X
LET vw = VIRTUAL_WIDTH
Use KEY(code), not KEY_STATE(code).
Example programs
hello.alb
BEGIN
VERSION 0.0.0.1
PRINT "Hello from AdaLogic BASIC!"
LISTEN
END
greeter.alb
BEGIN
VERSION 0.0.0.1
LET name AS STRING = "friend"
INPUT "What should we call you?", name
PRINT "Hello, " | name | "!"
LISTEN
END
count.alb
BEGIN
VERSION 0.0.0.1
FOR i = 1 TO 10 THEN
PRINT i
END FOR
LISTEN
END
window_paint.alb
BEGIN
VERSION 0.0.0.1
CREATE_WINDOW "ALB Square", 320, 240
ON PAINT
CLEAR $101018
COLOR $0B6BCB
FILL RECT 40, 40, 80, 80
COLOR $E8F1FB
TEXT 40, 140, "FILL RECT demo"
END
LISTEN
END
cells.alb
BEGIN
VERSION 0.0.0.1
STRICT cells[8] AS U16
FOR i = 1 TO 8 THEN
LET cells[i] = i * 10
END FOR
PRINT "cells[1]=" | cells[1]
LISTEN
END
Practice path
BEGIN/PRINT/LISTEN(VERSIONoptional)- Typed
LET+IF/FOR INPUT+ string|CREATE_WINDOW+ON PAINTSTRICTarrays (1-based)- Share via the Console
Common mistakes
- Use the Handbook’s statement forms instead of inventing call-style commands.
- Prefer
RETURN CAST(expr AS Type)for mixed arithmetic returns. ASSERT(expr)is runtime assert;ASSERT pred(...)is logic KB.- Do not name fields
fill,draw,match, etc. - More topics (network firewall, Markov/neural, static blit,
IMPORT_C) are documented in this handbook.
Source docs
docs/LANGUAGE.md— overviewdocs/GETTING_STARTED.md— first program- Examples gallery —
.albsources to run