Recalculating Cell Values
You should note a few important things regarding recalculations:
- Computation moves from top to bottom.
- Recalculation is non-iterative.
- Recalculation is triggered whenever a cell loses focus.
- The spreadsheet displays any error text in the offending cell if it can't execute the formula successfully.
- The spreadsheet executes formulas using the REBOL do command. This means you can run any REBOL code as a formula. The good news is, that means formulas are all-powerful; but that's also the bad news. The simple model discussed here has no security limitations on what formulas can or can't do, so be careful and remember that formulas execute every time a cell loses focusthis version doesn't check to see if the cell value has changed. If you write a formula that reads data from a web site, this version will execute that formula every time the spreadsheet recalculates the cell.
Common Questions You Might Have
Q: How do I enter formulas?
compute: does [
foreach cell cells [
if cell/formula [
if error? cell/text: try [do cell/formula]
set cell/var cell/text
A: Just as you would in a traditional spreadsheet; put an equal sign (=
) as the first character. For example, typing =now/time
into a cell will print the current time. Typing =checksum "any message"
will yield a CRC checksum. Formulas can combine cell data and REBOL Language expressions.
Q: How is the macro language implemented?
A: The formulas and macros are REBOL code that the spreadsheet evaluates from the cell. The most important thing to keep in mind, in this context, is that REBOL evaluates left-to-right; there is no inherent operator precedence. If you need to control the order of evaluation, use parentheses to group items.
Q: How does Nano-Sheets handle data types?
A: If you type $1000000
into cell A1, and 1.2531
into cell A2, and then enter the formula =A1 * A2
in cell A3, you'll see the way REBOL handles values like money. No messy, time-consuming fussing with formats. REBOL supports all the following scalar data types directly: integer
, and pair
Q: Nano-Sheets doesn't like money values with comma separators in them. Why?
A: The lexical format for money
values in REBOL was designed to allow foreign currencies to be entered in the same manner as U.S. currency. That means the decimal point can be either a period (.
) or a comma (,
) and you normally wouldn't use grouping separators. If you want to use them, the correct character is the apostrophe ('). For example, $1234567.89
, and $1'234'567,89
are all equivalent.