MathGroup Archive 2002

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

Search the Archive

Re: Notebook manipulation

  • To: mathgroup at
  • Subject: [mg32974] Re: [mg32824] Notebook manipulation
  • From: Dale Horton <daleh at>
  • Date: Fri, 22 Feb 2002 01:49:00 -0500 (EST)
  • Sender: owner-wri-mathgroup at

At 12:43 AM 2/14/2002, Roger Mason wrote:
>Firstly, thanks to Paul Hinton of WRI for his help with my last
>Secondly, I have been attempting to use the notebook manipulation
>functions to get some output written into a notebook that is created by
>the kernel. The idea is then to save or print the new notebook. By
>following section 2.10.3 of the on-line help, I have been able to write
>data into the new notebook and perform evaluation on the data. However,
>on saving or printing the new notebook the output cells are never
>Clearly, I am missing something. What am I doing wrong? Some code is
>Roger Mason.
>Mathematica 4.0, Linux RH7.0.
>nb = NotebookCreate[];
>(*nb = SelectedNotebook[];*)
>NotebookWrite[nb, "10!", All];
>SelectionEvaluateCreateCell[nb, All];
>NotebookApply[nb, "\[SelectionPlaceholder]/2", All ];
>SelectionEvaluateCreateCell[nb, Before];
>NotebookSave[nb, "notebook.nb"];
>(*NotebookPrint[nb, "/home/rmason/",
>       PrintingStyleEnvironment -> "Printout"];*)

Just because SelectionEvaluateCreateCell comes before NotebookSave, it 
doesn't mean that the actual evaluation occurs before the NotebookSave.


SelectionEvaluateCreateCell is like a Shift-Enter. It queues the 
evaluation, but there's already an evaluation in the kernel (the code 
you're running). NotebookSave and NotebookClose are frontend operations, 
however, and do not wait for the kernel. They act immediately. So the stuff 
in nb isn't set to evaluate until after your code is done, but by then nb 
is already saved and closed.


  • Prev by Date: Re: Getting Coordinates from plot
  • Next by Date: Re: Getting Coordinates from plot
  • Previous by thread: Re: Notebook manipulation
  • Next by thread: simulating random variables