MLTestUCS2Head (C Function)
MLTestUCS2Head has been replaced by WSTestUCS2Head.
int MLTestUCS2Head(MLINK l, const unsigned short *h, int v, int *n)
tests that the next expression to be read from l is an expression with the head h and a UCS2 encoded name of length v, and stores the number of arguments of the expression in n.
Details
![](Files/MLTestUCS2Head.en/details_1.png)
- MLTestUCS2Head() fails if the current expression on the link is not a function with a symbol as a head, or if the name of the symbol does not match h.
- MLTestUCS2Head() returns 0 in the event of an error, and a nonzero value if the function succeeds.
- Use MLError() to retrieve the error code if MLTestUCS2Head() fails.
- MLTestUCS2Head() will reset the stream pointer to the expression on the link just prior to calling MLTestUCS2Head() if the function fails. This operation behaves as if the programmer called MLCreateMark(l); MLTestUCS2Head(…); MLSeekToMark(…).
- MLTestUCS2Head() is declared in the MathLink header file mathlink.h.
Examples
Basic Examples (1)
#include "mathlink.h"
/* A function for testing whether the next expression on the link is a ReturnPacket[] */
void f(MLINK l)
{
const unsigned short packet[12];
int arguments;
packet[0] = 'R';
packet[1] = 'e';
packet[2] = 't';
packet[3] = 'u';
packet[4] = 'r';
packet[5] = 'n';
packet[6] = 'P';
packet[7] = 'a';
packet[8] = 'c';
packet[9] = 'k';
packet[10] = 'e';
packet[11] = 't';
if(! MLTestUCS2Head(l, (const unsigned short *)packet, 12,
&arguments))
{ /* read the contents of the ReturnPacket[] */ }
else
{ /* the head of the incoming expression is not ReturnPacket */ }
}