#COMPILE EXE ["filename"]Specifies the output target type. EXE produces a console executable. DLL and GUI/WINDOWS modes are recognized but explicitly rejected with a clear diagnostic (V22) until PE export/subsystem writing is implemented.
#COMPILE EXE "myapp.exe"
#DIM ALLRequires explicit declaration of all variables. Variables used without a LOCAL, DIM, STATIC, or GLOBAL declaration will produce an error.
#DIM ALL ' Best practice: always declare variables
#INCLUDE "filename" | #INCLUDE ONCE "filename" | #INCLUDEONCE "filename"Inserts the contents of another source file at the directive location. #INCLUDE ONCE and #INCLUDEONCE (V22) ensure the file is included only once, preventing duplicate declarations. Missing-file diagnostics are emitted when include-once paths fail.
Include paths are resolved relative to the current source file, then against paths specified with -I on the command line.
#INCLUDE ONCE "win32api.inc" #INCLUDEONCE "mytypes.pbi" #INCLUDE "helpers.inc"
#IF condition ... #ELSEIF condition ... #ELSE ... #ENDIFConditionally include or exclude blocks of source code at compile time (V21). Supports %DEF(name), NOT, AND, and OR in conditions. Dollar-branch variants $IF, $ELSEIF, $ELSE, $ENDIF are also supported.
#IF %DEF(PBXA64_V22)
PRINT "V22 macros available"
#ELSEIF %DEF(DEBUG)
PRINT "Debug build"
#ELSE
PRINT "Release build"
#ENDIF
#DEFINE name value | #UNDEF name#DEFINE (V22) creates an object-like text-replacement macro. Every occurrence of name in subsequent source is replaced with value. #UNDEF (V21) removes a previously defined symbol. Duplicate definitions produce a diagnostic error.
#DEFINE MAX_COUNT 100 #DEFINE APP_NAME "MyApp" LOCAL i AS LONG FOR i = 1 TO MAX_COUNT : PRINT APP_NAME : NEXT i #UNDEF MAX_COUNT
MACRO name(args) = expr or MACRO name(args) ... END MACROMacro expansion engine (V22). Supports:
MACRO Add1(x) = (x + 1)MACRO name(args) ... END MACROMACROFUNCTION name(args) ... END MACRO = expr with MACROTEMP unique-name generationExpansion is source-text based with recursion guards, depth limits, and arity diagnostics.
MACRO SAY(text)
PRINT text
END MACRO
MACROFUNCTION Twice(x)
MACROTEMP t
LOCAL t AS LONG
t = x * 2
END MACRO = t
See V22 Macro Preprocessor for full details.
#INCLUDE resolution with depth tracking to prevent infinite recursion. Include files use the .pbi extension by convention.
| Directive | Language | Description |
|---|---|---|
#PCODE ... #ENDP | PILOT | Embedded PILOT educational language block. Commands are lowered to PB statements. |
FUNCTION PBMAIN() AS LONG
#PCODE
T: Hello from PILOT!
A: What is your name?
T: Nice to meet you, $A!
E:
#ENDP
FUNCTION = 0
END FUNCTION