WSNewPacket (C Function)

int WSNewPacket(WSLINK link)

skips to the end of the current packet on link.

Details

  • WSNewPacket() works even if the head of the current top-level expression is not a standard packet type.
  • WSNewPacket() does nothing if you are already at the end of a packet.
  • WSNewPacket() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSNewPacket() fails.
  • WSNewPacket() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* read the next number from a link and ignore everything else */

void f(WSLINK lp)
{
    /* determine the type of the data on the link */
    switch(WSGetType(lp))
    {
        case WSTKINT:
            /* integer data */
            break;
        case WSTKREAL:
            /* floating point data */
            break;
        default:
            /* Skip to the next packet if not a number. */
            if(! WSNewPacket(lp))
                { /* unable to jump ahead to the next packet on lp */ }
    }
}