WSPutType (C Function)

int WSPutType(WSLINK link, int type)

prepares link to put an object of the specified type.

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.
  • WSPutType() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSPutType() fails.
  • WSPutType() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

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

void f(WSLINK lp)
{
    if(! WSPutType(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 an buffered outgoing data to lp */ }
}