OpenersNotesSection(Spacer1)Details

MLNewPacket() works even if the head of the current top-level expression is not a standard packet type.

MLNewPacket() does nothing if you are already at the end of a packet.

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

Use MLError() to retrieve the error code if MLNewPacket() fails.

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

/* read the next number from a link and ignore everything else */

void f(MLINK lp)
{
	/* determine the type of the data on the link */
	switch(MLGetType(lp))
	{
		case MLTKINT:
			/* integer data */
			break;
		case MLTKREAL:
			/* floating point data */
			break;
		default:
			/* Skip to the next packet if not a number. */
			if(! MLNewPacket(lp))
				{ /* unable to jump ahead to the next packet on lp */ }
	}
}

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

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Running the Wolfram System from within an External Program, paclet:tutorial/RunningTheWolframSystemFromWithinAnExternalProgram])}, {▪(RefLinkPlain[Error and Interrupt Handling, paclet:tutorial/ErrorAndInterruptHandling])}})}})