Previous Page: CPXaddfpdestFirst PageNext Page: CPXaddrows

CPXaddfuncdest


Description

The CPXaddfuncdest() routine adds a function msgfunction() to the message destination list for a channel. The CPXaddfuncdest() routine allows users to "trap" messages instead of printing them. That is, when a message is sent to the channel, the routine msgfunction() is called for each destination that was added to the function destination list by CPXaddfuncdest().

To illustrate, consider an application in which a developer wishes to trap CPLEX error messages and display them in a dialog box that prompts the user for an action. Use CPXaddfuncdest() to add the address of a function to the list of message destinations associated with the cpxerror channel. Then write the msgfunction() routine. It must contain the code that controls the dialog box. When CPXmsg() is called with cpxerror as its first argument, it will call the msgfunction() routine, which can then display the error message.

The handle parameter is a generic pointer that can be used to hold information needed by the msgfunction() routine to avoid making such information global to all routines.

Return Value

The routines return a zero on success, and a nonzero if an error occurs. Failure occurs when msgfunction() is not in the message destination list or the channel does not exist.

Synopsis

int CPXaddfuncdest (CPXENVptr env,
                    CPXCHANNELptr channel,
                    void *handle,
                    void (CPXPUBLIC *msgfunction) (void *, char *));

Arguments


CPXENVptr env
The pointer to the CPLEX environment as returned by one of the CPXopenCPLEX routines.

CPXCHANNELptr channel
The pointer to the channel to which the function destination is to be added.

void *handle
A void pointer that can be used in the msgfunction() routine to direct the message to a file, the screen, or a memory location.

void (CPXPUBLIC *msgfunction) (void *, char *)
The pointer to the function to be called when a message is sent to a channel.

Example

void msgfunction (void *handle, char *msg_string)
{
FILE *fp;
    fp = (FILE *)handle;
    fprintf (fp, "%s", msg_string);
}
status = CPXaddfuncdest (env, mychannel, fileptr, msgfunction);

See Also

CPXdelfuncdest().

Example lpex5.c in the CPLEX User's Manual.

Previous Page: CPXaddfpdestFirst PageNext Page: CPXaddrows