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

int WSGetType(WSLINK link)
gets the type of the current object on the WSTP connection specified by link.

DetailsDetails

  • Unlike WSGetNext(), WSGetType() does not advance to the next object on link, so it can be safely called more than once for the same object.
  • The following types can be returned:
  • 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
    WSTKOPTSTRcharacter string from newer versions of the WSTP library
    WSTKOPTSYMsymbol from newer versions of the WSTP library
  • WSTKINT and WSTKREAL do not necessarily signify numbers that can be stored in C int and double variables.
  • WSGetType() is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

/* read the type of the expression from a link */

void f(MLINK lp)
{
    switch(WSGetType(lp))
    {
        case MLTKINT:
            /* read the integer */
        case MLTKREAL:
            /* read the floating point number */
        case MLTKSTR:
            /* read the string. */

        /* ... */
    }
}