OnSystemMessage is a special global function. It is a function that gets called when a system message is issued. This is similar to the
OnKey or
OnStop functions, which get called automatically by the running CSPro application, not because of a call to the function in your logic. A system message is a message such as "Invalid subscript," not a user message that comes from an
errmsg statement.
The function must return a numeric value and you can provide from one to three parameters. If one numeric parameter is provided, then it will receive the message number. If two numeric parameters are provided, the second numeric parameter will get the message type (1 = error, 2 = warning). If a string parameter is provided, then it will receive the message text.
Return 0 (false) to suppress the message. Returning anything other than 0 means that the message will be issued (displayed to the enumerator in a data entry application or written to the listing file in a batch application).
function OnSystemMessage(numeric message_number, string message_text)
// modify the displayed message for invalid subscript errors
if message_number = 1008 then
errmsg("Subscript Error (%d). Most likely cause is no children in household. %s", message_number, message_text);
// suppress the system message
exit false;
endif;
// issue the message in all other cases
exit true;
end;