[Date Index]
[Thread Index]
[Author Index]
Re: How do I script the evaluation of a Notebook
*To*: mathgroup at smc.vnet.net
*Subject*: [mg30535] Re: [mg30515] How do I script the evaluation of a Notebook
*From*: Andrzej Kozlowski <andrzej at tuins.ac.jp>
*Date*: Tue, 28 Aug 2001 04:54:39 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
Although I find it difficult to imagine why you wish to do such a
strange thing (which makes me suspect that I might be misunderstanding
you) here is one way to do what you seem to be asking for. I will
illustrate it on an example. I guess its easiest to describe by an
example. I have currently opened before me two mathematica windows. The
function Notebooks[] returns a list of allopen notebooks:
In[1]:=
Notebooks[]
Out[1]=
{NotebookObject[<<Untitled-2>>], NotebookObject[<<Untitled-1>>],
NotebookObject[<<Messages>>]}
So we see that there are three opened notebooks, Untitled-2,Untitled-1
and Messages. I have put expressions I want to evaluate in Untitled-1
and I will evaluate the command that tells the kernel to evaluate them
in Untitled-2 (to avoid an infinite loop). So first, in Untitled-2 I
create a notebook object that can be handled by the kernel:
In[2]:=
nb=Notebooks[][[2]]
Out[2]=
NotebookObject[<<Untitled-1>>]
Now I will tell the kernel to evaluate the NotebookObject nb five times.
Again this is done in Untitled-2:
Do[FrontEndExecute[{FrontEndToken[nb, "EvaluateNotebook"]}], {5}]
This will happen so fast you want notice any difference unless you chose
your code in Untitled-1 in such a way as to get a different answer each
time. For example if you just have the single function Random[] and make
sure that Untitled-1 stays visible (is not covered by Untitled-2) you
will see the value in the output cell changing very fast.
Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/
On Saturday, August 25, 2001, at 09:58 AM, Matthew D. Langston wrote:
> How do I script the evaluation of a Notebook?
>
> I'd like to programmatically evaluate a Notebook multiple times in a
> loop.
> Although I don't know how to write it, here is the Mathematic
> pseudo-code
> that I'd like to learn how to write:
>
> nb = NotebookOpen["foo.nb"]
> Do[NotebookEvaluate[nb], {myVar,4}]
>
> I made up the name "NotebookEvaluate" because it is not a real
> Mathematica
> function, but it does describe what I want to do. Is there a function
> in
> Mathematica that takes a Notebook expression and evaluate the entire
> Notebook? Thanks for your help.
>
> Regards, Matt
>
> --
> Matthew D. Langston
> SLD, Stanford Linear Accelerator Center
> langston at SLAC.Stanford.EDU
>
>
>
Prev by Date:
**RE: Collecting multiple function arguments into a List?**
Next by Date:
**Re: Lines in a legend are too short**
Previous by thread:
**How do I script the evaluation of a Notebook**
Next by thread:
**Re: How do I script the evaluation of a Notebook**
| |