WSPutNext (C Function)

int WSPutNext(WSLINK link,int type)

prepares to put an object of the specified type on link.

Details

  • All type values begin with WSTK.
  • The following types are common:
  • WSTKERRerror
    WSTKINTinteger
    WSTKFUNCcomposite function
    WSTKREALapproximate real number
    WSTKSTRcharacter string
    WSTKSYMsymbol
    WSTKOLDINTinteger from older versions of the WSTP library
    WSTKOLDREALapproximate real number from older versions of the WSTP library
    WSTKOLDSTRcharacter string from older versions of the WSTP library
    WSTKOLDSYMsymbol from older versions of the WSTP library
  • WSTKINT and WSTKREAL do not necessarily signify numbers that can be stored in C int and double variables.
  • WSPutNext() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSPutNext() fails.
  • WSPutNext() is declared in the WSTP header file mathlink.h.

Examples

Basic Examples  (1)

#include "wstp.h"

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

void f(WSLINK lp)
{
    if(! WSPutNext(lp, WSTKFUNC))
        { /* unable to put the function type to lp */ }

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

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

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

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

    if(! WSFlush(lp))
        { /* unable to flush any buffered outgoing data to lp */ }
}