MLBytesToGet (C 関数)
MLBytesToGetはWSBytesToGetに置き換えられた.
int MLBytesToGet(MLINK link,int *n)
現行データのテキスト表現の中で読み取るのに残されたバイト数を計算し,その結果をn に保存する.
詳細

- MathLinkは,リンク上の読み取り可能なデータをその進行中のリンク表示以外のタイプに変換することができる. MLBytesToGet() は現行データを文字列表示に変換する.
- MLBytesToGet()はエラーがあると0を返し,関数が成功すると0以外の値を返す.
- MLError()を使うと, MLBytesToGet() が不成功の場合にエラーコードを引き出すことができる.
- MLBytesToGet()は,MathLinkヘッダファイル mathlink.hの中で宣言される.
例題
例 (1)
#include <stdlib.h>
#include <string.h>
#include "mathlink.h"
/* check the incoming string size to allocate enough memory to store the string */
void f(MLINK lp)
{
int incoming_bytes;
char *string;
const char *mlstring;
switch(MLGetType(lp))
{
case MLTKSTR:
if(! MLBytesToGet(lp, &incoming_bytes))
{ /* unable to get the size of the string */ }
string = (char *)malloc(incoming_bytes + 1);
if(string == (char *)0)
{ /* memory allocation failed */ }
if(! MLGetString(lp, &mlstring))
{ /* unable to get the string from lp */ }
memcpy(string, mlstring, incoming_bytes);
*(string + incoming_bytes) = '\0';
break;
/* ... */
};
/* ... */
}