Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am making batch file and need to know how to do the following
if %1 = "debug" goto debug
if %1 = "normal" goto normalAt the moment I get syntax error
It should be obvious what I am trying to do but if it is not I will explain.
ALSO! if i have a batch file which has been started with batchname parameter then within that batch file, if I type anotherbatchfile %1
will it give the %1 over from the first batch file so it can be used in the second?
Thanks,Mike

First question,you need to use two equal symbols instead of one.
Second question,yes.You can also start the second batchfile by using CALL.

Actually something like:
if %1.==debug. goto debug
if %1.==DEBUG. goto debugworks better. First the "." appended to the %1 parameter and compare solves some strange problems and having a compare for both upper and lower case handles that problem as the compare is case sensitive.

First thing, use double equal signs. Besides that, you should use a sinbol, like on the example from JackG. That because if you just do:
if %1==DEBUG goto debug
And if %1 is nothing, you'll get a sintax error. That's why you should use the auxiliar character. Which one to use, is up to you. Just keep in mind you must use on both sides:
if %1.==DEBUG. goto debug
if !%1==!DEBUG goto debug
if (%1)==(DEBUG) goto debug
if "%1"=="DEBUG" goto debugNow, as JackG said, the compare is case sensitive ('debug' different than 'DEBUG' different than 'DeBuG'). JackG's example does NOT make it case insensitive, since the parameter may have both upper and lower case characters (if it's 'DeBuG', it wouldn't goto:debug with his example). I think this one is a better approach for the case insensitive comparison:
set _%1=!!!
if "%_DEBUG%"=="!!!" goto debugLater one, maybe on the end of the file, unset the variable
set _%1=
Got it all? I hope I were clear.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |