Program Ask;

uses

  Crt;

var

  In_Char: char;

  index: word;

begin

  if (ParamCount = 1) and (ParamStr(1) = '/?') then

    begin

      writeln('ASK.EXE by David Wallace Croft.  FreeWare, 1992.');

      writeln('ASK will echo any command line inputs and then wait for the');

      writeln('user to press a key.  The ASCII value (0 to 255) of the key');

      writeln('is returned in the DOS ERRORLEVEL when ASK is done.  Lower');

      writeln('case letters are first translated to uppercase letters.');

      writeln('Example lines in a batch (MENU.BAT) file:');

      writeln('  @ECHO OFF');

      writeln(':Top');

      writeln('  ASK Do you want to play Games or do Word Processing (G/W)?');

      writeln('  REM Errorlevel 71 is ''G'' and ErrorLevel 87 is ''W''.');

      writeln(':G');

      writeln('  IF ERRORLEVEL 72 GOTO W');

      writeln('  IF NOT ERRORLEVEL  71 GOTO Bad');

      writeln('  CALL MenuGame.Bat');

      writeln('  GOTO Top');

      writeln(':W');

      writeln('  IF ERRORLEVEL 88 GOTO Bad');

      writeln('  IF NOT ERRORLEVEL 87 GOTO Bad');

      writeln('  CALL MenuWord.Bat');

      writeln('  GOTO Top');

      writeln(':Bad');

      writeln('  ECHO That option is not available.  Please try again.');

      writeln('  GOTO Top');

      Halt(0);

    end;

  for index := 1 to ParamCount do

    write(ParamStr(index) + ' ');

  In_Char := Upcase(ReadKey);

  WriteLn(In_Char);

  Halt(ord(In_Char));

end.