CellProlog

CellProlog

is an option to Cell that gives an expression to evaluate before each ordinary evaluation of the contents of the cell.

Details

  • CellProlog:>expr evaluates expr for every ordinary kernel evaluation done in the cell, as initiated for example by TemplateBox[{shift, return}, Key1, BaseStyle -> {Notes, FontWeight -> Plain, FontFamily -> Source Sans Pro}] or by Evaluate in Place.
  • CellProlog is not evaluated for evaluations associated with Dynamic objects.
  • The default setting is CellProlog->None.
  • CellProlog is often set at a style or notebook level, rather than for individual cells.

Examples

open allclose all

Basic Examples  (1)

Set the option CellProlog:>(x=42) on the second input cell in this example:

Though the variable x has not yet been set, it acquires the value 42 upon the evaluation of the input:

Applications  (2)

Set options on a cell to numericize output from a particular input cell using $Post:

This cell produces a numerical result:

Other cells are not affected:

Rules for setting up local package contexts for a cell:

Newly created symbols in the following cell will be in the context "c1`":

Wolfram Research (2007), CellProlog, Wolfram Language function, https://reference.wolfram.com/language/ref/CellProlog.html.

Text

Wolfram Research (2007), CellProlog, Wolfram Language function, https://reference.wolfram.com/language/ref/CellProlog.html.

CMS

Wolfram Language. 2007. "CellProlog." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CellProlog.html.

APA

Wolfram Language. (2007). CellProlog. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CellProlog.html

BibTeX

@misc{reference.wolfram_2023_cellprolog, author="Wolfram Research", title="{CellProlog}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/CellProlog.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_cellprolog, organization={Wolfram Research}, title={CellProlog}, year={2007}, url={https://reference.wolfram.com/language/ref/CellProlog.html}, note=[Accessed: 19-March-2024 ]}