1.

Solve : Varuible Help?

Answer»

heh need more help

so i got this:

set v=0

:testy
pause
if v==0 then goto testy
echo v is 1

:event
set v=1


Basically, when I call event I want the goto testy to cancel out, and print the "v is 1"
but when I RUN it, it dosent do anything (this is a simplified version)if %v%==0 goto testy
hmm it seems that still dosent work for some reason...
Heres the code:

Code: [Select]set HASSHINY=0

...

:EXAMINEROCK
cls
if %HASSHINY%==1 goto ALREADYAQUIREDSHINY
echo Something shiny is on the
echo rock, would you like to
echo take it?
echo       (y/n)

set /p text=""
if "%text%"=="y" goto AQUIREDSHINY
goto AQUIREDSHINY
if "%text%"=="n" goto STARTINGAREA
echo Unkown term: %t%!
pause
goto EXAMINEROCK

...

:AQUIREDSHINY
cls
set AQUIREDSHINY=1
echo You obtained a knife blade!
pause
goto STARTINGAREA


Basicilly, it keeps you from doing the EXAMINEROCK function again. Any help? Quote from: 036483 on January 08, 2012, 05:44:05 PM

Code: [Select]set HASSHINY=0

...

:EXAMINEROCK
cls
if %HASSHINY%==1 goto ALREADYAQUIREDSHINY
echo Something shiny is on the
echo rock, would you like to
echo take it?
echo       (y/n)

set /p text=""
if "%text%"=="y" goto AQUIREDSHINY
....................................................
goto AQUIREDSHINY
....................................................
[code]if "%text%"=="n" goto STARTINGAREA
echo Unkown term: %t%!
pause
goto EXAMINEROCK

...

:AQUIREDSHINY
cls
set AQUIREDSHINY=1
echo You obtained a knife blade!
pause
goto STARTINGAREA

That's your problem. Delete the highlighted line. You will always GO to the "ACQUIREDSHINY" no matter your ANSWER in it's current state. There are a lot of other small issues with this code. It looks like you might want to PROOFREAD it yourself and think about what it is you are trying to accomplish.ugh thats not the problem, that was just some PASTING issue, but something is wrong with the HASSHINY variable thing.A couple of things:

You don't clear the text variable each time, meaning that it will retain its value if the person just hits enter.

Code: [Select]echo       (y/n)
set text=
set /p text=
if "%text%"=="y" goto AQUIREDSHINY
if "%text%"=="n" goto STARTINGAREA
echo Unknown term: %text%!
Also

Code: [Select]set AQUIREDSHINY=1
should surely read

Code: [Select]set HASSHINY=1
oh thanks I didnt see that.


Discussion

No Comment Found