% Copyright 1994 Michael John Downes
% Copyright 2013 TeX Users Group
% This file is part of the dialogl package, released under the LPPL;
% see dialogl.ins for details.

\def\ComputerModern{\gdef\fontbase{Times}\gobble}
\def\Garamond{\gdef\fontbase{Computer Modern}\gobble}
\def\Helvetica{\gdef\fontbase{Garamond}\gobble}
\def\Malibu{\gdef\fontbase{Helvetica}\gobble}
\def\Times{\gdef\fontbase{Malibu}\gobble}

\def\gobble#1\endgobble{}

%    Make sure we have a reasonable \newlinechar
\newlinechar=`\^^J \catcode\newlinechar=12

\begingroup
\catcode`\<=1 \catcode`\ =2\relax
\gdef\menustart{\errmessage<%
....................................... }%
\endlinechar\newlinechar\catcode`\ =12\relax
\gdef\menutext{
 .......................................
 .......................................

  Select the font base you wish to use:

  [1] Computer Modern        [4] Malibu
  [2] Garamond               [5] Times
  [3] Helvetica

  (Default: Times)}%
\endgroup% percent here to avoid extra \newlinechar

\begingroup
\immediate\write16{\menutext}
%    If the user accidentally types 33 instead of 3 they will get past
%    all the legitimate menu choices. So to keep that from causing
%    trouble, we throw in a bunch of ~ characters below to perform
%    error recovery. The standard maximum number of tokens that TeX
%    will delete at one time is 99.
\catcode`\~=\active % just to make sure
\def~{\newlinechar`\^^J% restore normal value
  \message{%
Whoops! Well, you got Times as your font base, I think}%
  \gobble}
%    Minimize unwanted error context (note: setting
%    this to -1 doesn't suppress any more information)
\errorcontextlines 0
\newlinechar=`\! % to hide the automatic ! from \errmessage
\gdef\fontbase{Times}
%    Inside the next group we make the space character
%    active so that we can  use it to call \menustart,
%    and then we use \expandafter so that the first
%    space on the next line gets that catcode before
%    the \endgroup makes it revert to normal. All this
%    so that the user does not see `\menustart' on
%    screen, only a space.
\begingroup
\catcode`\ =\active\let =\menustart\expandafter\endgroup%
 % Enter a number (1...5) and press Return TWICE
\ComputerModern% Press Return to continue
\Garamond% Press Return to continue
\Helvetica% Press Return to continue
\Malibu% Press Return to continue
\Times% Press Return to continue
\gobble%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
\endgobble\endgroup%
\show\fontbase
\end
