Mathematica > Systems Interfaces & Deployment > C/C++ Language Interface > MathLink C Language Functions >
Mathematica > Systems Interfaces & Deployment > MathLink API > MathLink C Language Functions >
MathLink C Function

MLPutNext()

int MLPutNext(MLINK link, int type)
prepares to put an object of the specified type on link.
  • All type values begin with MLTK.
  • The following types are common:
MLTKERRerror
MLTKINTinteger
MLTKFUNCcomposite function
MLTKREALapproximate real number
MLTKSTRcharacter string
MLTKSYMsymbol
MLTKOLDINTinteger from older versions of the MathLink library
MLTKOLDREALapproximate real number from older versions of the MathLink library
MLTKOLDSTRcharacter string from older versions of the MathLink library
MLTKOLDSYMsymbol from older versions of the MathLink library
  • MLTKINT and MLTKREAL do not necessarily signify numbers that can be stored in C int and double variables.
  • MLPutNext() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLPutNext() fails.
  • MLPutNext() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* send a function using tokens and argument counts to a link */

void f(MLINK lp)
{
    if(! MLPutNext(lp, MLTKFUNC))
        { /* unable to put the function type to lp */ }

    if(! MLPutArgCount(lp, 2))
        { /* unable to put the number of arguments to lp */ }

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

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

    if(! MLPutInteger32(lp, 3))
        { /* unable to put the integer to lp */ }

    if(! MLFlush(lp))
        { /* unable to flush any buffered outgoing data to lp */ }
}
© 2008 Wolfram Research, Inc.
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team