MLTransferExpression()

int MLTransferExpression(MLINK dst, MLINK src)
从源链接 src 中传递一个表达式到目标链接 dst.

更多信息更多信息

  • dstsrc 不必是不同的.
  • dstsrc 可以是回环或普通的链接.
  • MLTransferExpression() 在错误事件中返回0,如果函数成功则返回非零值.
  • MLTransferExpression() 常用于从链接中读取一个表达式以便于把它存在回环链接中.
  • MLTransferExpression()MathLink 的标头文件 mathlink.h 中被声明.

范例范例打开所有单元关闭所有单元

基本范例 (1)基本范例 (1)

#include "mathlink.h"

/* transfer an expression to link 2 from loopback link 1 */

void f(MLINK lp2, MLINK lp1)
{
    /* send EvaluatePacket[ToExpression[str]] to lp1 */
if(! MLPutFunction(lp1, "EvaluatePacket", 1))
        { /* unable to put function to lp1 */ }

    if(! MLPutFunction(lp1, "ToExpression", 1))
        { /* unable to put function to lp1 */ }

    if(! MLPutString(lp1, "a = Table[RandomInteger[2,12]];"))
        { /* unable to put the string to lp1 */ }

    if(! MLEndPacket(lp1))
        { /* unable to put the end-of-packet indicator to lp1 */ }

    if(! MLFlush(lp1))
        { /* unable to put flush any outgoing data buffered in lp1 */ }

/* now transfer to lp2 from lp1 */
    if(! MLTransferExpression(lp2, lp1))
        { /* unable to transfer an expression from lp1 to lp2 */ }
}
New to Mathematica? Find your learning path »
Have a question? Ask support »