OpenersNotesSection(Spacer1)Details

After the call to MLPutFunction() other MathLink functions must be called to send the arguments of the function.

MLPutFunction() 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 MLPutFunction() fails.

MLPutFunction() 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"

/* put an Integrate[] expression to a link */

void f(MLINK lp)
{
	if(! MLPutFunction(lp, "Integrate", 2))
		{ /* unable to put the function to lp */ }

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

	if(! MLPutFunction(lp, "Power", 2))
		{ /* unable to put the function to lp */ }

	if(! MLPutSymbol(lp, "x", 1))
		{ /* unable to put the symbol to lp */ }

	if( ! MLPutInteger(lp, 2))
		{ /* unable to put the integer to lp */ }

	if(! MLPutFunction(lp, "Power", 2))
		{ /* unable to put the function to lp */ }

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

	if(! MLPutSymbol(lp, "x", 1))
		{ /* unable to put the symbol to lp */ }

	if(! MLPutInteger(lp, -1))
		{ /* unable to put the integer to lp */ }

	if(! MLPutSymbol(lp, "x", 1))
		{ /* unable to put the symbol to lp */ }

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

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

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

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}})}})