MLTestHead (C 函数)
MLTestHead 已经被 WSTestHead 所取代.
int MLTestHead(MLINK link,const char *head,int *n)
检验从 link 中读取的下一个对象是否是一个具有标头 head 的表达式,并把表达式的自变量数存在 n 中.
更多信息
![](Files/MLTestHead.zh/details_1.png)
- 如果链接中的当前对象不是一个以符号作为标头的函数或如果符号的名称不匹配 head,MLTestHead() 会失败.
- MLTestHead() 在错误事件中返回0,如果函数成功则返回非零值.
- 如果 MLTestHead() 失败,则使用 MLError() 检索错误代码.
- MLTestHead() 在 MathLink 的标头文件 mathlink.h 中被声明.
范例
基本范例 (1)
#include "mathlink.h"
/* test whether the head of the incoming object is "ReturnPacket" */
void f(MLINK lp)
{
int args;
if(MLTestHead(lp, "ReturnPacket", &args))
{ /* read the contents of the ReturnPacket[] */ }
else
{ /* the head of incoming packet is not "ReturnPacket" */ }
}