Solved Random Batch Crash Problem

October 8, 2012 at 21:37:36
Specs: Windows Vista
Random Batch Crash Problem
hi guys my batch file keeps crashing and i cant figure out why!
this is the part where it crashes
(no matter what i input it'll crash)


:menu
cls
echo NewGame
echo Continue
echo Options
echo Version 0.0.2
set cmd=
set /p cmd=
if /i "%cmd%"=="newgame" goto newgame
if /i "%cmd%"=="continue" (
::Btw for this bit it doesnt make the txt file
echo MenuL43 >> %cd%\Blackbox\Crashreport.txt
echo loading..
timeout > nul 2 /nobreak
set /p temp1=< Savefiles\plays
if %temp1% GTR 0 goto contgame
if %temp1%==0 (
echo MenuL49 >> %cd%\Blackbox\Crashreport.txt
echo NO SAVE DATA
pause
goto menu
)
if /i "%cmd%"=="options" goto options
echo invalid
pause
goto menu

Domo!


See More: Random Batch Crash Problem

Report •


#1
October 8, 2012 at 21:39:55
it doesnt write "MenuL49" into the txt file either!
i also tried
if /i "!cmd!"=="menu"
but it didnt work
btw,
set enabledelayedexpansion
is on

Domo!


Report •

#2
October 8, 2012 at 22:38:39
✔ Best Answer
unbalanced ( ), I believe. Looking at your code, add one for every "(", and subtract one for every ")". If your end result is not zero, you have an open (unmatched) parenthesis. for example: starting with your first (

if /i "%cmd%"=="continue" ( <--- first par, "one"

count "(" = one.

now count the rest:

if %temp1%==0 ( plus one, total: two
echo MenuL49 >> %cd%\Blackbox\Crashreport.txt
echo NO SAVE DATA
pause
goto menu
) minus one, total: one

so you have one, instead of zero, hence the error.

if /i "%cmd%"=="continue" (
...
if %temp1%==0 (
...
goto menu
) <------- add this parenthesis, (i think)
)

Sometimes () can really foul you up if you use : instead of ::
I learned the hard way, use "rem" or "::" for comments. If you use ":", and
it has a parenthesis, you will suffer the wrath of SINTAX.


Report •

#3
October 8, 2012 at 23:14:27
ahhh it all seems to work now! thank you very much, i didnt even realis that :)
oh, btw you spelt "Syntax" wrong
:)

Domo!


Report •
Related Solutions


Ask Question