MathGroup Archive 2005

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

Search the Archive

Re: Batch

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60408] Re: Batch
  • From: albert <awnl at arcor.de>
  • Date: Fri, 16 Sep 2005 03:48:50 -0400 (EDT)
  • Organization: Arcor
  • References: <20050914095734.AD3B7B36B@mfep7.connect.com.au> <dgben0$fls$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

> What I do now is to read the data directories/file names in a loop
> and then I start the calculation. The calculation is performed inside a
> Do, where I generate my tables, save them in the appropriate
> directories, and generate the graphics and save them also in different
> directories.  That works, but this is not a well-organized procedure
> because I have all the calculations inside a very large Do loop, that
> means that my notebook is almost a single large Do cell.

It seem to be quite obvious that you should reorganize your code (everything
that makes up the 'calculation'), so that you have a simple function that
will accept e.g. the filename to work on an the directory to save the
resultas as arguments. Then the body of your loop will only contain the
call of this function for various arguments. If you want to keep the
calculation-code (=funtion-definition) in an extra file, I would agree with
Dave that you should save the function to a package file an load that via
Get[] (or make it a real package and use Needs[]). After all that's what
Mathematica supplies for exactly that purpose. You will find that approach
to be much easier than you might think and it will work much better and be
less error-prone than using the frontend as a substitute for basic
programming techniques.

Whether you run the resulting Get[] + Do[] within the frontend or use the
mathematica-kernel only to do the job is another story...

>     I think it would be much better if I could have my calculation
> inside another notebook and if I call this notebook inside the Do loop.

>     My first try was to have a notebook to read the data file and
> directory names and the call a second notebook. In this notebook I have
> part of my calculation, rather documented and it called the last
> notebook which would finish the calculation and return to the next data.
> In the front end I manage to call the second notebook but it was only
> opened, not evaluated, I have to evaluate it manually. Perhaps the
> problem does not involve batch, but rather one notebook calling and
> evaluating another notebook.

If you really want to use the FrontEnd (which again, I would not recommend)
you can use a combination of NotebokOpen[], SelectionMove[]/NotebookFind[]
and SelectionEvaluate[] to achieve what you want. The following would be a
start:

nb=NotebookOpen["G:\\path\\to\\notebook\\that\\contains\\the\\calculation"];
SelectionMove[nb,All,Notebook];
SelectionEvaluate[nb];

If you need help on this, you should post the code you are using to 'call a
notebook' and you might find people to be able to help you much better...

cheers,

Albert


  • Prev by Date: Re: basic issue with do and :=
  • Next by Date: Re: Batch
  • Previous by thread: Re: Batch
  • Next by thread: Re: Batch