Applies To:
  • CitectSCADA 3.10

The way ErrSet() controls Cicode error handling has changed in version 3.10 (see Q1742). Prior to this, ErrSet() changed a global flag that allowed cicode tasks to do their own error handling. In version 3.10, each cicode thread has it's own flag to determine if the cicode can do its own error handling.

This is important when upgrading a system from previous versions, because the best practice was to call ErrSet(1) on startup, then leave it on. In version 3.10, this doesn't work because the error handling is thread based. Only startup cicode can handle errors after upgrading to 3.10.


The solution is to set up a global error handler using the OnEvent function as follows;

OnEvent( 2, ErrorHandler );

Now declare the ErrorHandler function;


This is a callback function, so it must return an INT, and have no arguments. Because the error handler does NOT return 0, the cicode thread will be allowed to resume.

Even if ErrSet(1) is never called, or ErrSet(0) has been called, then the global error handler will still allow the cicode to handle its own errors.

The parameter [cicode]HaltOnError has been include in version 3.2 and later to work around this problem if you set this parameter to 0 then it is the same as calling ErrSet(1) for all cicode threads. So to solve this problem you may also upgrade to version 3.2 and set the following parameter in the CITECT.INI file or in the parameters database.