OpenersNotesSection(Spacer1)Details

WSTestUCS2HeadWithArgCount() fails if the current expression on the link is not a function with a symbol as a head, if the name of the symbol does not match s, or if the number of arguments for the function is not n.

WSTestUCS2HeadWithArgCount() stores the actual number of arguments to the function in n when the function returns.

WSTestUCS2HeadWithArgCount() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[WSError(), paclet:ref/c/WSError]) to retrieve the error code if WSTestUCS2HeadWithArgCount() fails.

WSTestUCS2HeadWithArgCount() will reset the stream pointer to the expression on the link just prior to calling WSTestUCS2HeadWithArgCount() if the function fails. This operation behaves as if the programmer has called WSCreateMark(l); WSTestUCS2HeadWithArgCount(...); WSSeekToMark(...).

WSTestUCS2HeadWithArgCount() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "wstp.h"

/* A function to test whether the next expression on the Link is Plus[a,b] */

void f(WSLINK l)
{
	unsigned short symbol[4];
	int args = 2;
	const char *symbol;

	symbol[0] = 'P';
	symbol[1] = 'l';
	symbol[2] = 'u';
	symbol[3] = 's';

	if(! WSTestUCS2HeadWithArgCount(l, (const unsigned short *)symbol, 4, &args))
	{ /* Next expression is not Plus, or does not have two args */ }

	if(! WSGetSymbol(l, &symbol))
	{ /* Unable to read symbol */ }

	/* Check if symbol is 'a' */

	WSReleaseSymbol(l, symbol);

	if(! WSGetSymbol(l, &symbol))
	{ /* Unable to read symbol */ }

	/* Check if the symbol is 'b' */

	WSReleaseSymbol(l, symbol);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSGetArgCount(), paclet:ref/c/WSGetArgCount])  ▪  (NonWLLink[WSTestHead(), paclet:ref/c/WSTestHead])  ▪  (NonWLLink[WSTestHeadWithArgCount(), paclet:ref/c/WSTestHeadWithArgCount])  ▪  (NonWLLink[WSTestUTF16HeadWithArgCount(), paclet:ref/c/WSTestUTF16HeadWithArgCount])  ▪  (NonWLLink[WSTestUTF32HeadWithArgCount(), paclet:ref/c/WSTestUTF32HeadWithArgCount])  ▪  (NonWLLink[WSTestUTF8HeadWithArgCount(), paclet:ref/c/WSTestUTF8HeadWithArgCount])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Expressions, paclet:guide/WSTPCFunctionsForExchangingExpressions])}})}})