|
SOLUTIONS
|
MATHEMATICA MATHLINK C FUNCTION
MLUserData()
void * MLUserData(MLINK link, MLUserFunction *fp)
returns the data object and function pointer installed by MLSetUserData().
DetailsDetails
- MLUserData() is declared in the MathLink header file mathlink.h.
ExamplesExamplesopen allclose all
Basic Examples (1)Basic Examples (1)
#include <stdlib.h>
#include "mathlink.h"
typedef struct foo_ {
int member;
} foo;
int main(int argc, char **argv)
{
MLENV env;
MLINK link;
int error;
foo *fobj;
fobj = (foo *)malloc(sizeof(foo));
if(fobj == (foo *)0)
{ /* unable to allocate memory for foo object */ }
env = MLInitialize((char *)0);
if(env == (MLENV)0)
{ /* unable to initialize MathLink environment */ }
link = MLOpenArgcArgv(env, argc, argv, &error);
if(link == (MLINK)0 || error != MLEOK)
{ /* unable to create link object */ }
MLSetUserData(link, (void *)fobj, (MLUserFunction)0);
/* ... */
fobj = MLUserData(link, (MLUserFunction *)0);
free(fobj);
MLClose(link);
MLDeinitialize(env);
return 0;
}
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »
