Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!megatek!spot!hollen From: hollen@spot.megatek.uucp (Dion Hollenbeck) Newsgroups: comp.sys.ibm.pc Subject: Re: Interactive BAT files: here's how Message-ID: <382@megatek.UUCP> Date: 4 Oct 88 20:27:52 GMT References: <8810040015.AA21729@decwrl.dec.com> Sender: news@megatek.UUCP Lines: 49 From article <8810040015.AA21729@decwrl.dec.com>, by birdsall@manana.dec.com: >> Subject: Interactive BAT files: HOW? >> Posted: 29 Sep 88 00:19:14 GMT >> Organization: Evans & Sutherland, Salt Lake City, Utah > >> I would like to alter my AUTOEXEC.BAT file (or another BAT file) >> to accept interactive input. [...stuff deleted...] > > Is it "possible"? Why of course! All things are possible under MS-DOS ... > but it can be painful ... > > Try this: > [...stuff deleted...] > (consult your DOS reference manual ). The syntax is a bit obscure but this is > how you branch on a specific errorlevel using a BAT file IF statement: > > if errorlevel 1 if not errorlevel 2 goto one: > if errorlevel 2 if not errorlevel 3 goto two: > goto exit: > :one > one statements > ... > goto exit > :two Walt has got approximately the right idea here and everything else he says about he C programs is accurate. CAUTION!! If the above return values are tested in ascending order, when the (implied) test "if errorlevel >= 1" is made, it will be true, even if the program returned 2 or 3 as the errorlevel. FIX!!! Make sure all errorlevel numeric tests test descendingly: if errorlevel 2 if not errorlevel 3 goto two: if errorlevel 1 if not errorlevel 2 goto one: By the time you get to testing for 1, you have eliminated all values above 1 and the true branch will indeed be true. Dion Hollenbeck (619) 455-5590 x2814 Megatek Corporation, 9645 Scranton Road, San Diego, CA 92121 seismo!s3sun!megatek!hollen ames!scubed/