DECLARE FUNCTION|SUB name LIB "dll" ALIAS "export" (params) AS typeDeclares an external function imported from a Windows DLL. Supports BYVAL and BYREF parameters. Multiline parameter lists with _ continuation are supported.
DECLARE FUNCTION MessageBoxA LIB "user32.dll" _
ALIAS "MessageBoxA" ( _
BYVAL hWnd AS QUAD, _
BYVAL lpText AS ASCIIZ PTR, _
BYVAL lpCaption AS ASCIIZ PTR, _
BYVAL uType AS LONG _
) AS LONG
variable = expression | FUNCTION = expressionAssigns a value to a variable. FUNCTION = expr sets the return value of the current function.
x = 42 name$ = "Hello" FUNCTION = 0
PRINT expr [; expr ...]Outputs text to the console. Multiple expressions separated by ; are concatenated. A trailing expression adds a newline.
PRINT "The value is "; x PRINT "Hello, "; name$
IF condition THEN statements [ELSE statements] END IFConditional execution. Supports ELSEIF for multi-way branching.
IF x > 10 THEN
PRINT "Large"
ELSEIF x > 0 THEN
PRINT "Small"
ELSE
PRINT "Zero or negative"
END IF
FOR var = start TO end [STEP n] : statements : NEXT [var]Iterates a variable from start to end with optional STEP increment.
FOR i = 1 TO 10
PRINT i
NEXT i
FOR j = 10 TO 1 STEP -2
PRINT j
NEXT
WHILE condition : statements : WENDRepeats a block of statements while the condition is true.
WHILE x > 0
PRINT x
x = x - 1
WEND
GOTO labelUnconditional jump to a label. Labels are plain identifiers followed by :.
IF error THEN GOTO Cleanup PRINT "All OK" Cleanup: PRINT "Done"
GOSUB label ... label: ... RETURNCalls a local subroutine and returns when RETURN is encountered.
GOSUB PrintHeader
...
PrintHeader:
PRINT "=== Header ==="
RETURN
CALL procedure(args)Calls an external or user-defined procedure. For external WinAPI calls, arguments are staged according to the Windows x64 calling convention (first 4 in registers, rest on stack).
CALL MessageBoxA(0, STRPTR(msg$), "Title", 0)
OPEN "file" FOR OUTPUT|APPEND|INPUT AS #nOpens a file for output (write), append, or input (read). The file number #n is used in subsequent I/O statements.
OPEN "data.txt" FOR OUTPUT AS #1 OPEN "data.txt" FOR APPEND AS #2 OPEN "data.txt" FOR INPUT AS #3
PRINT #n, expr [; expr ...]Writes text to an open file.
PRINT #1, "Line of text" PRINT #1, "Value: "; x
INPUT #n, variableReads data from an open file into a variable.
INPUT #3, line$
CLOSE #nCloses an open file.
CLOSE #1