Using CitectSCADA > Compiling and Running a Project > Running the System > Using a Callback function
Using a Callback function

You can use a callback function (with the OnEvent function) to perform housekeeping tasks before the system shuts down. You would normally call OnEvent() in the main startup function (defined with the [Code]Startup parameter). Each time a Shutdown() call is made, the callback function is run.

/* A user shutdown procedure. */
INT
FUNCTION
MyStartupFunction()
...
OnEvent(25, MyShutdown);
...
END

INT
FUNCTION
MyShutdown()
STRING sPath;
// Perform housekeeping tasks
...
sPath = ProjectCurrentGet();
If sPath = "ProjectA" Then
ProjectSet("ProjectB");
Else
ProjectSet("ProjectA");
END
Shutdown("Everybody", sPath, 2);
END