|
SchemeSiag 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
Cell referencesReferences 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.
RangesCertain 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. FunctionsSiag adds the following functions to those defined by SIOD:
Functions available for expressionsHundreds 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:
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. Examples
Command Reference(load-buffer)Asks for a file name and opens the file with that name as a Siag document.(new-buffer)Opens a new empty Siag window.(preview)Preview the contents of the current buffer.(print)Prints the current buffer using the lpr command.(save-buffer)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.(save-buffer-as)Asks for a filename and saves the currently open document using that filename.(load-external)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.(save-external)Calls an external program to save a document. The program must read the document from stdin.(quit-program)Quits from Siag. If there are any changes that have not been saved, Siag asks if they should be saved.(undo-restore)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-cell)Delete the contents of the current cell.(insert-line)Insert a line into the document, shifting the rest of the document down.(remove-line)Remove one line, shifting the rest of the document up.(insert-col)Insert one column, shifting the rest of the document right.(remove-col)Remove one column, shifting the rest of the document left.(select-all)Select every cell in the grid.(search-forward)Search the grid for a cell where the text matches a string.(search-backward)Like Find, but search backwards.(edit-label)Asks for a label to insert into the current cell.(edit-siod)Asks for a SIOD expression to insert into the current cell.(edit-c)Asks for a C expression to insert into the current cell.(edit-guile)Asks for a Guile expression to insert into the current cell. Requires the optional Guile interpreter.(edit-tcl)Asks for a Tcl expression to insert into the current cell. Requires the optional Tcl interpreter.(set-mark-command)Moves the mark to the current cell.(set-block)Sets the block to be the rectangular area between the mark and the current cell.(unset-block)Clears the block from the grid.(copy-block)Copies the contents of the block to the area to the right and below the current cell.(delete-block)Deletes all the cells in the block.(fill-block)Fill every cell in the selection with a single value or a pattern of values.(block-sum)Inserts a formula calculating the sum of the cells in the block into the current cell.(block-min)Inserts a formula calculating the smallest value of the cells in the block into the current cell.(block-max)Inserts a formula calculating the largest value of the cells in the block into the current cell.(block-avg)Inserts a formula calculating the average of the cells in the block into the current cell.(block-borders 0/1/2/3)
(set-cell-width)Sets the width in pixels of the current column.(fit-block-width)Sets the width of every column in the selection to be just wide enough for the values that are to be displayed.(set-cell-height)Sets the height in pixels of the current row.(fit-block-height)Sets the height of every row in the selection to be just high enough for the values that are to be displayed.(define-style)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.(new-attribute "family"/"style"/"fg"/"bg")Change the way the current cell or the selection looks.(data-record-edit)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.(data-entry)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.(siag-net port)Starts a trivial TCP based data server which listens on port 8080 and understands the following commands:
(switch-to-buffer)Change which buffer is displayed in the current window.(kill-buffer 1)Delete the current buffer.(split-window-vertically)Split the current buffer in two.(delete-window)Remove the current window and give its space to its neighbors.(delete-other-windows)Remove all windows except the current one.(other-window)Make the next window current.(protect-cells)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.(remove-protection)Removes the protection previously set by Window - Protect Cells.(grid-lines 1/0)Toggles visibility of the grid lines on the screen. This does not in any way affect the output when the sheet is printed.(tooltip-set 0)Removes the yellow popup bubbles when the mouse pointer is moved over the toolbar buttons. See also the function (tooltip-set N).(splot "lines")Makes a surface plot using lines.(plot-wizard)Show a form where the user can specify the appearance of a plot.(exec-siod)Enter a command to be executed by the SIOD interpreter.(exec-c)Enter a command to be executed by the C interpreter. This currently is not operational.(exec-guile)Enter a command to be executed by the optional Guile interpreter.(exec-tcl)Enter a command to be executed by the optional Tcl interpreter.(spawn command)Forks and runs an external program as a separate process.(webserver)Starts a simple one-shot web server on port 8080.(mailto)Mails the current document using SMTP. Requires sendmail running on the local host.(filemgr)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.(help-contents)Displays the Siag online documentation.(help-search)This command does nothing useful.(help-copyright)Displays the GNU public licence.(help-for-help)Displays help for using the online help.(print-version)Displays the current version string.Ulric Eriksson - July 2000 - ulric@siag.nu |