#OVERRIDE & Preprocessor
#OVERRIDE replaces a registered BASIC runtime call with a typed custom function body. This allows controlled adaptations and targeted instrumentation without rewriting every call in the program.
Typed replacement within the module
The definition is placed at module scope, starts with #OVERRIDE target(parameter AS type) AS returntype and ends with #ENDOVERRIDE. This function example sets FUNCTION in its body. The compiler checks the registered target contract and parameter/return types. Separate source rules also cover registered statement and operator targets; not every name is an eligible target.
#OVERRIDE is distinct from ordinary macro text replacement and the OVERRIDE method keyword in classes. Preprocessor directives such as #IF and user-defined symbols are excluded as targets. It does not globally replace an operating-system function either. The definition belongs to the compiled module rather than acting as a global switch for other programs.
Example: deliberately customize ABS
Compiled and executed with shipped V21 on 2026-09-30: ABS(2) deliberately returns 42 here. This intentionally changes semantics rather than preserving mathematical ABS. A separate negative #OVERRIDE #IF test was rejected with diagnostic 4125 and produced no executable.
Open checked sourcePreprocessor: selection and reuse before compilation
The separate BASIC preprocessor handles file inclusion with #INCLUDE, object-like and function-like #DEFINE macros, conditional branches with #IF / #ELSE / #ENDIF, and repeated source generation with #REPEAT / #ENDREPEAT. The driver provides -E, -I, -D and -U for preprocessing output, include paths and command-line definitions.
This processing occurs before the BASIC frontend. #OVERRIDE instead replaces a typed runtime call; the two tools have different scopes.
Example: include, macro, condition and repetition
V21: compiled and executed natively. The %INDEX = 2 branch sets SELECTED to 40; ADD(SELECTED, 2) must equal 42. The selected #IF branch is checked; failures return 1 or 2.
Open checked sourceweb-defines.inc
The include file is part of the checked example. Save this text as web-defines.inc alongside preprocessor.pb.
Supported by the current #OVERRIDE collector, existing contract cases and the stated short V21 checks. This single example does not fully qualify every overload, operator or statement variation.
View verification receiptsX-Code