home *** CD-ROM | disk | FTP | other *** search
-
- Forth Spreadsheet
-
-
- This is the "Craig Lindley" Forth Spreadsheet which was published in
- Forth Dimensions, Vol. 7 Nos. 1 and 2. That article contains a discussion
- of the implementation. The port to Forthmacs required a few source code
- changes, particularly in order to make it work on a 32-bit Forth
- implementation. I also increased the number of rows from 26 to 100,
- eliminated some redundant screen redisplays in the GO_TO command, rewrote
- a lot of the cursor movement code, and added control key bindings so that
- the EMACS cursor movement keys can be used as well as the arrow keys.
-
- To get started:
-
- fload spread.fth
- spreadsheet
-
- Spreadsheet commands:
-
- Cursor Movement
-
- up ^P, up_arrow Up one row
- down ^N, down_arrow Down one row
- left ^B, left_arrow Left one column
- right ^F, right_arrow Right one column
- left_page ^Y, F1 Left 4 columns
- right_page ^U, F2 Right 4 columns
- up_page ^T, F3 Up 15 rows
- down_page ^V, F4 Down 15 rows
- first_col ^A, F5 Go to column A
- last_col ^E, F6 Go to column Z
- top_row F7 Go to row 0.
- bottom_row F8 Go to row 99
- go_to g Prompts for new row and column
-
- Other
-
- input_cell_data d Put number in cell
- input_equ e Put equation in cell
- input_row_names r Put labels on rows
- input_col_names c Put labels on columns
- format f Select integer or dollar format
- replicate_col a Copy data to other columns
- mode m Select auto or manual recalculation
- new n Erase spreadsheet
- calc_order o Select row or column calculation order
- perform_calc p, ^L Recalculate
- quit_calc q, ^Z Exit
-
-
- Equations
-
- Equations are entered in infix notation, for example:
-
- 5 b + ( 10 c * 11 f )
-
- The spaces are required. This equation multiplies cell "10 C" by cell
- "11 F", and adds cell "5 B" to the result. In this example, the parentheses
- are redundant, since * has a higher precedence than +.
-
- Operators:
-
- * / Highest precedence
- + - Normal precedence
- mod Lowest precedence
-
- Operators with the same precedence associate from left to right.
-
-
- What is Wrong with this Spreadsheet
-
- 1) The recalculation algorithm is naive. Instead of calculating rows first,
- then columns, (or vice versa), a spreadsheet should keep a dependency
- graph and recalculate only those paths in the graph which depend on
- changed data. This would eliminate redundant recalculation.
-
- 2) There should be a way to specify a range of values in an equation, for
- example: sum all the entries between cell 3 A and cell 10 A.
-
- 3) Reverse-Polish notation for equations is more flexible, and would allow
- any Forth operator to appear in an equation.
-
- 4) Should use the mouse, GEM windows, etc.
-
- 5) There should be a print command.
-
- 6) There should be some way to store the spreadsheet state in a file and
- restore it later.
-
- 7) There should be some way to insert/delete whole rows/columns.
-
- 8) The key bindings should be set by dictionary entries, in the same way
- that Forthmacs binds editing keys.
-
- 9) The current cell should be marked with inverse video.
-
- 10) It should be possible to enter numbers without using the "D" command.
-