MLTestHead has been replaced by WSTestHead.

int MLTestHead(MLINK link,const char *head,int *n)

tests that the next object to be read from link is an expression with head head, and stores the number of arguments of the expression in n.


  • MLTestHead() fails if the current object on the link is not a function with a symbol as a head, or if the name of the symbol does not match head.
  • MLTestHead() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLTestHead() fails.
  • MLTestHead() will reset the stream pointer to the expression on the link just prior to calling MLTestHead() if the function fails. This operation behaves as if the programmer called MLCreateMark(link); MLTestHead(); MLSeekToMark().
  • MLTestHead() is declared in the MathLink header file mathlink.h.


Basic Examples  (1)

#include "mathlink.h"

/* test whether the head of the incoming object is "ReturnPacket" */

void f(MLINK lp)
    int args;

    if(MLTestHead(lp, "ReturnPacket", &args))
        { /* read the contents of the ReturnPacket[] */ }
        { /* the head of incoming packet is not "ReturnPacket" */ }

See Also

MLGetArgCount()  MLTestUCS2Head()  MLTestUTF16Head()  MLTestUTF32Head()  MLTestUTF8Head()  MLTestHeadWithArgCount()