Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8330 > unrolled thread

Re: Initialization Cells Not Evaluated When Notebook Saved to CDF

Started byJohn Fultz <jfultz@wolfram.com>
First post2012-02-04 11:31 +0000
Last post2012-02-05 11:04 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Initialization Cells Not Evaluated When Notebook Saved to CDF John Fultz <jfultz@wolfram.com> - 2012-02-04 11:31 +0000
    Re: Initialization Cells Not Evaluated When Notebook Saved to CDF David Reiss <dbreiss@gmail.com> - 2012-02-05 11:04 +0000

#8330 — Re: Initialization Cells Not Evaluated When Notebook Saved to CDF

FromJohn Fultz <jfultz@wolfram.com>
Date2012-02-04 11:31 +0000
SubjectRe: Initialization Cells Not Evaluated When Notebook Saved to CDF
Message-ID<jgj4ud$mva$1@smc.vnet.net>
Actually, I'll bet that it does *not* work in Mathematica.  Which is to say that if you do nothing more than open the CDF file in a freshly started session of 
Mathematica, you'll get the same breakages.

CDF files which you expect to deploy cannot rely on Shift+Enter evaluations to 
prime the pump.  You need to make sure that all of the code dependencies are in 
the dynamic evaluations somewhere.  Some possible ways of doing this, all of
which have been discussed at various points on MathGroup, include:

* Using the Initialization option of Dynamic, DynamicModule, or Manipulate
* Using the SaveDefinitions option of Manipulate
* Adding code to the NotebookDynamicExpression option of the notebook (if it's 
initialization code, then wrapped in Refresh[#,None]& to prevent it from 
evaluating more than once per session).
* Not such a good idea for function definitions, but if you simply have code
that needs to run before Dynamic code runs, nesting a DynamicWrapper around it 
might be appropriate, too.

Sincerely,

John Fultz
jfultz@wolfram.com
User Interface Group
Wolfram Research, Inc.

On Fri, 3 Feb 2012 02:11:15 -0500 (EST), Gregory Lypny wrote:
> Hello everyone,
>
> I've saved a notebook to CDF.  It has a number of initialization
> cells.  The functions and values of the variables that have been
> initialized are then used or displayed in other cells that make use of
> Dynamic[].  The notebook works fine when opened in Mathematica but in
> the CDF Player, most of the cells with results display errors because
> functions and variables have not been initialized.  What am I doing
> wrong?
>
> Gregory

[toc] | [next] | [standalone]


#8353

FromDavid Reiss <dbreiss@gmail.com>
Date2012-02-05 11:04 +0000
Message-ID<jglnns$2cv$1@smc.vnet.net>
In reply to#8330
I really need to review the list of functions that are new in version
8.  I hadn't been aware of the NotebookDynamicExpression function and
related ones.  And the approach that you describe to execute code upon
opening a notebook serves to complement the lack of a "WindowOpen"
event for the NotebookEventActions -> "WindowClose" event.  So this
then begs the question of why there isn't a "WindowOpen" event
defined.  Just curious....

Thanks!
--David


On Feb 4, 6:31 am, John Fultz <jfu...@wolfram.com> wrote:
> Actually, I'll bet that it does *not* work in Mathematica.  Which is to say that if you do nothing more than open the CDF file in a freshly started session of
> Mathematica, you'll get the same breakages.
>
> CDF files which you expect to deploy cannot rely on Shift+Enter evaluations to
> prime the pump.  You need to make sure that all of the code dependencies are in
> the dynamic evaluations somewhere.  Some possible ways of doing this, all of
> which have been discussed at various points on MathGroup, include:
>
> * Using the Initialization option of Dynamic, DynamicModule, or Manipulate
> * Using the SaveDefinitions option of Manipulate
> * Adding code to the NotebookDynamicExpression option of the notebook (if it's
> initialization code, then wrapped in Refresh[#,None]& to prevent it from
> evaluating more than once per session).
> * Not such a good idea for function definitions, but if you simply have code
> that needs to run before Dynamic code runs, nesting a DynamicWrapper around it
> might be appropriate, too.
>
> Sincerely,
>
> John Fultz
> jfu...@wolfram.com
> User Interface Group
> Wolfram Research, Inc.
>
>
>
>
>
>
>
> On Fri, 3 Feb 2012 02:11:15 -0500 (EST), Gregory Lypny wrote:
> > Hello everyone,
>
> > I've saved a notebook to CDF.  It has a number of initialization
> > cells.  The functions and values of the variables that have been
> > initialized are then used or displayed in other cells that make use of
> > Dynamic[].  The notebook works fine when opened in Mathematica but in
> > the CDF Player, most of the cells with results display errors because
> > functions and variables have not been initialized.  What am I doing
> > wrong?
>
> > Gregory

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web