MLNextPacket (C Function)

MLNextPacket has been replaced by WSNextPacket.

int MLNextPacket(MLINK link)

goes to the next packet on link and returns a constant to indicate its head.

Details

  • 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 the Wolfram Language's Input[] function
    INPUTSTRPKTInputStringPacket[]request input as a string
    MENUPKTMenuPacket[integer,string]menu request with title string
    MESSAGEPKTMessagePacket[symbol,string]Wolfram Language 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
    SYNTAXPKTSyntaxPacket[integer]position at which a syntax error was detected in the input line
    TEXTPKTTextPacket[string]text output from the Wolfram Language, 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.

Examples

Basic Examples  (1)

#include "mathlink.h"

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

void f(MLINK lp)
{
    switch(MLNextPacket(lp))
    {
        case CALLPKT:
            /* read the CallPacket[] */
            break;
        case EVALUATEPKT:
            /* read the EvaluatePacket[] */
            break;
        case RETURNPKT:
            /* read the EvaluatePacket[] */

        /* ... */

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