\chapter{The command line interface}
\label{cli}

\section{Gretl at the console}
\label{cli-console}

The \app{gretl} package includes the command-line program
\app{gretlcli}. On Linux it can be run from the console, or in an
xterm (or similar).  Under MS Windows it can be run in a console
window (sometimes inaccurately called a ``DOS box'').  \app{gretlcli}
has its own help file, which may be accessed by typing ``help'' at the
prompt. It can be run in batch mode, sending outout directly to a file
(see also the \emph{Gretl Command Reference}).
    
If \app{gretlcli} is linked to the \app{readline} library (this is
automatically the case in the MS Windows version; also see
Appendix~\ref{app-technote}), the command line is recallable and
editable, and offers command completion.  You can use the Up and Down
arrow keys to cycle through previously typed commands.  On a given
command line, you can use the arrow keys to move around, in
conjunction with Emacs editing keystokes.\footnote{Actually, the key
  bindings shown below are only the defaults; they can be customized.
  See the
  \href{http://cnswww.cns.cwru.edu/~chet/readline/readline.html}{readline
    manual}.} The most common of these are:
%    
\begin{center}
  \begin{tabular}{cl}
    \textit{Keystroke} & \multicolumn{1}{c}{\textit{Effect}}\\
    \verb+Ctrl-a+ & go to start of line\\
    \verb+Ctrl-e+ & go to end of line\\
    \verb+Ctrl-d+ & delete character to right\\
  \end{tabular}
\end{center}
%
where ``\verb+Ctrl-a+'' means press the ``\verb+a+'' key while the
``\verb+Ctrl+'' key is also depressed.  Thus if you want to change
something at the beginning of a command, you \emph{don't} have to
backspace over the whole line, erasing as you go.  Just hop to the
start and add or delete characters.  If you type the first letters of
a command name then press the Tab key, readline will attempt to
complete the command name for you.  If there's a unique completion it
will be put in place automatically.  If there's more than one
completion, pressing Tab a second time brings up a list.

\section{Changes from Ramanathan's ESL}
\label{cli-syntax}

\app{gretlcli} inherits its basic command syntax from Ramu
Ramanathan's \app{ESL}, and command scripts developed for \app{ESL}
should be usable with few or no changes: the only things to watch for
are multi-line commands and the \cmd{freq} command.
    
\begin{itemize}
\item In \app{ESL}, a semicolon is used as a terminator for many
  commands.  I decided to remove this in \app{gretlcli}. Semicolons
  are simply ignored, apart from a few special cases where they have a
  definite meaning: as a separator for two lists in the \cmd{ar} and
  \cmd{tsls} commands, and as a marker for an unchanged starting or
  ending observation in the \cmd{smpl} command. In \app{ESL} semicolon
  termination gives the possibility of breaking long commands over
  more than one line; in \app{gretlcli} this is done by putting a
  trailing backslash \verb+\+ at the end of a line that is to be
  continued.
\item With \cmd{freq}, you can't at present specify user-defined
  ranges as in \app{ESL}.  A chi-square test for normality has been
  added to the output of this command.
\end{itemize}

Note also that the command-line syntax for running a batch job is
simplified. For \app{ESL} you typed, e.g.
      
\begin{code} 
    esl -b datafile < inputfile > outputfile
\end{code}
%
while for \app{gretlcli} you type:
%      
\begin{code}
    gretlcli -b inputfile > outputfile
\end{code}

The inputfile is treated as a program argument; it should specify a
datafile to use internally, using the syntax \cmd{open datafile} or
the special comment \verb+(* !+ datafile \verb+*)+
    
%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "gretl-guide"
%%% End: 

