WSPutFunction()
This feature is not supported on the Wolfram Cloud.

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

DetailsDetails

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

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

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

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

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

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

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

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

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

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

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

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

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

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

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