OpenersNotesSection(Spacer1)Details

WSGetNumberAsString() allocates memory to store the string value. To release the memory allocated by WSGetNumberAsString(), call (NonWLLink[WSReleaseString(), paclet:ref/c/WSReleaseString]) on the contents of s. If WSGetNumberAsString() fails, do not call (NonWLLink[WSReleaseString(), paclet:ref/c/WSReleaseString]) on the contents of s.

WSGetNumberAsString() returns 0 on error and a nonzero value on success.

WSGetNumberAsString() 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 for reading an integer from a link */

void f(WSLINK l)
{
	switch(WSGetType(l))
	{
		case WSTKINT:
		{
			int rawType;
			rawType = WSGetRawType(l);
			if(rawType == WSTK_WSSHORT)
			{
				short theNumber;
				WSGetInteger16(l, &theNumber);
				/* ... */
			}
			else if(rawType == WSTK_WSINT)
			{
				int theNumber;
				WSGetInteger32(l, &theNumber);
				/* ... */
			}
			else
			{
				const char *theNumber;
				WSGetNumberAsString(l, &theNumber);
				/* ... */
				WSReleaseString(l, theNumber);
			}
		}
		break;
		case WSTKREAL:
			/* ... */
	}
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSReleaseString(), paclet:ref/c/WSReleaseString])  ▪  (NonWLLink[WSGetNumberAsUCS2String(), paclet:ref/c/WSGetNumberAsUCS2String])  ▪  (NonWLLink[WSGetNumberAsUTF16String(), paclet:ref/c/WSGetNumberAsUTF16String])  ▪  (NonWLLink[WSGetNumberAsUTF32String(), paclet:ref/c/WSGetNumberAsUTF32String])  ▪  (NonWLLink[WSGetNumberAsUTF8String(), paclet:ref/c/WSGetNumberAsUTF8String])}})}})

({{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])}})}})