MLEvaluateString (C 函数)

MLEvaluateString 已经被 WSEvaluateString 所取代.

int MLEvaluateString(MLINK link,char *string)

发送一个字符串给 Wolfram 语言进行计算,放弃响应中发送的任何数据包.

更多信息

  • MLEvaluateString() 的代码没有包含在 MathLink 程序库中,但是由 mccmprep 在处理 MathLink 模板文件时自动生成.
  • 会导致 被打印在链接的另一端的一个 Mathematica 会话中.
  • MLEvaluateString() 只可用于 mprep MathLink 模板 程序中.
  • MLEvaluateString() 失败时返回0,成功时返回非零值.
  • MLEvaluateString() 在 MathLink 的标头文件 mathlink.h 中被声明.

范例

基本范例  (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))
    {
        /* ... */
    }

    /* ... */    
}