Path: utzoo!attcan!telly!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.os.msdos.misc Subject: Re: Getting rid of "syntax error" from .bat files - how to? Message-ID: <1990Dec8.150147.1225@druid.uucp> Date: 8 Dec 90 15:01:47 GMT References: <9467@pasteur.Berkeley.EDU> Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 27 In article <9467@pasteur.Berkeley.EDU> Graham Brand writes: > 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? The problem is that with no parameter it evaluates to if ==param1 which is invalid. To get around this simply do the test as follows: if %1x==param1x The extra character on both sides prevents the syntax error without affecting the comparison. >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. Not sure what you mean. The following works for me: if %1==-f echo -f Or with the above change: if x%1==x-f echo -f Can you give an example of the problem. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | There's no government West Hill, Ontario, Canada | like no government! +1 416 281 6094 |