MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathlink help needed

  • To: mathgroup at
  • Subject: [mg31047] Re: Mathlink help needed
  • From: Jens-Peer Kuska <kuska at>
  • Date: Sat, 6 Oct 2001 03:32:10 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <9p40vt$5dj$>
  • Sender: owner-wri-mathgroup at

> 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);

:Function: MyInc
:Pattern: MyInc[i_Integer]
:Argumens: {i}
:ArgumentTypes: {Integer}
:ReturnType: Integer

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
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
Mathematica box. It is the heavy pice of paper -- you remember ?
Just read the book.


  • Prev by Date: Re: Stuck in a For Loop
  • Next by Date: Re: Assumptions question (1/m^x,x>1,m=Infinity)
  • Previous by thread: Re: Stuck in a For Loop
  • Next by thread: Write output to file continuously