Mathematica Technical FAQs Services & Resources / Mathematica / Notebook Interface
-----
 /
Buttons & Hyperlinks
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

How do I get buttons to read from and write to cells?

First, the cells you read from and write to must be selectable. The cell option CellTags makes this easy to do.

The button needs to

Find the cells to be read. (NotebookLocate, SelectionMove, NotebookFind)

Read in the cells. (NotebookGet, NotebookRead)

Convert the cells into expressions. (MakeExpression, ToExpression)

Manipulate the expressions to create output.

Convert the output into cells. (ToString, MakeBoxes, ToBoxes)

Wite the ouput to the cells. (CellPrint, NotebookWrite, NotebookPut, StylePrint)

Here is an example.

In[1]:=

This function reads in cells with CellTags "x" and "y", converts the cells to values, adds the two values, converts the new value to a cell, and writes out the cell. The following code creates some cells which use this command.

In[2]:=

This creates two input cells, a button, and an output cell. If you place a 2 in one input cell, place a 4 in the second input cell, and hit the button, then a six is written to the output cell.

 

 
 

 

Download this FAQ as a Mathematica 5.2 Notebook






 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy | [ja]