V26 Error, DATA, Array & File Commands

Error Handling

ON ERROR GOTO

Syntax: ON ERROR GOTO label

Redirects runtime errors to a label. Use ERR and ERL to inspect the error.

ON ERROR GOTO failed
ERROR 9        ' Simulate subscript error
EXIT FUNCTION
failed:
    PRINT "Error "; ERR; " at line "; ERL
    ERRCLEAR
    RESUME NEXT

ON ERROR RESUME NEXT

Syntax: ON ERROR RESUME NEXT

Ignores errors and continues execution at the next statement.

ON ERROR GOTO 0

Syntax: ON ERROR GOTO 0

Disables error trapping. Errors will terminate the program.

ERR / ERL / ERRCLEAR

Syntax: ERR, ERL, ERRCLEAR

ERR returns the last error number. ERL returns the line number. ERRCLEAR clears the error state.

ERROR n

Syntax: ERROR n

Triggers a runtime error with code n.

RESUME / RESUME NEXT

Syntax: RESUME | RESUME NEXT

RESUME retries the statement that caused the error. RESUME NEXT continues after it.

DATA / READ / RESTORE

DATA

Syntax: DATA value1, value2, ...

Stores literal values at compile time. Can appear at the end of the source file or with a label.

DATA 12, 34, "MASTER"
myData: DATA 100, 200

READ

Syntax: READ var1, var2, ...

Reads values from DATA statements into variables.

LOCAL a AS LONG, b AS LONG, s AS STRING
READ a, b, s

RESTORE

Syntax: RESTORE [label]

Resets the DATA pointer. With a label, points to a specific DATA block.

RESTORE          ' Reset to first DATA
RESTORE myData   ' Point to labelled DATA

Array Commands

CommandDescription
ARRAY ASSIGN a(), valueFill all elements with a value
ARRAY REVERSE a()Reverse element order
ARRAY SORT a()Sort elements ascending
ARRAY COPY src() TO dst()Copy array contents
ARRAY SCAN a(), = value TO resultFind element index
Current limit: These commands target one-dimensional dynamic numeric arrays.
REDIM nums(1 TO 5) AS LONG
REDIM copy(1 TO 1) AS LONG
ARRAY ASSIGN nums(), 7
ARRAY SORT nums()
ARRAY SCAN nums(), = 7 TO found
ARRAY COPY nums() TO copy()

File & Directory Commands

CommandDescription
FILECOPY src$, dst$Copy a file
RMDIR path$Remove a directory
GETATTR(path$)Get file attributes
SETATTR path$, attrsSet file attributes
RESETClose all open files
FLUSH #nFlush file buffer
SETEOF #nSet end of file
REMAIN$(#n)Remaining chars after GET

Math & Selection

FunctionDescription
MIN(a, b)Return smaller value
MAX(a, b)Return larger value
IIF(cond, t, f)Inline if-then-else
CHOOSE(idx, v1, v2, ...)Select value by index
SWITCH(cond1, val1, cond2, val2, ...)First matching condition
ROUND(x)Round to nearest integer

String & Format Helpers

FunctionDescription
BUILD$(expr1, expr2, ...)Build string from expressions
CLIP$(s$)Remove leading/trailing spaces
RETAIN$(s$, chars$)Keep only specified characters
SHRINK$(s$)Collapse multiple spaces
FORMAT$(n, "000")Format number with zero-picture mask
PRINT USING mask$; exprFormatted output (first-pass)

LIKE Operator

Syntax: expr LIKE pattern$

First-pass substring pattern matching. Returns true if pattern$ is found in the source expression.

IF s LIKE "M" THEN PRINT "Match found"

#ASM Blocks

Syntax: #ASM ... #ENDASM

Raw x64 assembly injection. Text is passed directly to the assembler output.

#ASM
    nop
    ; custom x64 instructions here
#ENDASM

LINE Graphics

Syntax: LINE x1, y1, x2, y2

Graphics line statement (scaffold in V26 -- parsed but not yet lowered to GDI calls).