OpenersNotesSection(Spacer1)Details

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

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

MLGetNumberAsString() is declared in the MathLink header file (RefLink[mathlink.h, paclet:/ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

/* A function for reading an integer from a link */

void f(MLINK l)
{
	switch(MLGetType(l))
	{
		case MLTKINT:
		{
			int rawType;
			rawType = MLGetRawType(l);
			if(rawType == MLTK_MLSHORT)
			{
				short theNumber;
				MLGetInteger16(l, &theNumber);
				/* ... */
			}
			else if(rawType == MLTK_MLINT)
			{
				int theNumber;
				MLGetInteger32(l, &theNumber);
				/* ... */
			}
			else
			{
				const char *theNumber;
				MLGetNumberAsString(l, &theNumber);
				/* ... */
				MLReleaseString(l, theNumber);
			}
		}
		break;
		case MLTKREAL:
			/* ... */
	}
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLReleaseString(), paclet:/ref/c/MLReleaseString])  ▪  (NonWLLink[MLGetNumberAsUCS2String(), paclet:/ref/c/MLGetNumberAsUCS2String])  ▪  (NonWLLink[MLGetNumberAsUTF16String(), paclet:/ref/c/MLGetNumberAsUTF16String])  ▪  (NonWLLink[MLGetNumberAsUTF32String(), paclet:/ref/c/MLGetNumberAsUTF32String])  ▪  (NonWLLink[MLGetNumberAsUTF8String(), paclet:/ref/c/MLGetNumberAsUTF8String])}})}})