MLPutFunction()

int MLPutFunction(MLINK link, const char *s, int n)
puts a function with head given by a symbol with name s and with n arguments to the MathLink connection specified by link.

DetailsDetails

  • After the call to MLPutFunction() other MathLink functions must be called to send the arguments of the function.
  • MLPutFunction() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLPutFunction() fails.
  • MLPutFunction() is declared in the MathLink header file mathlink.h.

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

#include "mathlink.h"

/* put an Integrate[] expression to a link */

void f(MLINK lp)
{
    if(! MLPutFunction(lp, "Integrate", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutFunction(lp, "Times", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutFunction(lp, "Power", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutSymbol(lp, "x", 1))
        { /* unable to put the symbol to lp */ }

    if( ! MLPutInteger(lp, 2))
        { /* unable to put the integer to lp */ }

    if(! MLPutFunction(lp, "Power", 2))
        { /* unable to put the function to lp */ }

    if(! MLPutFunction(lp, "Sqrt", 1))
        { /* unable to put the function to lp */ }

    if(! MLPutSymbol(lp, "x", 1))
        { /* unable to put the symbol to lp */ }

    if(! MLPutInteger(lp, -1))
        { /* unable to put the integer to lp */ }

    if(! MLPutSymbol(lp, "x", 1))
        { /* unable to put the symbol to lp */ }

    if(! MLEndPacket(lp))
        { /* unable to send the end-of-packet sequence to lp */ }

    if(! MLFlush(lp))
        { /* unable to flush any buffered output data in lp */ }
}
New to Mathematica? Find your learning path »
Have a question? Ask support »