Path: utzoo!attcan!uunet!peregrine!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!uafhp!engr.uark.edu!sab From: sab@engr.uark.edu (Steven A. Breuer) Newsgroups: comp.os.msdos.misc Subject: Re: Getting rid of "syntax error" from .bat files - how to? Summary: Test for no parameters Message-ID: <5649@uafhp.uark.edu> Date: 5 Dec 90 19:43:39 GMT References: <9467@pasteur.Berkeley.EDU> Sender: netnews@uafhp.uark.edu Lines: 25 In article <9467@pasteur.Berkeley.EDU>, brand@cad.Berkeley.EDU (Graham Brand) writes: > I have written a batch file which accepts parameters from the command > line using the: > if %1==param1 > syntax. It works fine except that if I don't pass any parameters, I > get the above syntax error message. Is there any way to suppress this? > > In addition, is there any way of passing a string, the first character > of which is a dash (-), as in -f? It doesn't seem to work with the > above test. > Batch files have trouble with blank parameters (none). try the following "if" statements. It is a good idea to surround the parameters with some character - this should take of errors happening because of no parameters. This should also allow you to use the dash (-) as part of a parameter. if "%1"=="" goto NOPARMS if "%1"=="param1" goto PARAM1 Steve Breuer sab@engr.uark.edu