Comment =================================================================== This is a MarxMenu that you would use in a BATCH file in order to return an ErrorLevel code. This ErrorLevel code can be used to control the execution of a BATCH file as follows: You have a BAT file called YESNO.BAT which branches to YES.BAT or NO.BAT depending on how you answer. MARXMENU YESNO 'Are you a programmer' N 15 1 0 IF ERRORLEVEL 1 YES NO In this example, we wait for a yes/no answer. If return is pressed or no answer is given in the alloted time, the default answer is assumed. In this example a Yes returns ErrorLevel 1 and no returns ErrorLevel 0. If WaitTime = 0 then it will wait forever for a KeyPress The Maximum WaitTime is 99 seconds. StandardIO is selected allowing this program to be run over a modem if necessary. =================================================================== EndComment Var Answer Question DefaultAnswer OppositeAnswer QTimer WaitTime LastSecond YesErrorLevel NoErrorLevel Question = NextWord(CmdLine) DefaultAnswer = NextWord(CmdLine) WaitTime = Value(NextWord(CmdLine)) YesErrorLevel = Value(NextWord(CmdLine)) NoErrorLevel = Value(NextWord(CmdLine)) StandardIO If NoErrorLevel = YesErrorLevel Writeln Writeln 'MarxMenu Programing Example:' Writeln 'CopyRight 1989 by Marc Perkel' Writeln Writeln 'Usage:' Writeln ' MARXMENU YESNO ' Writeln Writeln ' is the yes/no question to ask.' Writeln ' is the answer assumed if return is pressed or timeout.' Writeln ' is the number of seconds to wait for an answer.' Writeln ' is the DOS ErrorLevel to return for a YES answer.' Writeln ' is the DOS ErrorLevel to return for a NO answer.' Writeln Writeln 'Example:' Writeln " MarxMenu YesNo 'Are you a programmer' N 15 1 0" ExitCode = 0 ExitMenu Endif DefaultAnswer = UpperCase(DefaultAnswer) Writeln Write Question If DefaultAnswer = 'Y' Write ' (Y/n)? ' OppositeAnswer = 'N' Else Write ' (y/N)? ' OppositeAnswer = 'Y' Endif Answer = DefaultAnswer WaitTime = Min(WaitTime,99) If WaitTime > 0 LastSecond = Second While (not KbdReady) and (LastSecond = Second) ;First Second EndWhile QTimer = WaitTime While not KbdReady and (QTimer > 0) ;CountDown LastSecond = Second Write QTimer If QTimer = 9 then Write(' ' + BkSp) Write BkSp if QTimer > 9 then Write BkSp While (not KbdReady) and (LastSecond = Second) EndWhile if not KbdReady then QTimer = QTimer - 1 EndWhile EndIf if KbdReady or (WaitTime = 0) then Answer = UpperCase(ReadKey) if Answer <> OppositeAnswer then Answer = DefaultAnswer If Answer = 'Y' ExitCode = YesErrorLevel Writeln 'Yes' Else ExitCode = NoErrorLevel Writeln 'No' Endif