Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The following represents an abbreviated example of more complicated code, but it replicates a problem the more complicated code encounters.

f[x_, y_] := Module[{o1, o2},
  o1 = 2 x;
  o2 = 3 y;
  Column[{o1, Button["Save data to file", w = Print[o2], Method -> "Queued"]}, Frame -> True]]

z = "";
Grid[{{"input1", InputField[Dynamic[x]]},{"input2", InputField[Dynamic[y]]},{"A button", Button["Evaluate", z = f[x, y], Method -> "Queued"]}},Frame -> True]

Dynamic[z]

I put this code in an InitializationCell.

When I launch the notebook containing this initialized cell either directly by clicking on the notebook's icon or by selecting it from Mathematica's File >> Open... menu, the notebook runs the code on startup as one would expect:

enter image description here

BUT....

When using OS X, Mathematica 9, by default launches a "Welcome to Wolfram Mathematica 9" display.

enter image description here

If I select the same notebook from the above (by clicking on the correct "Open recent ...." selections) the InitializationCell fails to run when the notebook opens. What gives?

I can certainly choose not to launch anything from this apparently problematic Welcome screen, but this presents a larger problem if one needs to deploy a Mathematica application to some end user over whom's environment one doesn't have complete control.

This kind of inconsistency does not help an end user's confidence in the platform.

Can anyone explain why this happens?

Does this Welcome screen point to a cached version of the notebook for which it thinks the initialization cells have already run? But remember that this only happens when launching Mma.

Can one set anything in a notebook or in the Options Inspector to stop this from happening?

share|improve this question
1  
FWIW: On my system initialization cells are never evaluated on opening a notebook. I wasn't even aware of the possibility. From the documentation: "Additional front end options determine the precise behavior of initialization cells when a notebook is opened." So I guess you should not rely on this behavior when deploying your code anyway. –  sebhofer Jan 30 '13 at 10:02
    
@sebhofer -- I'd like to see (or help to develop) a clear set of best practices for deployment of Mma applications. Something along the excellent FAQ Writing Packages at mathematica-users.org, but covering all configuration requirements. Packages and init.m files cover much of this, but I wonder if one really needs installation code in addition to these. Maybe one could do this as part of a package, but one can get into trouble if one's application requires configuration changes that conflict with an end users other needs. Shouldn't an Mma application stand on its own -- complete? –  Jagra Jan 30 '13 at 13:59
    
@sebhofer - I believe that you can set InitializationCellEvaluation to True in the Options Inspector to automatically prompt to evaluate initialization cells when a notebook is opened. –  KAI Jan 30 '13 at 18:24
3  
I have never experienced initialization cells automatically evaluating when a notebook opened on any version of Mathematica, and I hope I never do. It would be a security nightmare. Were you to send me a notebook that did automatic evaluation on being opened, I would classify you as a hacker and never accept anything from you on my system again. –  m_goldberg Jan 30 '13 at 19:24
    
@m_goldberg -- Why would Mathematica automatically evaluating initialization cells constitute any more of a security nightmare than any other application that you launch? Any application with a GUI runs code on startup (probably a lot of code). I use auto evaluating initialization cells to run interface code for end users of very controlled applications. This seems a perfectly legitimate use of the technology. I think the question really goes to whom or to what institutions one trusts to supply safe code. –  Jagra Jan 31 '13 at 1:38

1 Answer 1

up vote 1 down vote accepted

I reported this to Wolfram. They reproduced the problem, acknowledged it as a bug, and passed it upstream as a developer report. The developers will get back to me when they resolve the issue. They also don't see any configuration setting solutions or workarounds.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.