MathGroup Archive 2005

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

Search the Archive

Re: Batch

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60525] Re: Batch
  • From: albert <awnl at arcor.de>
  • Date: Mon, 19 Sep 2005 04:45:43 -0400 (EDT)
  • References: <20050916044831.D106BBC36@mfep9.connect.com.au> <dggdur$ggq$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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


  • Follow-Ups:
    • WORD document
      • From: Maria Cristina Dias Tavares <cristina@dsce.fee.unicamp.br>
    • Re: Re: Batch
      • From: Maria Cristina Dias Tavares <cristina@dsce.fee.unicamp.br>
  • 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