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


int MLNextPacket(MLINK link)
goes to the next packet on link and returns a constant to indicate its head.
  • The following packets can be returned:
BEGINDLGPKTBeginDialogPacket[integer]start a dialog subsession referenced by integer
CALLPKTCallPacket[integer,list]request to invoke the external function numbered integer with arguments list
DISPLAYENDPKTDisplayEndPacket[]obsolete PostScript graphics-related packet
DISPLAYPKTDisplayPacket[]obsolete PostScript graphics-related packet
ENDDLGPKTEndDialogPacket[integer]end the dialog subsession referenced by integer
ENTEREXPRPKTEnterExpressionPacket[expr]evaluate expr
ENTERTEXTPKTEnterTextPacket[string]parse string and evaluate as an expression
EVALUATEPKTEvaluatePacket[expr]evaluate expr while avoiding the kernel main loop
INPUTNAMEPKTInputNamePacket[string]name to be assigned to the next input (usually In[n]:=)
INPUTPKTInputPacket[]prompt for input, as generated by Mathematica's Input[] function
INPUTSTRPKTInputStringPacket[]request input as a string
MENUPKTMenuPacket[integer,string]menu request with title string
MESSAGEPKTMessagePacket[symbol,string]Mathematica message identifier (symbol::string)
OUTPUTNAMEPKTOutputNamePacket[string]name to be assigned to the next output (usually Out[n]=)
RESUMEPKTResumePacket[]obsolete packet
RETURNEXPRPKTReturnExpressionPacket[expr]result of EnterExpressionPacket[] evaluation
RETURNPKTReturnPacket[expr]result of a calculation
RETURNTEXTPKTReturnTextPacket[string]formatted text representation of a result
SUSPENDPKTSuspendPacket[]obsolete packet
SYNTAXPACKETSyntaxPacket[integer]position at which a syntax error was detected in the input line
TEXTPACKETTextPacket[string]text output from Mathematica, as produced by Print[]
  • MLNextPacket() returns ILLEGALPKT in the event of an error. mathlink.h defines ILLEGALPKT as 0.
  • MLNextPacket() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* read the type of the incoming packet on a link */

void f(MLINK lp)
        case CALLPKT:
            /* read the CallPacket[] */
        case EVALUATEPKT:
            /* read the EvaluatePacket[] */
        case RETURNPKT:
            /* read the EvaluatePacket[] */

        /* ... */

        case ILLEGALPKT:
            /* unable to read the next packet from lp */