MLGetNumberAsUCS2String (C 函数)
MLGetNumberAsUCS2String 已经被 WSGetNumberAsUCS2String 所取代.
int MLGetNumberAsUCS2String(MLINK l, const unsigned short **s, int *n)
reads the next number on the MathLink connection specified by l as a string of UCS2 characters representing the number value stored in the string s of length n.
更多信息
![](Files/MLGetNumberAsUCS2String.zh/details_1.png)
- MLGetNumberAsUCS2String() allocates memory to store the string value. To release the memory allocated by MLGetNumberAsUCS2String(), call MLReleaseUCS2String() on the contents of s. If MLGetNumberAsUCS2String() fails, do not call MLReleaseUCS2String() on the contents of s.
- MLGetNumberAsUCS2String() returns 0 on error and a nonzero value on success.
- MLGetNumberAsUCS2String() is declared in the MathLink header file mathlink.h.
范例
基本范例 (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 unsigned short *theNumber;
int length;
MLGetNumberAsUCS2String(l, &theNumber, &length);
/* ... */
MLReleaseUCS2String(l, theNumber, length);
}
}
break;
case MLTKREAL:
/* ... */
}
}