MLGetData (C 関数)
MLGetDataはWSGetDataに置き換えられた.
int MLGetData(MLINK link,char *b,int len,int *count)
link で指定されたMathLink接続からテキストデータを得て,結果を最長len のバッファb に,実際に読み込んだバイト数をcount に保持しておく.
詳細

- MLGetData()はb を割り当てない.b は供給されなければならない.
- MLGetData()はエラーがあると0を返し,関数が成功すると0以外の値を返す.
- MLError()を使うと,MLGetData()が不成功の場合にエラーコードを引き出すことができる.
- MLGetData()は,MathLinkヘッダファイルmathlink.hの中で宣言される.
例題
例 (1)
#include "mathlink.h"
/* read data from a link in textual form */
void f(MLINK lp)
{
int size, count;
char *buff;
switch(MLGetType(lp))
{
case MLTKSTR:
if(! MLBytesToGet(lp, &size))
{
/* unable to read the number of bytes from lp */
return;
}
buff = (char *)malloc(size * sizeof(char));
if(buff == (char *)0)
{
/* unable to allocate mmemory */
return;
}
if(! MLGetData(lp, buff, size &count))
{
/* unable to read the string data from lp */
free(buff);
return;
}
/* ... */
free(buff);
break;
}
/* ... */
}