V26 Error, DATA, Array & File Commands
Error Handling
ON ERROR GOTO
ON ERROR GOTO labelRedirects 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
ON ERROR RESUME NEXTIgnores errors and continues execution at the next statement.
ON ERROR GOTO 0
ON ERROR GOTO 0Disables error trapping. Errors will terminate the program.
ERR / ERL / ERRCLEAR
ERR, ERL, ERRCLEARERR returns the last error number. ERL returns the line number. ERRCLEAR clears the error state.
ERROR n
ERROR nTriggers a runtime error with code n.
RESUME / RESUME NEXT
RESUME | RESUME NEXTRESUME retries the statement that caused the error. RESUME NEXT continues after it.
DATA / READ / RESTORE
DATA
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
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
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
| Command | Description |
|---|---|
ARRAY ASSIGN a(), value | Fill 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 result | Find element index |
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
| Command | Description |
|---|---|
FILECOPY src$, dst$ | Copy a file |
RMDIR path$ | Remove a directory |
GETATTR(path$) | Get file attributes |
SETATTR path$, attrs | Set file attributes |
RESET | Close all open files |
FLUSH #n | Flush file buffer |
SETEOF #n | Set end of file |
REMAIN$(#n) | Remaining chars after GET |
Math & Selection
| Function | Description |
|---|---|
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
| Function | Description |
|---|---|
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$; expr | Formatted output (first-pass) |
LIKE Operator
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
#ASM ... #ENDASMRaw x64 assembly injection. Text is passed directly to the assembler output.
#ASM
nop
; custom x64 instructions here
#ENDASM
LINE Graphics
LINE x1, y1, x2, y2Graphics line statement (scaffold in V26 -- parsed but not yet lowered to GDI calls).