This chapter describes two related topics: the command-line interface, where you can type expressions and commands expressed in LME, the language of SysQuake, and observe the results immediately; and SQ scripts, simple programs which support interactive graphics.
The main purpose of SysQuake is interactive graphics. However, it is often convenient to issue simple commands at a command-line interface. This permits evaluation of expressions, checking command syntax and behavior as well as debugging user functions. For these reasons, SysQuake also includes this possibility.
You can type commands, cut to or paste from the clipboard after the prompt, and copy from anywhere. When you hit the Return key, everything after the last prompt is interpreted. The following keys have a special meaning:
Commands you can type in the Command window or panel include:
The commands you can type are described in the chapter LME Reference (LME is the name of the language used by SysQuake). You can also type expressions; LME evaluates them and displays their result unless you add a semicolon. When you evaluate an expression, its result is assigned to the variable ans, so that you can reuse it easily. Here is a simple example which displays four times the sine of three radians, and then adds 5 to the result (type what is in bold; the plain characters correspond to what SysQuake displays itself when you hit the Return key):
> 4*sin(3) ans= 0.5645 > ans+5 ans= 5.5645
Calls to graphic functions are permitted. On platforms where a single graphic window is displayed, if an SQ file is already loaded, you can clear the figures first with the clf command:
> clf > plot(sin(0:0.1:2*pi))
There are two ways to program interactive graphics for SysQuake: SQ scripts and SQ files. Both are text files based on LME, SysQuake's language. For small programs, SQ scripts are simpler than SQ files, because they do not require the declarations of variables, figures and functions; but they have limitations which make them less suitable for large applications. They should be used only for interactive graphics when no other form of user interface is necessary. The table below summaries the differences.
SQ scripts | SQ files | |
---|---|---|
Interactive graphics | x | x |
Sliders and buttons | x | x |
Zoom and Shift | x | x |
Multiple synchronized graphics | x | x |
Easy access to variables | x | |
Figure menu | x | |
Settings menu | x | |
Undo/Redo | x | |
Save | x | |
Functions | libraries only | x |
Suitable for long computation | x | |
Help | x | |
Multiple instances | on some platforms | |
SysQuake LE | x | x |
An SQ script is a sequence of LME commands and expressions, very similar to what could be typed in the command-line interface. The single command
plot(sin(0:0.1:2*pi));
is enough to display a sine evaluated for angles between 0 and
The typical structure of an SQ script which supports the interactive manipulation of graphical element(s) is described below. Code samples show a typical implementation for manipulating the vertical position of points; but of course, many variants are possible.
if firstrun x = 1:10; y = rand(2,10); end
_z | initial position of the mouse as a complex number |
_x | initial horizontal position of the mouse |
_y | initial vertical position of the mouse |
_z0 | initial position of the clicked element as a complex number |
_x0 | initial horizontal position of the clicked element |
_y0 | initial vertical position of the clicked element |
_z1 | current position of the mouse as a complex number |
_x1 | current horizontal position of the mouse |
_y1 | current vertical position of the mouse |
_kx | factor the horizontal position is multiplied by (_x1/_x) |
_ky | factor the horizontal position is multiplied by (_y1/_y) |
_q | additional data specific to the plot |
_m | true if the modifier key (Shift key) is held down |
_id | ID of the manipulated object |
_nb | number of the manipulated trace (1-based) |
_ix | index of the manipulated point (1-based) |
switch _id case 1 y(_nb,_ix) = _y1; end
plot(x, y, 'r', 1);