SCILAB WORKING ENVIRONMENT
SCILAB CONSOLE
Scilab Working Envionment
The first way is to use Scilab interactively, by typing commands in the console, analyzing the results
and continuing this process until the final result is computed. This document is designed so that the Scilab
examples which are printed here can be copied into the console. The goal is that the reader can experiment
by himself Scilab behavior. This is indeed a good way of understanding the behavior of the program and,
most of the time, it allows a quick and smooth way of performing the desired computation.
In the following example, the function disp is used in the interactive mode to print out the string ”Hello
World!”.
1
, The completion in the console.
-->s="Hello World!" s =
Hello World! -->disp(s)
Hello World!
In the previous session, we did not type the characters ”-->”which is the prompt, and which is managed
by Scilab. We only type the statement s="Hello World!" with our keyboard and then hit the <Enter> key.
Scilab answer is s = and Hello World!. Then we type disp(s) and Scilab answer is Hello World!.
When we edit a command, we can use the keyboard, as with a regular editor. We can use the left ← and
right → arrows in order to move the cursor on the line and use the <Backspace>and <Suppr>keys in order
to fix errors in the text.
In order to get access to previously executed commands, use the up arrow ↑ key. This allows to browse
the previous commands by using the up ↑ and down ↓ arrow keys.
The <Tab>key provides a very convenient completion feature. In the following session, we type the
statement disp in the console.
-->disp
Then we can type on the <Tab>key, which makes a list appear in the console, as presented in figure 4.
Scilab displays a listbox, where items correspond to all functions which begin with the letters ”disp”. We
can then use the up and down arrow keys to select the function we want.
The auto-completion works with functions, variables, files and graphic handles and makes the
development of scripts easier and faster.
The editor
Scilab version 5.2 provides a new editor which allows to edit scripts easily. Figure 5 presents the editor
during the editing of the previous ”Hello World!” example.
2
, The editor.
The editor can be accessed from the menu of the console, under the Applications > Editor menu, or
from the console, as presented in the following session.
-->editor()
This editor allows to manage several files at the same time, as presented in figure 5, where we edit five
files at the same time.
There are many features which are worth to mention in this editor. The most commonly used features
are under the Execute menu.
• Load into Scilaballows to execute the statements in the current file, as if we did a copy and paste.
This implies that the statements which do not end with the semicolon ”;” character will produce an
output in the console.
• Evaluate Selection allows to execute the statements which are currently selected.
• Execute File IntoScilaballows to execute the file, as if we used the exec function. The results which
are produced in the console are only those which are associated with printing functions, such as disp
for example.
3
, We can also select a few lines in the script, right click (or Cmd+Click under Mac), and get the context
menu which is presented in figure 6.
The Edit menu provides a very interesting feature, commonly known as a ”pretty printer” in most
languages. This is the Edit > Correct Indentation feature, which
Context menu in the editor.
automatically indents the current selection. This feature is extremelly convenient, as it allows to format
algorithms, so that the if, for and other structured blocks are easy to analyze.
The editor provides a fast access to the inline help. Indeed, assume that we have selected the disp
statement, as presented in figure 7. When we right-click in the editor, we get the context menu, where the
Help about ”disp” entry allows to open the help page associated with the disp function.
4