Re: Mathlink help needed
- To: mathgroup at smc.vnet.net
- Subject: [mg31047] Re: Mathlink help needed
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 6 Oct 2001 03:32:10 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <9p40vt$5dj$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
> I posted a help-needed message earlier on Mathlink. I did not see any
> replies on my questions. So here I simplify my question.
>
> 1) How do I call a user-defined functions in a Mathematica notebook from
> a C-program via Mathlink?
you are a bit lazy reading the documentation ? Right ?
Write a c-program and a template
int MyInc(int i)
{ retturn i++}
int main(int argc, char *argv[]) {
return MLMain(argc,argv);
}
:Begin:
:Function: MyInc
:Pattern: MyInc[i_Integer]
:Argumens: {i}
:ArgumentTypes: {Integer}
:ReturnType: Integer
:End:
use mprep or on a unix box mcc to add the C-functions to
due to your template part.
Compile the output of mprep and use Install["yourCompiledBinary"]
and you will have the usefull functions MyInc[]
>
> 2) How can I envoke "evaluate notebook" from my C-program so I can get
> initial values assigned?
What initial values ? When your function is called from the Mathematica
kernel
you can call back to the kernel. You can also do some call to the
FrontEnd if you have a FrontEnd running. But typical the
kernel pass the parameter to the function if you say MyInc[2]
the kernel will send the 2 to your program, MyInc() will increment it
and send it back to the kernel.
>
> I am very green on Mathematica and Mathlink, so any help is appreciated.
>
You can change this -- there is a big book "The Mathematica Book" in
your
Mathematica box. It is the heavy pice of paper -- you remember ?
Just read the book.
Regards
Jens