WSGetInteger8 (C Function)

int WSGetInteger8( WSLINK l , unsigned char * i )

gets an 8-bit integer from the WSTP connection specified by l and stores it in i.

Details

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

Examples

Basic Examples  (1)

#include "wstp.h"

/* A function to read an unsigned char from a link */

void f(WSLINK l)
{
    unsigned char c;

    if(! WSGetInteger8(l, &c))
    { /* Unable to read the integer from l */ }

    /* Use the integer */
}