Initializing help system before first use

xpress.addcbmsghandler

xpress.addcbmsghandler


Purpose
Declares an output callback function in the global environment, called every time a line of message text is output by any object in the library. This callback function will be called in addition to any output callbacks already added by xpress.addcbmsghandler.
Synopsis

xpress.addcbmsghandler(msghandler, data, priority)

ret = f_msghandler(vObject, vUserContext, vSystemThreadId, sMsg, iMsgType, iMsgNumber)


Arguments
msghandler 
The callback function which takes six arguments, vObject, vUserContext, vSystemThreadId, sMsg, iMsgType and iMsgNumber. Use None to cancel a callback function.
vObject 
The object sending the message.
vUserContext 
The user-defined object passed to the callback function.
vSystemThreadId 
The system id of the thread sending the message cast to a void *.
sMsg 
A string containing the message, which may simply be a new line. When the callback is called for the first time sMsg will be empty.
iMsgType 
Indicates the type of output message:
information messages;
(not used);
warning messages;
error messages.
When the callback is called for the first time iMsgType will be a negative value.
iMsgNumber 
The number associated with the message. If the message is an error or a warning then you can look up the number in the section Optimizer Error and Warning Messages for advice on what it means and how to resolve the associated issue.
data 
A user-defined object to be passed to the callback function.
priority 
An integer that determines the order in which multiple message handler callbacks will be invoked. The callback added with a higher priority will be called before a callback with a lower priority. Set to 0 if not required.
Further information
To send all messages to a log file the built in message handler logfilehandler can be used. This can be done with:
xpress.addcbmsghandler(logfilehandler, 'log.txt', 0) 

Related topics