\HeaderA{menu}{Menu Interaction Function}{menu}
\keyword{utilities}{menu}
\keyword{programming}{menu}
\begin{Description}\relax
\code{menu} presents the user with a menu of choices labelled from 1
to the number of choices.  To exit without choosing an item one can
select \samp{0}.
\end{Description}
\begin{Usage}
\begin{verbatim}
menu(choices, graphics = FALSE, title = "")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{choices}] a character vector of choices
\item[\code{graphics}] a logical indicating whether a graphics menu should be
used if available.
\item[\code{title}] a character string to be used as the title of the menu.
\code{NULL} is also accepted.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If \code{graphics = TRUE} and a windowing system is available
(Windows, MacOS X or X11 \emph{via} Tcl/Tk) a listbox widget is
used, otherwise a text menu.

Ten or fewer items will be displayed in a single column, more in
multiple columns if possible within the current display width.

No title is displayed if \code{title} is \code{NULL} or \code{""}.
\end{Details}
\begin{Value}
The number corresponding to the selected item, or 0 if no choice was
made.
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{select.list}{select.list}}, which is used to implement the graphical
menu, and allows multiple selections.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Not run: 
switch(menu(c("List letters", "List LETTERS")) + 1,
       cat("Nothing done\n"), letters, LETTERS)
## End(Not run)
\end{ExampleCode}
\end{Examples}

