Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > MathLink C Language Functions >
MathLink C Function

MLGetString()

int MLGetString(MLINK link, const char **s)
gets a character string from the MathLink connection specified by link, storing the string in s.
  • MLGetString() allocates memory for the character string. You must call MLReleaseString() to disown this memory. If MLGetString() fails and the function's return value indicates an error, do not call MLReleaseString() on the contents of s.
  • MLGetString() returns immutable data.
  • MLGetString() creates a string that is terminated by \0.
  • MLGetString() stores single \ characters from Mathematica as pairs of characters \\.
  • MLGetString() stores special characters from Mathematica in a private format.
  • MLGetString() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetString() fails.
  • MLGetString() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* read a string from a link */

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

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

    /* ... */

    MLReleaseString(lp, string);
}
© 2013 Wolfram Research, Inc. Japanese
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team