MathGroup Archive 2005

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

Search the Archive

Re: Batch


Hi,
>     I will just copy a simple code below to describe what I am getting.
> The output in the first notebook is a = a; b = b ; ...

... and I guess that what you want is that a,b,c,... have their numerical
values when evaluating the other notebooks, right?
 
>                     This is the former notebook ;
> Do[
>   {
>      c = 3,
>      nb2 = NotebookOpen["tt1.nb"],
>      SelectionMove[nb2, All, Notebook],
>      Print["k main ", k],
>      SelectionEvaluate[nb2],
>      Print["a = ", a],
>      Print["b = ", b],
>      Print["ac = ", ac],
>      Print["bc = ", bc],
>     },
>   {k, 1, 1}]

I haven't analyzed what exactly goes wrong, but my first guess was that the
scoping of the Do-loop is the reason why k is not known to be 1 in the
other notebooks (and that this is presumably what you don't like). 
And indeed, if you change the code so that k is a global variable, e.g.:

k = 1; 
While[k <= 1,{
   c = 3,
   nb2 = NotebookOpen["tt1.nb"], 
   SelectionMove[nb2, All, Notebook], 
   Print["k main ", k], 
   SelectionEvaluate[nb2], 
   Print["a = ", a], 
   Print["b = ", b], 
   Print["ac = ", ac],
   Print["bc = ", bc], 
   k++
   }]

the code does something that I guess is about what you want to achieve...

hth

Albert


  • Prev by Date: Re: integral to table values
  • Next by Date: Re: probability with simulation
  • Previous by thread: Re: Batch
  • Next by thread: Re: Re: Batch