2 Simple interactive use

Contents of this section

When you start Tela from the Unix prompt without arguments (usually by typing tela), the system enters interactive mode after reading some initialization files and is ready to parse and execute command lines. The Tela prompt is ``> ''. The GNU Readline library is the first layer interacting with the user. This library makes it easy to modify and reexecute previous commands. The most important key combinations are (Ctrl means keeping Control down when pressing the key):

Ctrl-P         Get Previous line
Ctrl-N         Get Next line
Ctrl-F         Forward cursor one character position
Ctrl-B         Backward cursor one character position

Ctrl-A         Set cursor position at beginning of line
Ctrl-E         Set cursor position at End of line
Ctrl-K         Delete (Kill) text beyond cursor position

TAB            Try to complete reserved word, identifier or filename
Enter          Execute command line (cursor need not be at end position)

Ctrl-C         Interrupt command during command execution
Ctrl-D         Quit Tela (must be alone in line)

You have probably used other software which also uses the GNU Readline library, e.g. the GNU debugger gdb. If your terminal is properly configured, you can use the arrow keys instead of Ctrl-P, Ctrl-N, Ctrl-F and Ctrl-B to move in the history buffer. You should get familiar with these commands as soon as possible, since it will greatly speed up your working with Tela. The command completion is able to complete Tela reserved words, function names (either intrinsic, standard, or user-defined), variables names and filenames. Filename completion is invoked if the TAB key is pressed inside a string (``...''). This can be useful with the source command, for example.

Tela uses the X window system to display graphics. The graphics is displayed by a separate program, named PlotMTV, but calling it is transparent to the user. The DISPLAY environment variable must be properly defined, otherwise the graphics will not work.

Try entering the following commands first (``> `` means the Tela prompt which you obviously do not type):

> x=0:0.1:4*pi
> plot(x,sin(x))

The first command creates a vector of real numbers ranging from 0 to 4 times Pi with step 0.1 and assigns the vector to variables x. The second command then plots sin(x) versus x. A graph of sin(x) should appear in a new PlotMTV window, if not, the system is not properly installed.

In Matlab, an expression is printed if there is no semicolon at the end of command line. In Tela, however, an expression is printed if it is not assigned to any variable, regardless of any semicolon. In fact, Tela internally inserts a semicolon at the end of every command line before actually parsing it. The insertion is not done when reading commands from a file.

This leads us to the next topic: how to execute commands from a file. Type

> source("demo")

A menu of choices appears, but let us first explain what the source command does. It looks for file named ``demo.t'' in the current TELAPATH (if the file name contains a period, the ``.t'' is not appended). The TELAPATH is a list of directories where input files are searched, similar in function to the Unix PATH. The file ``demo.t'' is found in some standard directory and commands in it are executed. The current TELAPATH can be seen by giving the command telapath().

When reading commands from a t-file, there should be a semicolon at the end of each statement (or actually separating the consecutive statements, but the difference is unessential here).

OK, now play with the demos. Press a number and ENTER to the menus, to get back to command level select Quit.

The typical and recommended way to use Tela when developing something bigger than one line is the following: Open an editor window and a shell (Xterm) executing Tela on your workstation. Create a t-file, for example ``mine.t'' with the editor and write some Tela commands in it. Remember to use semicolons as statement separators. Try it out by typing source(``mine.t'') in the Tela window. You must have started Tela from the same directory where ``mine.t'' lies, or you can use the Tela cd command to change to that directory. (See help cd.) Doing this repeatedly you only need save the file from the editor and press Ctrl-P ENTER in Tela window to execute the file with changes you just made. This is only slightly clumsier than program development with Turbo Pascal in the old times: instead of a single keypress you now have to press three keys and switch the window with the mouse once to execute the program!

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter