Description
CLIP provides a diagnostics service that allows user code to generate and manage diagnostics and also display CLIP runtime generated diagnostics.
Generation
The ClpDiag function has identical functionality to the standard 'C' printf function except that the resulting string output is handled by a user defined function (see below). This function will return TRUE if successful, or FALSE if an error occurs.
Uns ClpDiag( char *fmt [,arg]... );
fmt
Format control string (see printf function ).
arg
Optional arguments.
Routing
Diagnostic routing is governed by the 'Route to Master' process attribute (see Process Attributes). If routing is enabled and the executing process is a slave or a sub-master then all its diagnostics will be relayed to its master process for display.
Filing
Diagnostic filing is governed by the 'Output File' process attribute (see Process Attributes). This attribute determines the name (and path) of the file that the executing process will use to output diagnostics. If this is set to 'Disabled' then no file will be opened. If it is set to 'Default' then it will use; Slave[id]Diags.txt, SubMaster[id]Diags.txt or RootMasterDiags.txt; depending on the process type and id. Otherwise it needs to be a string in double quotes or a macro that evaluates to a Char* string. Newly created diagnostic files will overwrite earlier files with the same name.
Handling
Diagnostic handling is governed by the 'On Diagnostic' process attribute (see Process Attributes). The attribute determines the name (and namespace) of a user function that is called each time a diagnostic is issued. If the attribute is set to 'disabled' then no handler will be called, if it is set to 'default' then the default handler will be called, otherwise it should be set to the name of a function that must take the form; void Handler( char *diag, void *dialoguePtr ). On entry the 'diag' string is that provided by the corresponding system and/or user diagnostic call; and dialoguePtr will hold the address of the selected dialogue window which was set using the SetCallbackWindow function (see GUI programming).
In all cases the handler will be executed by the 'GUI' thread, but the default handler will be platform specific.
Examples
Uns TestDefn1_PhilosopherMthdElem::ProcessThink()
{
Uns failed = FALSE;
Uns elemNum = this->ElemNum();
ClpDiag( "%d) Thinking\n", elemNum );
failed = ! Think();
ClpDiag( "%d) Done Thinking %d\n", elemNum, ! failed );
return ! failed;
}