Mathematica > Systems Interfaces & Deployment > C/C++ Language Interface > MathLink C Language Functions >
Mathematica > Systems Interfaces & Deployment > MathLink API > MathLink C Language Functions >
MathLink C Function

MLGetSymbol()

int MLGetSymbol(MLINK link, const char **s)
gets a character string corresponding to the name of a symbol from the MathLink connection specified by link, storing the resulting string in s.
  • MLGetSymbol() allocates memory for the character string. You must call MLReleaseSymbol() to disown this memory. If MLGetSymbol() fails and the function's return value indicates an error, do not call MLReleaseSymbol() on the value contained in s.
  • MLGetSymbol() creates a string that is terminated by \0.
  • MLGetSymbol() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetSymbol() fails.
  • MLGetSymbol() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* read a symbol from a link */

void f(MLINK lp)
{
    const char *symbol;

    if(! MLGetSymbol(lp, &symbol))
        {
            /* unable to read the symbol from lp */
            return;
        }

    /* ... */

    MLReleaseSymbol(lp, symbol);
}
© 2008 Wolfram Research, Inc.
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team