MLEvaluateString()

int MLEvaluateString(MLINK link, char *string)
sends a string to Mathematica for evaluation, and discards any packets sent in response.

DetailsDetails

  • The code for MLEvaluateString() is not included in the MathLink library, but is generated automatically by mcc or mprep in processing MathLink template files.
  • will cause to be printed in a Mathematica session at the other end of the link.
  • MLEvaluateString() is only available for use in mprep MathLink template programs.
  • MLEvaluateString() returns 0 on failure and a nonzero value on success.
  • MLEvaluateString() is declared in the MathLink header file mathlink.h.

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

:Begin:
:Function: f
:Pattern: KernelTime[]
:Arguments: {}
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

#include "mathlink.h"

/* read the Kernel's response from evaluating the expression
{Date[],$TimeZone} */

void f(void)
{
    /* Pretend we are not in our local timezone. */
    if(! MLEvaluateString(stdlink, "$TimeZone = 9;"))
        { /* unable to send $TimeZone = 9; to stdlink */ }

    if(! MLEvaluate(stdlink, "{Date[],$TimeZone}"))
        { /* unable to send the expression to stdlink */ }

    /* get the Kernel's response */
    switch(MLGetType(stdlink))
    {
        /* ... */
    }

    /* ... */    
}
New to Mathematica? Find your learning path »
Have a question? Ask support »