The {$ASSERTIONS} switch determines if assert statements are compiled into the binary or not. If
the switch is on, the statement
Assert(BooleanExpression,AssertMessage);
|
Will be compiled in the binary. If te BooleanExpression evaluates to False, the RTL will check if
the AssertErrorProc is set. If it is set, it will be called with as parameters the AssertMessage
message, the name of the file, the LineNumber and the address. If it is not set, a runtime error 227
is generated.
The AssertErrorProc is defined as
Type
TAssertErrorProc=procedure(const msg,fname:string;lineno,erroraddr:longint);
Var
AssertErrorProc = TAssertErrorProc;
|
This can be used mainly for debugging purposes. The system unit sets the AssertErrorProc to a
handler that displays a message on stderr and simply exits. The sysutils unit catches the run-time
error 227 and raises an EAssertionFailed exception.