This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
MATHEMATICA LIBRARYLINK C FUNCTION|Tutorials »

processMathLink


calls Mathematica to process the expression written onto a link.
  • Used in C/C++ code in a library function called from Mathematica.
  • A nonzero error code value will be returned if there is an error.
The following gets a MathLink connection and uses it to send a message to the kernel:
The following gets a MathLink connection and uses it to send a message to the kernel:
    int err;
    MLINK link = libData->getMathLink(libData);
    MLPutFunction( link, "EvaluatePacket", 1);
    MLPutFunction( link, "Message", 2);
    MLPutFunction( link, "MessageName", 2);
    MLPutSymbol( link, "MyFunction");
    MLPutString( link, "info");
    MLPutString( link, "Message called from within DLL function.");
    err = libData->processMathLink( link);
    if (err) return err;
    pkt = MLNextPacket( link);
    if ( pkt == RETURNPKT) {
        MLNewPacket(link);
    }