ELSE issue?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: ELSE issue?

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Location
    YouTube
    Posts
    1

    ELSE issue?

    I'm making a text adventure in pure Batch, and made a test level, as shown below.
    Code:
    echo What do?
    echo.
    set /p var=Input Command:
    if %var%==i goto inventory
    if %var%==inventory goto inventory
    if %var%==l goto look
    if %var%==look goto look
    if %var%==inspect goto look
    if %var%==examine goto look
    if %var%==xyzzy goto cliche
    if %var%==potato goto potato
    else echo I dont understand.
    The idea here is that if you type in a command that isn't one of the ones listed, it says it doesn't understand.
    Yet, if I type in an unknown command, it just goes back to the start of that level.
    What's going on?

    Thanks!
    ~DigiDuncan

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,634

    Re: ELSE issue?

    Try
    Code:
    if %var%==potato (
      goto potato
    ) else (
      echo I dont understand.
    )
    see the help (type help if in a console window)
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center