Scheme
Siag uses Scheme for commands and expressions. This means that the program
can be easily extended with new functions. When Load is chosen from the
File menu, for instance, the Lisp function (load-buffer) is called.
It is thus possible to make File - Load do something completely different
by writing a new load-buffer function, perhaps adding the ability to
read other file formats.
Functions available as commands
- (backward-cell)
- Move point one cell to the left.
- (forward-cell)
- Move point one cell to the right.
- (next-line)
- Move point one line down.
- (previous-line)
- Move point one line up.
- (beginning-of-line)
- Move point to column 1.
- (end-of-line)
- Move point to the last used cell in the current line.
- (beginning-of-buffer)
- Move point to column 1, line 1.
- (end-of-buffer)
- Move point to the last used cell in the last used line.
- (top-of-buffer)
- Move point to line 1 without changing the column.
- (bottom-of-buffer)
- Move point to the last used line without changing the column.
- (scroll-up)
- Move the window up one windowful.
- (scroll-cell-up)
- Move the window up one line.
- (scroll-down)
- Move the window down one windowful.
- (scroll-cell-down)
- Move the window down one line.
- (scroll-left)
- Move the window left one windowful.
- (scroll-cell-left)
- Move the window left one column.
- (scroll-right)
- Move the window right one windowful.
- (scroll-cell-right)
- Move the window right one column.
- (what-cursor-position)
- Prints information about the contents of the current cell
on the status bar.
- (delete-cell)
- Delete the contents of the current cell.
- (insert-line)
- Insert an empty line, moving the rest of the document down.
- (edit-label)
- Create a label in the current cell.
- (edit-expression)
- Create an expression in the current cell.
- (set-mark-command)
- Move mark to the current cell.
- (exchange-point-and-mark)
- Swap point and mark.
- (kill-region)
- Should delete everything between point and mark for compatibility
with Emacs, but currently does nothing. Block commands are available
for that purpose.
- (copy-block)
- Copy the block to the rectangular area with its top left corner
in the current cell. If the block overlaps the destination area,
useful fill operations can be achieved.
- (intelligent-copy-block)
- Copies the block in such a way that overlapping areas are handled
correctly.
- (delete-block)
- Deletes all the cells in block.
- (print-block)
- Dumps the block to a text file.
- (set-block)
- Sets the block to be the area between mark and point.
- (save-block-file)
- What does this do?
- (new-siag)
- Loads a new Siag window.
- (load-buffer)
- Loads a Siag document into a new buffer.
- (save-buffer)
- Saves the current buffer as a Siag document.
- (save-buffer-as)
- Saves the current buffer using a new file name.
- (print-version)
- Prints version information on the status bar.
- (help-contents)
- Starts the Chimera program with siag.html as argument.
- (help-search)
- Search for keyword. Currently not implemented.
- (help-for-help)
- Starts the Chimera program with siaghelp.html as argument.
- (recenter)
- Redraws the screen.
- (recalc-matrix)
- Recalculates all the cells once. If the are circular references,
this may need to be repeated.
- (execute-extended-command)
- Read and execute a Scheme command.
- (keyboard-quit)
- Abort a multi-key command sequence.
- (quit-siag)
- Exit from Siag. If there are any unsaved changes, asks if they
should be saved.
- (no-op)
- Does nothing. Sometimes useful for debugging.
Functions available for expressions
In addition to the ordinary Scheme syntax, these commands are available
to make life in a spreadsheet easier:
- (row)
- Returns the row number of the cell which is being computed.
- (col)
- Returns the column number of the cell which is being computed.
- (get-cell row col)
- Returns the contents of the cell with the given
coordinates.
- (sum start end)
- Returns the sum of all the cells in the rectangle
between start and end.
There are also bindings to a number of standard floating-point functions.
- acos
- acosh
- asin
- asinh
- atan
- ceil
- cos
- cosh
- exp
- fabs
- floor
- log
- log10
- pow2
- pow10
- sin
- sinh
- sqrt
- tan
- tanh
- erf
- erfc
- j0
- j1
- lgamma
- y0
- y1
- expm1
- log1p
- cbrt
- atan2
- drem
- fmod
- hypot
- pow
There are three ways to execute Scheme code:
- Enter it as an expression in a cell
- Pressing ( and typing it in the input window
- Loading it from a file using
(load "filename")
A file can be loaded on startup by giving the option -iFilename
on the command line. A useful file to load is siod.scm which adds
common functions like caar, cadr and the like.
There is no difference between functions that are intended for commands
and those that are intended for expressions. It is quite possible to
enter the function (forward-cell) into a cell, making the point move
forward every time the sheet is recalculated (a command cannot be
entered directly as it returns nil and an expression must return
a number, but it can be entered as (let () (forward-cell) 0),
which returns 0).
It is also possible
to make the program compute the sum (+ 1 2) every time a certain key
is pressed. Not very useful (except for debugging), but possible.
This is done by changing the keybindings in the resource file.
Ulric Eriksson - July 1996 - ulric@asogy.stockholm.se