This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
MathLink C Function


int MLTransferToEndOfLoopbackLink(MLINK d, MLINK s)
transfers the full contents of the loopback link s to the destination link d.
  • s and d should be distinct.
  • s must be a loopback link, while d may be a loopback link or an ordinary link.
  • MLTransferToEndOfLoopbackLink() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • MLTransferToEndOfLoopbackLink() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* build up an expression on a loopback link and send that expression to a second link */

void f(MLINK lp1, MLINK lp2)
    if(! MLPutFunction(lp1, "EvaluatePacket", 1))
        { /* unable to put the function to lp1 */ }

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

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

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

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

    if(! MLTransferToEndOfLoopbackLink(lp2, lp1))
        { /* unable to transfer all the data from lp1 to lp2 */ }