Chapter 4. Modes of working

Table of Contents
Command scripts
The "session" concept
The gretl toolbar

Command scripts

As you execute commands in gretl, using the GUI and filling in dialog entries, those commands are recorded in the form of a "script". Such scripts can be edited and re-run, using either gretl or the command-line client, gretlcli.

To view the current state of the script at any point in a gretl session, choose "Command log" under the File menu. This log file is called session.inp and it is overwritten whenever you start a new session. To preserve it, save the script under a different name. Script files will be found most easily, using the GUI file selector, if you name them with the extension ".inp".

To open a script you have written independently, use the "File, Open command file" menu item; to create a script from scratch use the "File, New command file" item. In either case a script window will open (see Figure 4-1).

Figure 4-1. Script window, editing a command file

The toolbar at the botton left of the script window offers the following functions (left to right): (1) Save the file; (2) Save the file under a specified name; (3) Execute the commands in the file; (4) Copy selected text; (5) Paste the selected text; (6) Find and replace text; (7) Undo the last Paste or Replace action; (8) Help (if you place the cursor in a command word and press the question mark you will get help on that command); (9) Close the window.

These functions (and in addition a Print option) may also be found under the "File" and "Edit" menus at the top of the script window.

When you click the Execute icon or choose the "File, Run" menu item all output is directed to a single window, where it can be edited, saved or copied to the clipboard.

To learn more about the possibilities of scripting, take a look at the gretl Help item "Script commands syntax," or start up the command-line program gretlcli and consult its help, or consult Chapter 10 in this manual. In addition, the gretl package includes over 70 "practice" scripts. Most of these relate to Ramanathan (2002), but they may also be used as a free-standing introduction to scripting in gretl and to various points of econometric theory. You can explore the practice files under "File, Open command file, practice file" There you will find a listing of the files along with a brief description of the points they illustrate and the data they employ. Open any file and run it ("File, Run" in the resulting script window) to see the output.

Note that long commands in a script can be broken over two or more lines, using backslash as a continuation character.

You can, if you wish, use the GUI controls and the scripting approach in tandem, exploiting each method where it offers greater convenience. Here are two suggestions.

A further option is available for your computing convenience. Under gretl's File menu you will find the item "Gretl console". This opens up a window in which you can type commands and execute them one by one (by pressing the Enter key) interactively. This is essentially the same as gretlcli's mode of operation, except that (a) the GUI is updated based on commands executed from the console, enabling you to work back and forth as you wish, and (b) gretl's Monte Carlo loop routine (see the Section called Monte Carlo simulations in Chapter 8) is not at present available in this mode.