3

Suppose that an expression like

f[something, 12]

was sent to a MathLink link, and we need to read off only the second part of f, which has a known type (e.g. integer). How can the first part, something, be discarded? something could be an atomic or compound expression of any kind. I need to do this in C.

Example:

int argc = 2;
if (! MLTestHeadWithArgCount(link, "f", &argc)) {
   // fail
}

// how do I discard the complete next expression here, whether it's atomic or compound?

int i;
MLGetInteger32(link, &i); // get the integer
Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263

1 Answers1

3

Based on Todd Gayley's response here and trying it out, it can be done using

MLTransferExpression(NULL, link)

This will remove one complete (sub)expression form the link.

The code for the example from the question would be

int argc = 2;
if (! MLTestHeadWithArgCount(link, "f", &argc)) {
   // fail
}

MLTransferExpression(NULL, link);

int i;
MLGetInteger32(link, &i); // get the integer
Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263