OpenersNotesSection(Spacer1)Details

MLTestString() fails if the current object on the link is not a string, or if the value of the string does not match s.

MLTestString() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[MLError(), paclet:/ref/c/MLError]) to retrieve the error code if MLTestString() fails.

MLTestString() will reset the stream pointer to the expression on the link just prior to calling MLTestString()if the function fails. This operation behaves as if the programmer called MLCreateMark(link); MLTestString(…); MLSeekToMark(…).

MLTestString() is declared in the MathLink header file (RefLink[mathlink.h, paclet:/ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

/* A function for testing the next expression on the link for a string */

void f(MLINK l)
{
	if(! MLTestString(l, "$Version"))
	{ /* The next expression on the link is not $Version */ }
	else
	{ /* The next expression on the link is $Version */ }
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLTestUCS2String(), paclet:/ref/c/MLTestUCS2String])  ▪  (NonWLLink[MLTestUTF16String(), paclet:/ref/c/MLTestUTF16String])  ▪  (NonWLLink[MLTestUTF32String(), paclet:/ref/c/MLTestUTF32String])  ▪  (NonWLLink[MLTestUTF8String(), paclet:/ref/c/MLTestUTF8String])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays, and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}})}})