WSGetType (C Function)

int WSGetType(WSLINK link)

gets the type of the current object on the WSTP connection specified by link.

Details

  • 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.

Examples

Basic Examples  (1)

#include "wstp.h"

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

void f(WSLINK lp)
{
    switch(WSGetType(lp))
    {
        case WSTKINT:
            /* read the integer */
        case WSTKREAL:
            /* read the floating point number */
        case WSTKSTR:
            /* read the string. */

        /* ... */
    }
}