This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function


int MLPutInteger16(MLINK link, int i)
puts the 16-bit integer i to the MathLink connection specified by link.
  • The argument i is typically declared as short in external programs, but must be declared as int in MLPutInteger16() itself in order to work even in the absence of C prototypes.
  • MLPutInteger16() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLPutInteger16() fails.
  • MLPutInteger16() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* send the expression Times[10,30] to a link */

void f(MLINK lp)
    short a = 10;
    short b = 30;

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

    if(! MLPutInteger16(lp, a))
        { /* unable to put the integer to lp */ }

    if(! MLPutInteger16(lp, b))
        { /* unable to put the integer to lp */ }

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

    if(! MLFlush(lp))
        { /* unable to flush outgoing data to lp */ }