.NET/Link API Version 1.5 USE FRAMES

IMathLink.CreateMark Method 

Creates a mark at the current point in the incoming MathLink data stream.

[Visual Basic]
Function CreateMark() As ILinkMark
ILinkMark CreateMark();


Marks can returned to later, to re-read data. A common use is to create a mark, call some method for reading data, and if a MathLinkException is thrown, seek back to the mark and try a different method of reading the data.

If you create a mark, be sure to call DestroyMark to destroy it, or you will create a memory leak.

One common reason to use a mark is if you want to examine an incoming expression and branch to different code depending on some property of the expression. You want the code that actually handles the expression to see the entire expression, but you will need to read at least a little bit of the expression to decide how it must be handled (perhaps just calling GetFunction to see the head). Here is a code fragment demonstrating this technique:
string head = null;
ILinkMark mark = ml.CreateMark();
try {
    int argc;
    head = ml.GetFunction(out argc);
} finally {
if (head == "foo")
else if (head == "bar")
Note that we use try/finally to ensure that the mark is destroyed even if an exception is thrown.

Some of the usefulness of marks in the C-language MathLink API is obviated by .NET/Link's Expr class.


Exception TypeCondition
MathLinkExceptionOn any MathLink error.

See Also

IMathLink Interface | Wolfram.NETLink Namespace | SeekMark | DestroyMark