Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

Re: MathLink function: Global variable?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3217] Re: [mg3170] MathLink function: Global variable?
  • From: John Fultz <jfultz>
  • Date: Sat, 17 Feb 1996 14:18:10 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

> 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 cs.purdue.edu)

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
execute.

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.

Sincerely,

John Fultz
jfultz at wolfram.com
Applications Group
Wolfram Research, Inc.

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: What is Mathmatica
  • Next by Date: Re: MathLink function: Global variable?
  • Previous by thread: MathLink function: Global variable?
  • Next by thread: Re: MathLink function: Global variable?