OpenersNotesSection(Spacer1)Details

MLEndPacket() should be called to indicate the end of any top-level expression, regardless of whether its head is a standard packet.

MLEndPacket() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[MLError(), paclet:ref/c/MLError]) to retrieve the error code if MLEndPacket() fails.

MLEndPacket() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

/* send the expression {10, Times[3.56, 10], 1.3} to a link */

void f(MLINK lp)
{
	if(! MLPutFunction(lp, "List", 3))
		{ /* unable to send the function List to lp */ }

	if(! MLPutInteger32(lp, 10))
		{ /* unable to send the integer 10 to lp */ }

	if(! MLPutFunction(lp, Times, 2))
		{ /* unable to send the function Times to lp */ }

	if(! MLPutReal64(lp, 3.56))
		{ /* unable to send the double 3.56 to lp */ }

	if(! MLPutInteger32(lp, 10))
		{ /* unable to send the integer 10 to lp */ }

	if(! MLPutReal32(lp, 1.3))
		{ /* unable to send the float 1.3 to lp */ }

	if(! MLEndPacket(lp))
		{ /* unable to send the end of packet message to lp */ }
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLPutFunction(), paclet:ref/c/MLPutFunction])  ▪  (NonWLLink[MLFlush(), paclet:ref/c/MLFlush])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Two-Way Communication with External Programs, paclet:tutorial/TwoWayCommunicationWithExternalPrograms])}, {▪(RefLinkPlain[Running the Wolfram System from Within an External Program, paclet:tutorial/RunningTheWolframSystemFromWithinAnExternalProgram])}})}})