Cicode Programming Reference > Cicode Function Categories > Miscellaneous Functions Introduction > Assert


Verifies that the specified expression is TRUE. If then expression is FALSE, the current task will be halted. This is useful to help prevent the execution of code you do not want to run in the event an error has been detected.

This function can be used in a debug mode, where the FALSE assertion will be logged to the Kernel and SysLog.DAT, with the time, date, Cicode file name, and line number. Additionally the operator will be prompted with a dialog. The debug mode can be set by using the [Code]DebugMessage parameter or DebugMsgSet() function.

Note: If you have the "Citect will start debugger on hardware errors" option set in the Cicode Editor, the Debugger will start with the position before the Halt() instruction. You need to 'step over' this command if you want to continue debugging the function that called the Assert().




The boolean expression. This expression needs to evaluate to TRUE (1) or FALSE (0).

Return Value

None. However, if the assertion tests as FALSE, error 347 is generated.

Related Functions

Halt, DebugMsg, DebugMsgSet, CodeTrace, TraceMsg, ErrLog


FUNCTION FileDisplayEx(STRING sFileName);
INT hFile;
hFile = FileOpen(sFileName, "r");
Assert(hFile <> -1);

See Also

Miscellaneous Functions