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.
Documentation for Siod, the Scheme interpreter used in Siag
References to cells in the sheet can be done using A1 or R1C1 notation.
Note that this is a nonstandard extension to the Scheme language
which means that symbols cannot have names that start with one or
more letters and finishes with one or more digits.
When lines and columns are inserted or removed, the references
are automatically updated.
There is also a functional interface to the spreadsheet contents.
Additional functions can be defined in $SIAGHOME/siag/siag.scm,
where they will be available for all users, or in
$HOME/.siagrc, where they will be available for one user only.
- (get-cell row column)
- Returns the value of the cell.
- (x-get-cell row column buffer)
- Cross-references between buffers are possible by
specifying the buffer name. The buffer must be loaded.
- (get-string row column)
- Returns the value of the cell in the form of a string,
regardless of what's actually there: a string, a number,
a label, an error or nothing.
- (x-get-string row column buffer)
- The same as get-string, but references another buffer.
- (href n)
- Refers to a cell n columns to the right (left for
negative n) of the current cell.
- (vref n)
- Refers to a cell n rows below (above for
negative cell) the current cell.
- (area-sum r1 c1 r2 c2)
- The sum of all cells from (r1,c1) to (r2,c2)
- (area-min r1 c1 r2 c2)
- The minimum of all cells from (r1,c1) to (r2,c2)
- (area-max r1 c1 r2 c2)
- The maximum of all cells from (r1,c1) to (r2,c2)
- (area-avg r1 c1 r2 c2)
- The average of all cells from (r1,c1) to (r2,c2)
Certain functions can handle not only numbers and references, but whole
ranges of cells. Such ranges are written as, for example,
a1..c2 (A1 notation) or r1c1..r2c3 (R1C1 notation).
In this case,
the range consists of all cells from row 1, column 1 to row 2, column 3
(6 cells altogether). Not all fuctions can handle ranges.
Ranges update when lines and columns are inserted or deleted, just
like the references described above.
Siag adds the following functions to those defined by SIOD:
- Move point one cell to the left.
- Move point one cell to the right.
- Move point one line down.
- Move point one line up.
- Move point to column 1.
- Move point to the last used cell in the current line.
- Move point to column 1, line 1.
- Move point to the last used cell in the last used line.
- Move point to line 1 without changing the column.
- Move point to the last used line without changing the column.
- Move the window up one windowful.
- Move the window up one line.
- Move the window down one windowful.
- Move the window down one line.
- Move the window left one windowful.
- Move the window left one column.
- Move the window right one windowful.
- Move the window right one column.
- Prints information about the contents of the current cell
on the status bar.
- Delete the contents of the current cell.
- Insert an empty line, moving the rest of the document down.
- Create a label in the current cell.
- Create an expression in the current cell.
- Move mark to the current cell.
- Swap point and mark.
- Should delete everything between point and mark for compatibility
with Emacs, but currently does nothing. Block commands are available
for that purpose.
- 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.
- Copies the block in such a way that overlapping areas are handled
- Deletes all the cells in block.
- Dumps the block to a text file.
- Sets the block to be the area between mark and point.
- What does this do?
- Loads a new Siag window.
- Loads a Siag document into a new buffer.
- Saves the current buffer as a Siag document.
- Saves the current buffer using a new file name.
- Prints version information on the status bar.
- Starts the Chimera program with siag.html as argument.
- Search for keyword. Currently not implemented.
- Starts the Chimera program with siaghelp.html as argument.
- Redraws the screen.
- Recalculates all the cells once. If the are circular references,
this may need to be repeated.
- Read and execute a Scheme command.
- Abort a multi-key command sequence.
- Exit from Siag. If there are any unsaved changes, asks if they
should be saved.
- Does nothing. Sometimes useful for debugging.
Functions available for expressions
Hundreds of string and/or numeric functions are available. The full
reference is here. The reference
shows the standard syntax, not the Scheme syntax. The mapping
between the two is trivial.
There are three ways to execute Scheme code:
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.
- Enter it as an expression in a cell
- Press ( or Alt-X and type it in the input window
- Load it from a file using
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 (begin (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.
- The constant 123.4
- (- (+ 1 2) 3)
- This evaluates to 0
- (get-cell 3 4)
- The contents of the cell in row 3, column 4
- (get-cell R (- C 1))
- The contents of the cell immediately to the left of the
- (href -1)
- The same as above
- (+ r2c3 r2c4)
- The sum of the value in row 2, column 3 and the value
in row 2, column 4
- (+ c2 d2)
- The same as above, except that A1 notation was used
instead of R1C1.
- (acos r3c1)
- Arc cosine of the value in row 3, column 1.
- (tan r2c2)
- Tangent of r2c2.
- (/ (sin r2c2) (cos r2c2))
- Also tangent of r2c2.
- (pow temp 0.25)
- The variable temp raised to the power of 1/4.
- (pow temp (/ 1 4))
- The same as above.
- (asin (sin 1.59))
- This evaluates to 1.59
- (r_sum r2c2..r5c6 r1c1 12)
- The sum of all numbers between row 2, column 2 and row 5,
column 6; the number in row 1, column 1; and the number 12.
Asks for a file name and opens the file with that name as a
Opens a new empty Siag window.
Preview the contents of the current buffer.
Prints the current buffer using the lpr command.
Saves the currently open document
using the most recently used filename. If no name has been
given to the document, the name "noname.siag" is used.
Asks for a filename and saves the currently open document
using that filename.
Calls an external program to load a document. This can be used to
load over a network, using a program like httpget. The program
must print the document on stdout.
Calls an external program to save a document. The program must
read the document from stdin.
Quits from Siag. If there are any changes that have not
been saved, Siag asks if they should be saved.
Undoes the latest undoable operation. Not all operations can be
undone; in particular, operations involving very large ranges of
cells can require so much space that it is not realistic to store
the previous state. Also, some commands simply don't implement undo.
Delete the contents of the current cell.
Insert a line into the document, shifting the rest of the document
Remove one line, shifting the rest of the document up.
Insert one column, shifting the rest of the document right.
Remove one column, shifting the rest of the document left.
Select every cell in the grid.
Search the grid for a cell where the text matches a string.
Like Find, but search backwards.
Asks for a label to insert into the current cell.
Asks for a SIOD expression to insert into the current cell.
Asks for a C expression to insert into the current cell.
Asks for a Guile expression to insert into the current cell.
Requires the optional Guile interpreter.
Asks for a Tcl expression to insert into the current cell.
Requires the optional Tcl interpreter.
Moves the mark to the current cell.
Sets the block to be the rectangular area between the mark and
the current cell.
Clears the block from the grid.
Copies the contents of the block to the area to the right and
below the current cell.
Deletes all the cells in the block.
Fill every cell in the selection with a single value or a pattern
Inserts a formula calculating the sum of the cells in the block
into the current cell.
Inserts a formula calculating the smallest value of the cells in the block
into the current cell.
Inserts a formula calculating the largest value of the cells in the block
into the current cell.
Inserts a formula calculating the average of the cells in the block
into the current cell.
Sets the width in pixels of the current column.
Sets the width of every column in the selection to be just wide
enough for the values that are to be displayed.
Sets the height in pixels of the current row.
Sets the height of every row in the selection to be just
high enough for the values that are to be displayed.
All the styles can be redefined, given a little care and understanding
of how printf works. Most formats are simply variations of floating
point, but Integer and Hex are by definition integer and are called
with integer arguments. Date and Time are really weird and should
be more flexible.
Change the way the current cell or the selection looks.
Enter values into a record, where the field names are taken from the
first line of the block. This way, all a user has to do is to set the
block where the database is to be, put the cursor on the line where
he wants to edit a record and select Data - Edit Record.
This function is useful when entering data into many cells. After
a record has been edited, the program automatically moves down one
line and continues with the next.
Starts a trivial TCP based data server which listens on port 8080
and understands the following commands:
- 0: Removes borders from every cell in the block.
- 1: Puts borders around the block.
- 2: Puts borders around every cell in the block.
- 3: Puts borders under the last line of the block.
Note that once the server is started, Siag no longer responds to
user input until it recieves a QUIT command.
Change which buffer is displayed in the current window.
Delete the current buffer.
Split the current buffer in two.
Remove the current window and give its space to its neighbors.
Remove all windows except the current one.
Make the next window current.
Prevents the point from moving into any of the cells above and to
the left of it. Also makes those lines and columns stay on the
window so that they are visible even if the grid is scrolled.
Removes the protection previously set by Window - Protect Cells.
Toggles visibility of the grid lines on the screen. This does not
in any way affect the output when the sheet is printed.
Removes the yellow popup bubbles when the mouse pointer is moved over
the toolbar buttons. See also the function (tooltip-set N).
Makes a surface plot using lines.
Show a form where the user can specify the appearance of a plot.
Enter a command to be executed by the SIOD interpreter.
Enter a command to be executed by the C interpreter. This currently
is not operational.
Enter a command to be executed by the optional Guile interpreter.
Enter a command to be executed by the optional Tcl interpreter.
Forks and runs an external program as a separate process.
Starts a simple one-shot web server on port 8080.
Mails the current document using SMTP. Requires sendmail running on
the local host.
A simple demo of Siag as a file manager. Adds a few file management
commands and displays the contents of the current directory in the grid.
Displays the Siag online documentation.
This command does nothing useful.
Displays the GNU public licence.
Displays help for using the online help.
Displays the current version string.
- PUT r1 c1 r2 c2
- Reads one label per line and puts them into r1c1..r2c2.
- GET r1 c1 r2 c2
- Prints one label per line from the range r1c1..r2c2.
- Exits the server and returns to Siag.
Ulric Eriksson - July 2000 - email@example.com