Re: Batch evaluation of multiple notebooks?
- To: mathgroup at smc.vnet.net
- Subject: [mg69331] Re: Batch evaluation of multiple notebooks?
- From: "Blackadder" <Malte at t-online.de>
- Date: Thu, 7 Sep 2006 04:30:32 -0400 (EDT)
- References: <edjhj7$m01$1@smc.vnet.net><edm1od$cpq$1@smc.vnet.net>
Thanks a lot, worked like a charm! The fine thing about this method is that control over the evaluation and closing of each notebook completely remains within the main loop. I came up with another idea that will cause the notebooks to be evaluated in sequential order. The main notebook contains a list of files to process, say "fileList" and an integer index pointer to this list, called "currFileIdx" . Now you define a function "excuteNotebook" like this: executeNotebook[fname_String] := Module[{}, If[currFileIdx<Length[fileList], openNotebook = NotebookOpen[fname, Visible -> True]; SelectionMove[openNotebook, After, Notebook]; NotebookWrite[openNotebook, "currFileIdx++;executeNotebook[fileList[[currFileIdx]]];"]; SelectionMove[openNotebook, All, Notebook]; SelectionEvaluate[openNotebook]; ]; ]; This function appends the command to evaluate the next notebook to the one that is currently active. You thus build up a chain of evaluations where each notebook calls the next one to be evaluated. This works ok, too, but Roland's version is way more elegant and presumably safer. Best wishes, Malte -- Roland Franzius schrieb: > The good old semaphore technics from mainframe times: > > Let each Notebook create a "I am finished (nr xx).txt" file and hold the > main loop idling before executing the next notebook until the expected > file does show up to exist. > > -- > > Roland Franzius