[Solved] if %var% == 1 goto blah isn't working?

Score
0
Vote Up
January 22, 2012 at 16:01:15 Pacific
Specs: Windows Vista, Dell Dimension AMD Athlon 64 X2 Dual Core

I have a batch file, and was making an if statement. Then I went in and tested it. It closed, so I got an error log that said 'goto was unexpected at this time.' It was working before, and the other if statements still work, why would this particular one not work?

This is the non-working command: if %luck% == 1 goto lucky
This is the working command: if %svgnum% == back goto mainmenu
They are about the same, besides the variables.


Jump to Best Answer ↓   Report •


#1
Vote Down
Score
0
Vote Up
January 22, 2012 at 23:58:31 Pacific

Best Answer

Honestly all I can say is syntax's in batch are very sensitive,
the smallest difference in code can mess with a lot of different parts of your batch.

I see no problem, but from my own experience I've had a batch function wrong because of spaces in the statement.

Instead of using:
if %luck% == 1 goto lucky

Use:
if %luck%==1 goto lucky

Also make sure that there is a :lucky for the batch to goto.


Reply ↓  Report •
Reply to Message Icon Start New Discussion
Related Posts

« Using Inputs in Batch GTK glade/gedit PLEASE HE... »