OpenersNotesSection(Spacer1)Details

A raw backslash in the string must be sent as two characters '∖∖'.

Special characters can be sent only using the format returned by (NonWLLink[MLGetString(), paclet:ref/c/MLGetString]).

The encoding normally used is the same as for (NonWLLink[MLGetString(), paclet:ref/c/MLGetString]).

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

MLPutString() 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 a string representing an expression to a Mathematica kernel
   for evaluation */

void f(MLINK lp)
{
    /* construct the packet to be sent to the kernel */
	MLPutFunction(lp, "EvaluatePacket", 1);
    MLPutFunction(lp, "ToExpression", 1);
    MLPutString(lp, (const char *)"3+4/Sqrt[19.2]");
    MLEndPacket(lp);

    /* send the packet */
	if(! MLFlush(lp))
		{ /* unable to flush an outgoing data buffered in lp */ }

}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLPutByteString(), paclet:ref/c/MLPutByteString])  ▪  (NonWLLink[MLPutUCS2String(), paclet:ref/c/MLPutUCS2String])  ▪  (NonWLLink[MLPutUTF8String(), paclet:ref/c/MLPutUTF8String])  ▪  (NonWLLink[MLPutUTF16String(), paclet:ref/c/MLPutUTF16String])  ▪  (NonWLLink[MLPutUTF32String(), paclet:ref/c/MLPutUTF32String])  ▪  (NonWLLink[MLPutSymbol(), paclet:ref/c/MLPutSymbol])}})}})

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