Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

FrontEnd trouble



The following behaviour of Mathematica 3.0 FrontEnd is surprising and
quite annoying:

In a notebook I define a button, the purpose of which is to start or
stop a MathLink link; the button changes when clicked: green with
"Start link" text on it, red with "Stop link" on it; as far as this
button is not standard, I need to edit it in the "Show Expression" mode
(CTRL-Shift-E. This is the button:

Cell[BoxData[
    ButtonBox[
      RowBox[{"Starts", " ", "link"}],

tonFunction:>CompoundExpression[ 
          Get[ "StartsEndsButton`"],
StartsEndsButton`StartsEndsFunction, externalFunction],
      ButtonEvaluator->Automatic,
      ButtonData:>"should changes its color",
      Active->True,
      ButtonStyle->None,
      Background->RGBColor[0, 1, 0],
      ButtonNote->"changes its color when clicked"]], "Input",
  CellLabel->"In[3]:=",
  Editable->False,
  Evaluatable->False,
  GeneratedCell->True,
  CellTags->"StartsEndsButton"]

To fully understand the question, I precise that StartsEndsButton is a
package with a unique function called StartsEndsFunction. The package
has been tested Okay. "externalFunction" stands for a function defined
in the Global` context. The Button evaluator is the Kernel, not the
FrontEnd.

To test the button, I start a new kernel,  define the working directory
(because the package is not yet referenced in $Path or in the
Applications Directory), evaluate the definition of the external
function and finally click on my button. Wonderful, its WORKS! Let's
save everything and have a cup of tea. BUT if now I want to have a look
at the Mathematica expression of the button, I get:

Cell[BoxData[
    (etc.) 
          Get[ "StartsEndsButton`"], StartsEndsFunction,
externalFunction],
      (etc.)]

which means that next time I will start a new kernel, set the working
directory, etc. and press the button, I will get an error message
because the kernel will define StartsEndsFunction in the global context
before reading the package (I have had a look at the note in The
Mathematica Book Section 2.6.10 that explains the mechanism of order of
creation of symbols).

My questions are now:
1- A FrontEnd question : Why does the cell associated with the button is
modified, even when the cell is not editable; and who did it (the
Kernel, the FrontEnd), according to which rules, and when ?  2- A
general programming question : In case I could not get an answer to the
previous question, how can I write a function that reads a package and
calls a function in the package context all at the same time?

With many thanks,


**************************************** Jean-Marie THOMAS
Conseil et Audit en Inginierie de Calcul Strasbourg, France
**************************************** 




  • Prev by Date: Front End Message
  • Next by Date: Trying to plot "fuzzy" values vs time
  • Prev by thread: Front End Message
  • Next by thread: Trying to plot "fuzzy" values vs time