|
SOLUTIONS
|
MATHEMATICA MATHLINK C 関数
MLGetData()
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)例 (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;
}
/* ... */
}
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »
