WSGetInteger32 (C Function)

int WSGetInteger32(WSLINK link,int *i)

gets a 32-bit integer from the WSTP connection specified by link and stores it in i.


  • If the data on the link corresponds to a real number, WSGetInteger32() will round it to an integer.
  • If the data on the link corresponds to an integer too large to store in a C int on your computer system, then WSGetInteger32() will fail, and return 0.
  • You can get arbitrary-precision integers by first using IntegerDigits to generate lists of digits, then calling WSGetInteger32List().
  • WSGetInteger32() returns a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetInteger32() fails.
  • WSGetInteger32() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

/* read a 32-bit integer from a link */

void f(WSLINK lp)
    int data;

    if(! WSGetInteger32(lp, &data))
        { /* unable to read an integer from lp */ }

    /* use the integer */