WSNextPacket (C Function)
int WSNextPacket(WSLINK link)
goes to the next packet on link and returns a constant to indicate its head.
Details
- The following packets can be returned:
-
BEGINDLGPKT BeginDialogPacket[integer] start a dialog subsession referenced by integer CALLPKT CallPacket[integer,list] request to invoke the external function numbered integer with arguments list DISPLAYENDPKT DisplayEndPacket[] obsolete PostScript graphics-related packet DISPLAYPKT DisplayPacket[] obsolete PostScript graphics-related packet ENDDLGPKT EndDialogPacket[integer] end the dialog subsession referenced by integer ENTEREXPRPKT EnterExpressionPacket[expr] evaluate expr ENTERTEXTPKT EnterTextPacket[string] parse string and evaluate as an expression EVALUATEPKT EvaluatePacket[expr] evaluate expr while avoiding the kernel main loop INPUTNAMEPKT InputNamePacket[string] name to be assigned to the next input (usually In[n]:=) INPUTPKT InputPacket[] prompt for input, as generated by the Wolfram Language's Input[] function INPUTSTRPKT InputStringPacket[] request input as a string MENUPKT MenuPacket[integer,string] menu request with title string MESSAGEPKT MessagePacket[symbol,string] Wolfram Language message identifier (symbol::string) OUTPUTNAMEPKT OutputNamePacket[string] name to be assigned to the next output (usually Out[n]=) RESUMEPKT ResumePacket[] obsolete packet RETURNEXPRPKT ReturnExpressionPacket[expr] result of EnterExpressionPacket[] evaluation RETURNPKT ReturnPacket[expr] result of a calculation RETURNTEXTPKT ReturnTextPacket[string] formatted text representation of a result SUSPENDPKT SuspendPacket[] obsolete packet SYNTAXPKT SyntaxPacket[integer] position at which a syntax error was detected in the input line TEXTPKT TextPacket[string] text output from the Wolfram Language, as produced by Print[] - WSNextPacket() returns ILLEGALPKT in the event of an error. wstp.h defines ILLEGALPKT as 0.
- WSNextPacket() is declared in the WSTP header file wstp.h.
Examples
Basic Examples (1)
#include "wstp.h"
/* read the type of the incoming packet on a link */
void f(WSLINK lp)
{
switch(WSNextPacket(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 */
}
}