Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Varuible Help  (Read 6731 times)

0 Members and 1 Guest are viewing this topic.

036483

  • Guest
Varuible Help
« on: January 08, 2012, 02:31:33 AM »
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)

Salmon Trout

  • Guest
Re: Varuible Help
« Reply #1 on: January 08, 2012, 04:31:44 AM »
if %v%==0 goto testy

036483

  • Guest
Re: Varuible Help
« Reply #2 on: January 08, 2012, 05:44:05 PM »
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?

Raven19528



    Hopeful
  • Thanked: 30
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Varuible Help
    « Reply #3 on: January 08, 2012, 05:55:18 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.
    "All things that are
    Are with more spirit chased than enjoy'd" -Shakespeare

    036483

    • Guest
    Re: Varuible Help
    « Reply #4 on: January 08, 2012, 07:45:57 PM »
    ugh thats not the problem, that was just some pasting issue, but something is wrong with the HASSHINY variable thing.

    Sirim



      Rookie

      Thanked: 2
      • Experience: Familiar
      • OS: Windows 7
      Re: Varuible Help
      « Reply #5 on: January 09, 2012, 05:38:49 AM »
      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

      036483

      • Guest
      Re: Varuible Help
      « Reply #6 on: January 09, 2012, 09:20:36 PM »
      oh thanks I didnt see that.