MathGroup Archive 1996

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

Search the Archive

Re: MathLink function: Global variable?

  • Subject: [mg3217] Re: [mg3170] MathLink function: Global variable?
  • From: jfultz (John Fultz)
  • Date: 18 Feb 1996 00:22:24 -0600
  • Approved:
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at

> HI. I am writing a C function with Mathlink.
> I have noticed that global variable stays there after each execution of the 
> function after Install.
> Is this what it supposed to be?
> Is this means that I can keeps some context in C function during Mathematica 
> session?
> ---
> Chang Song (song at

The short answer is yes.

The long answer, which I hope will help you to understand installable
functions a bit better, is to tell you exactly how installable functions

Note that, when you run an installable function, the function called is
MLMain().  MLMain() is a function created by mprep (or SAmprep if you're
on a Mac) that does the following in a continuous loop:

* Wait to receive information from Mathematica
* Reformat the received information and pass it off to the appropriate
  user-written function
* Receive results from the user-written function, reformat it, and send it
  over the link back to Mathematica.
* Wait to receive information from Mathematica again

This is a pretty simplified view of it, but it's essentially how it works.
Note that the program never quits--it continues executing forever and ever,
until it is notified that it should Uninstall itself.  So, there is no
opportunity for global variables to ever be reset, since the program itself
is never reset.


John Fultz
jfultz at
Applications Group
Wolfram Research, Inc.

  • Prev by Date: Re: MathLink function: Global variable?
  • Next by Date: Re: Integrals of Fourier Series
  • Previous by thread: Re: MathLink function: Global variable?
  • Next by thread: How to change ( the blue ) frame color on X front-end ?