MLGetString (C Function)

MLGetString has been replaced by WSGetString.

int MLGetString(MLINK link,const char **s)

gets a character string from the MathLink connection specified by link, storing the string in s.

Details

  • 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 the Wolfram Language as pairs of characters .
  • MLGetString() stores special characters from the Wolfram Language 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.

Examples

Basic Examples  (1)

#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);
}