Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5295
| From | lagj <jean.lagarde@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Order of evaluations in the Kernel, especially related to CellEpilog |
| Date | 2011-09-30 08:03 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j63t43$6d9$1@smc.vnet.net> (permalink) |
| References | <j6121p$m26$1@smc.vnet.net> |
Never mind, I should have realized it was the selection moving around.
I modified my epilog to use the EvaluationCell instead of the current
Cell and everything works as expected now.
On Sep 28, 11:08 pm, lagj <jean.laga...@gmail.com> wrote:
> I'm a bit confused as to the order in which Mathematica queues evaluations in
> the kernel. I have created a new style of input cell with a CellEpilog
> that moves any output (Output or Print type) to a different notebook.
> This works fine when I evaluate cells one at a time, but if I evaluate
> a group containing many of these cells, my CellEpilog seems not to run
> on most of them, and for those cells for which it runs, the order can
> be different in the second notebook (e.g. if I'm evaluating a group
> containing cell1, cell2, cell3 in that order in the "input" notebook,
> the results may appear in the order out1, out3, out2 in the "output"
> notebook). I assumed that the CellEpilog runs immediately after the
> cell is evaluated, but Mathematica seems to be shuffling things around, i.e.
> queuing the CellEpilogs to run together after the main evaluations or
> something like that.As for those cells for which the epilog doesn't
> seem to run, I suspect it does run, but by running out of order the
> selection might be at an unexpected place in the source notebook and
> so my code doesn't find any Output or Print cell to process and does
> nothing.
>
> Any insight appreciated. My CellEpilog code below.
>
> At a higher level, maybe someone can suggest a better idea to achieve
> what I want? I want the option to output the result of some
> evaluations to a different notebook (without having to copy them
> manually). I prefer the source document to be a notebook and not an m
> file because I want to preserve other output in the source notebook
> and want the richness of a notebook document for my source.
>
> (outnb points to the desired output notebook)
>
> Block[{cellData,cellDataList},
> SelectionMove[EvaluationNotebook[], Previous, Cell];
> cellData=NotebookRead[EvaluationNotebook[]];
> Which[Part[cellData,
> 2]=="Output",NotebookWrite[outnb,cellData];
>
> NotebookDelete[EvaluationNotebook[]],
> Part[cellData,2]=="Print",cell=
DataList={cellData};
>
> NotebookDelete[EvaluationNotebook[]];
> =
While[True,
>
> SelectionMove[EvaluationNotebook[],Previous,Cell];
>
> cellData=NotebookRead[EvaluationNotebook[]];
>
> If[Part[cellData,2]=="Print",PrependTo[cellDataList,cellData];
>
> NotebookDelete[EvaluationNotebook[]],
>
> Break[]]];
>
> Map[NotebookWrite[outnb,#]&,cellDataList];
>
Null]]
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Order of evaluations in the Kernel, especially related to CellEpilog lagj <jean.lagarde@gmail.com> - 2011-09-29 06:08 +0000 Re: Order of evaluations in the Kernel, especially related to CellEpilog lagj <jean.lagarde@gmail.com> - 2011-09-30 08:03 +0000
csiph-web