13.07.2015 Views

Mathematica Tutorial: Notebooks And Documents - Wolfram Research

Mathematica Tutorial: Notebooks And Documents - Wolfram Research

Mathematica Tutorial: Notebooks And Documents - Wolfram Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Notebooks</strong> and <strong>Documents</strong> 169Executing Notebook Commands Directly in the FrontEndWhen you execute a command like NotebookWrite@obj, dataD the actual operation of insertingdata into your notebook is performed in the front end. Normally, however, the kernel is neededin order to evaluate the original command, and to construct the appropriate request to send tothe front end. But it turns out that the front end is set up to execute a limited collection ofcommands directly, without ever involving the kernel.NotebookWrite@obj,dataDFrontEnd`NotebookWrite@obj,dataDversion of NotebookWrite to be executed in the kernelversion of NotebookWrite to be executed directly in thefront endDistinguishing kernel and front end versions of commands.The basic way that <strong>Mathematica</strong> distinguishes between commands to be executed in the kerneland to be executed directly in the front end is by using contexts. The kernel commands are inthe usual System` context, but the front end commands are in the FrontEnd` context.FrontEndExecute@exprDsend expr to be executed in the front endSending an expression to be executed in the front end.Here is a blank notebook.In[1]:=This uses kernel commands to write data into the notebook.NotebookWrite@SelectedNotebook@D, "x + y + z"D

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!