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

Author Topic: Need help with choice and if  (Read 5041 times)

0 Members and 1 Guest are viewing this topic.

phgk93

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 7
    Need help with choice and if
    « on: October 12, 2019, 08:03:18 PM »
    hey,
    I'm trying to make a sort of gane launcher with batch. Basically a few choice's and if's but after the first choice the if's seem to do nothing as no matter my input it always opens the first game of the list.
    And i've tried using set /p but the same problem occured

    (And, yes, I probably made same embarrassing mistakes but am not  programer, first time coding)

    Here my code so far:

    @echo off

    mode con: cols=1024

    :START
    Echo Press 1 for GBA or 2 for SNES
    choice/c 12 /n

    if %errorlevel%==1 (Echo Choose game
    Echo 1 Castlevania - Aria of Sorrow
    Echo 2 Keitan Denjuu Telefang
    Echo 3
    Echo 4
    Echo 5
    Echo 6
    Echo 7
    Echo 8
    Echo 9
    Echo 0 Return
    choice /c 1234567890 /n

    if "%errorlevel%"=="1" goto 1
    if "%errorlevel%"=="0" goto START

    :1
    "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Keitai Denjuu Telefang - Speed Version (Japan).gbc"
    )

    if %errorlevel%==2 (Echo Choose game
    Echo 1 Blackthorne

    choice /c 123456789 /n

       if %errorlevel%==2 "C:\Emuladores\zsnesw151\zsnesw.exe" "C:\Emuladores\zsnesw151\ROMs\Blackthorne (USA).sfc"
       exit)

    phgk93

      Topic Starter


      Newbie

      • Experience: Beginner
      • OS: Windows 7
      Re: Need help with choice and if
      « Reply #1 on: October 14, 2019, 09:57:48 AM »
      I figured it out! Just used a GOTO command with all the IFs stacked together just calling the GOTOs.
      Still if anyone has any hints on optimazation it be appreciated.
      Posting the code to see if it helps others.

      Code:

      @ECHO OFF

      :MENU
      Echo Press 1 for GBA or 2 for SNES
      CHOICE /C 12 /N


      IF %ERRORLEVEL%==1 GOTO GBA
      IF %ERRORLEVEL%==2 GOTO SNES
      EXIT

      :GBA
      ECHO ------Choose Game------
      ECHO 1 A-C
      ECHO 2 D-F
      ECHO 3 G-I
      ECHO 4 J-L
      ECHO 5 M-O
      ECHO 6 P-R
      ECHO 7 S-U
      ECHO 8 V-X
      ECHO 9 Y-Z
      ECHO 0 RETURN
      CHOICE /C 1234567890 /N

           IF %ERRORLEVEL%==1 GOTO 1
           IF %ERRORLEVEL%==2 GOTO 2
           IF %ERRORLEVEL%==3 GOTO 3
           IF %ERRORLEVEL%==4 GOTO 4
           IF %ERRORLEVEL%==5 GOTO 5
           IF %ERRORLEVEL%==6 GOTO 6
           IF %ERRORLEVEL%==7 GOTO 7
           IF %ERRORLEVEL%==8 GOTO 8
           IF %ERRORLEVEL%==9 GOTO 9
           IF %ERRORLEVEL%==10 GOTO 10

      :1
      ECHO 1 CASTLEVANIA - ARIA OF SORROW
      ECHO 2 CASTLEVANIA - CIRCLE OF THE MOON
      ECHO 3 CASTLEVANIA - HARMONY OF DISSONANCE
      ECHO 0 RETURN
      CHOICE /C 1230 /N   
      (IF %ERRORLEVEL%==1 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Castlevania - Aria of Sorrow.gba"
       IF %ERRORLEVEL%==2 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Castlevania - Circle of the Moon.gba"
       IF %ERRORLEVEL%==3 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Castlevania - Harmony of Dissonance.gba"
       IF %ERRORLEVEL%==4 GOTO GBA
      EXIT
      )

      :2
      ECHO 1 DRAGON WARRIOR MONSTERS
      ECHO 2 DRAGON WARRIOR MONSTERS 2 - COBI'S JOURNEY
      ECHO 3 DRAGON WARRIOR MONSTERS 2 - TARA'S ADVENTURE
      ECHO 0 RETURN
      CHOICE /C 1230 /N   
      (IF %ERRORLEVEL%==1 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Dragon Warrior Monsters (USA).gbc"
       IF %ERRORLEVEL%==2 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Dragon Warrior Monsters 2 - Cobi's Journey (USA).gbc"
       IF %ERRORLEVEL%==3 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Dragon Warrior Monsters 2 - Tara's Adventure (USA).gbc"
       IF %ERRORLEVEL%==4 GOTO GBA
      EXIT
      )

      :3
      ECHO 1 GACHASTA! DINO DEVICE 2 DRAGON
      ECHO 0 RETURN
      CHOICE /C 10 /N   
      (IF %ERRORLEVEL%==1 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Gachasta! Dino Device 2 Dragon (J).gba"
       IF %ERRORLEVEL%==2 GOTO GBA
      EXIT
      )

      :4
      ECHO 1 KEITAI DENJUU TELEFANG - SPEED
      ECHO 2 KEITAI DENJUU TELEFANG 2 - POWER
      ECHO 3 LIL' MONSTER
      ECHO 0 RETURN
      CHOICE /C 1230 /N   
      (IF %ERRORLEVEL%==1 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Keitai Denjuu Telefang - Speed Version (Japan).gbc"
       IF %ERRORLEVEL%==2 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Keitai Denjuu Telefang 2 - Power Version (J).gba"
       IF %ERRORLEVEL%==3 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Lil' Monster (USA).gbc"
       IF %ERRORLEVEL%==4 GOTO GBA
      EXIT
      )

      :5
      ECHO 1 MEDABOT - METABEE
      ECHO 2 MONSTER RANCHER ADVANCE
      ECHO 3 MONSTER RANCHER ADVANCVE 2
      ECHO 4 MONSTER RANCHER CARD BATTLE
      ECHO 5 MONSTER RANCHER EXPLORER
      ECHO 6 NETWORK BOUKENKI BUGSITE - BETA
      ECHO 0 RETURN
      CHOICE /C 1234560 /N   
      (IF %ERRORLEVEL%==1 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Medabots - Metabee Version (E).gba"
       IF %ERRORLEVEL%==2 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Monster Rancher Advance (U).gba"
       IF %ERRORLEVEL%==3 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Monster Rancher Advance 2 (U).gba"
       IF %ERRORLEVEL%==4 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Monster Rancher Card Battle (USA).gbc"
       IF %ERRORLEVEL%==5 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Monster Rancher Explorer (USA).gbc"
       IF %ERRORLEVEL%==6 "C:\Emuladores\VisualBoyAdvance\VisualBoyAdvance.exe" "C:\Emuladores\VisualBoyAdvance\ROMs\Network Boukenki Bugsite - Beta Version (Japan).gbc"
       IF %ERRORLEVEL%==7 GOTO GBA
      EXIT
      )

      :10
      GOTO MENU
      )

      :SNES

      ECHO ------Choose Game------
      ECHO 1 A-C
      ECHO 2 D-F
      ECHO 3 G-I
      ECHO 4 J-L
      ECHO 5 M-O
      ECHO 6 P-R
      ECHO 7 S-U
      ECHO 8 V-X
      ECHO 9 Y-Z
      ECHO 0 RETURN
      CHOICE /C 1234567890 /N

           IF %ERRORLEVEL%==1 GOTO 1
           IF %ERRORLEVEL%==2 GOTO 2
           IF %ERRORLEVEL%==3 GOTO 3
           IF %ERRORLEVEL%==4 GOTO 4
           IF %ERRORLEVEL%==5 GOTO 5
           IF %ERRORLEVEL%==6 GOTO 6
           IF %ERRORLEVEL%==7 GOTO 7
           IF %ERRORLEVEL%==8 GOTO 8
           IF %ERRORLEVEL%==9 GOTO 9
           IF %ERRORLEVEL%==10 GOTO 10

      :1
      ECHO 1 ACTRAISER
      ECHO 2 ALADDIN
      ECHO 3 ALIEN 3
      ECHO 4 BLACKTHORNE
      ECHO 0 RETURN
      CHOICE /C 12340 /N   
      (IF %ERRORLEVEL%==1 "C:\Emuladores\SNES9X\snes9x.exe" "C:\Emuladores\SNES9X\Roms\ActRaise (U).smc"
       IF %ERRORLEVEL%==2 "C:\Emuladores\SNES9X\snes9x.exe" "C:\Emuladores\SNES9X\Roms\Aladdin (USA).sfc"
       IF %ERRORLEVEL%==3 "C:\Emuladores\SNES9X\snes9x.exe" "C:\Emuladores\SNES9X\Roms\Alien 3 (USA).sfc"   
       IF %ERRORLEVEL%==4 "C:\Emuladores\SNES9X\snes9x.exe" "C:\Emuladores\SNES9X\Roms\Blackthorne (USA).sfc"
       IF %ERRORLEVEL%==5 GOTO SNES
      EXIT
      )

      :10
      GOTO MENU
      )