MLTestHeadWithArgCount has been replaced by WSTestHeadWithArgCount.

int MLTestHeadWithArgCount(MLINK l, const char *s, int *n)

tests that the next object to be read from the MathLink connection specified by l is an expression with head s, and that the number of arguments of the expression is n.


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


Basic Examples  (1)

#include "mathlink.h"

/* A function to test whether the next expression on the Link is Plus[a,b] */

void f(MLINK l)
    int args = 2;
    const char *symbol;

    if(! MLTestHeadWithArgCount(l, "Plus", &args))
    { /* Next expression is not Plus, or does not have two args */ }

    if(! MLGetSymbol(l, &symbol))
    { /* Unable to read symbol */ }

    /* Check if symbol is 'a' */

    MLReleaseSymbol(l, symbol);

    if(! MLGetSymbol(l, &symbol))
    { /* Unable to read symbol */ }

    /* Check if the symbol is 'b' */

    MLReleaseSymbol(l, symbol);

See Also

MLGetArgCount()  MLTestHead()   MLTestUCS2HeadWithArgCount()   MLTestUTF16HeadWithArgCount()   MLTestUTF32HeadWithArgCount()   MLTestUTF8HeadWithArgCount()