OpenersNotesSection(Spacer1)Details

MathLink messages provide out-of-band message sending and receiving that is not tied to the normal transfer of data.

MLPutMessageWithArg() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[MLError(), paclet:ref/c/MLError]) to retrieve the error code if MLPutMessageWithArg() fails.

MLPutMessageWithArg() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"


/* define some custom messages and arguments */

#define AppMenuMessage MLFirstUserMessage + 1

#define AppMenuOption1 1
#define AppMenuOption2 2

/* send an AppMenuMessage to a link */

void f(MLINK lp)
{
	if(! MLPutMessageWithArg(lp, AppMenuMessage, AppMenuOption2))
		{ /* unable to send the message to lp */ }
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLPutMessage(), paclet:ref/c/MLPutMessage])  ▪  (NonWLLink[MLMessageReady(), paclet:ref/c/MLMessageReady])  ▪  (NonWLLink[MLGetMessage(), paclet:ref/c/MLGetMessage])  ▪  (NonWLLink[MLSetMessageHandler(), paclet:ref/c/MLSetMessageHandler])  ▪  (NonWLLink[MLGetMessageHandler(), paclet:ref/c/MLGetMessageHandler])}})}})