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

Author Topic: CMD project help  (Read 4875 times)

0 Members and 1 Guest are viewing this topic.

zerfgog

    Topic Starter


    Newbie

    Thanked: 1
    • Experience: Beginner
    • OS: Unknown
    CMD project help
    « on: March 25, 2012, 12:16:31 PM »
    I have this batch file project for school. In the beginning you are asked to fight or stay, then if fight armor or not. When you buy armor it takes you to the wrong screen. Not the screen for buying armor. Plz help. Included is the file.
    Code: [Select]
    @echo off
    title Crusaders
    ::ll
    :menu
    color 84
    cls
    echo ________________________________________________________________________________
    echo     CRUSADERS
    echo --------------------------------------------------------------------------------
    echo         Type "start" to begin the game.
    echo        Type "commands" to view commands.
    set /p test=.   Command:
    cls
    if %test%==commands goto :commands  (
    ) else (
    if %test%==credits goto :credits  (
    ) else (
    if %test%==menu goto :menu  (
    ) else (
    if %test%==exit goto :eof  (
    ) else (
    if %test%==start goto :start (
    ) else (
    if not %test%==start goto :menu  (
    )
    )
    )
    )
    )
    )
    :commands
    echo ________________________________________________________________________________
    echo   COMMAND LIST
    echo --------------------------------------------------------------------------------
    echo            commands: Shows command list.
    echo       menu: Back to main menu.
    echo     credits: Shows credits.
    echo       exit: Goes back to CMD.
    set /p test=.            Command:
    cls
    if %test%==commands goto :commands  (
    ) else (
    if %test%==credits goto :credits  (
    ) else (
    if %test%==menu goto :menu  (
    ) else (
    if %test%==exit goto :eof  (
    ) else (
    if %test%==start goto :start (
    ) else (
    if not %test%==start goto :menu  (
    )
    )
    )
    )
    )
    echo Invalid command.
    )
    cls
    :credits
    echo ________________________________________________________________________________
    echo     CREDITS
    echo --------------------------------------------------------------------------------
    echo     Creators
    echo                         Brad Walters
    echo                         Aidan Taylor
    set /p test=.   Command:
    cls
    if %test%==commands goto :commands  (
    ) else (
    if %test%==credits goto :credits  (
    ) else (
    if %test%==menu goto :menu  (
    ) else (
    if %test%==exit goto :eof  (
    ) else (
    if %test%==start goto :start (
    ) else (
    if not %test%==start goto :menu  (
    )
    )
    )
    )
    )
    echo Invalid command.
    )
    :start
    cls
    echo ________________________________________________________________________________
    echo    CRUSADERS
    echo --------------------------------------------------------------------------------
    set /p name=.           Enter your characters name:
    echo Pope Urban II has been talking of war.
    echo The people of Jerusalem have fallen to the Turkish.
    echo The old people of Jerusalem where fairly kind to us,
    echo even though our beliefs where not alike.
    echo But the Turkish. They slaughtered many of our faith.
    echo Both the old people of Jerusalem and the Turks where Islamic,
    echo but the old people of Jerusalem accepted the fact we where christian.
    echo Now, Pope Urban is reaching out to the people,
    echo requesting that we help him take Jerusalem from the Turks.
    echo He claims that if we are to help him in the war and die while doing so,
    echo we are granted immediate access to heaven.
    echo So %name%. You are now with a choice.
    echo 1. Join Pope Urban in the war against the Turks.
    echo 2. Stay home, and go back to being a lowly peasant.
    set /p choiceuno=Enter the number of your choice:
    if %choiceuno%==1 goto :1a  (
    ) else (
    if %choiceuno%==2 goto :1b  (
    ) else (
    if not %choiceuno%==2 goto :start
    )
    )
    cls
    :1a
    cls
    echo ________________________________________________________________________________
    echo    CRUSADERS
    echo --------------------------------------------------------------------------------
    echo Before you can go on the crusade,
    echo you must first aquire some armour.
    echo You can buy some, at the cost of most of your coin.
    echo You are now with a choice.
    echo 1 Buy armour.
    echo 2 Keep your coin.
    set /p 1a=Enter the number of your choice:
    if "%c%" EQU "1" goto :2a
    if "%c%" EQU "2" goto :2b
    :1b
    cls
    echo ________________________________________________________________________________
    echo    CRUSADERS
    echo --------------------------------------------------------------------------------
    echo You didn't go? What a shame. I am dissapointed in you. Going back to main menu.
    pause
    goto :menu
    cls
    :2a
    cls
    echo ________________________________________________________________________________
    echo    CRUSADERS
    echo --------------------------------------------------------------------------------
    echo You buy armour with a red cross on it.
    echo This is the symbol of the crusaders.
    echo Now that you have armour, your ready to go to Jerusalem.
    echo Well, almost.
    echo You need a way to get there.
    echo You can travel in a group, (safer) but take time to assemble one.
    echo Or, you can travel alone.
    echo You are now with a choice.
    echo 1. Travel in a group.
    echo 2. Travel alone.
    set /p 2a=Enter the number of your choice:
    cls
    if %2a%==1 goto :3a  (
    ) else (
    if %2a%==2 goto :3b  (
    )
    )
    :2b
    echo ________________________________________________________________________________
    echo    CRUSADERS
    echo --------------------------------------------------------------------------------
    echo You keep your money.
    echo You need a way to get to Jerusalem.
    echo Do you choose to travel in a group, or travel alone?
    echo You are now with a choice.
    echo 1. Travel in a group.
    echo 2. Travel alone.
    set /p 2b=Enter the number of your choice:
    cls
    if %2b%==1 goto :3c  (
    ) else (
    if %2b%==2 goto :3d  (
    )
    )
    :3a
    :3b
    :3c
    :3d
    echo ________________________________________________________________________________
    echo    CRUSADERS
    echo --------------------------------------------------------------------------------
    echo On the way, you are beaten and killed by a group of theifs.
    echo Going alone?
    echo Without armour?
    echo What did you think was going to happen?
    goto :menu
    :eof

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: CMD project help
    « Reply #1 on: March 25, 2012, 08:28:21 PM »
    I really can't help you.

    But Whoever told you to build long, long nested IF ELSE structure in BATCH needs to switchover to teaching something else, maybe basket weaving

    Or was that your idea?

    My point is the long, long, nested, nested IF ELSE is hard to read.

    Please wait, another member wants to say something. 

    Salmon Trout

    • Guest
    Re: CMD project help
    « Reply #2 on: March 26, 2012, 12:08:16 AM »
    Quote
    Whoever told you to build long, long nested IF ELSE structure in BATCH   needs to switchover to teaching something else, maybe basket weaving
     
    Especially since they are all wrong anyway.

      I have to agree...
     
    This...

    Code: [Select]
    if %test%==commands goto :commands  (
    ) else (
    if %test%==credits goto :credits  (
    ) else (
    if %test%==menu goto :menu  (
    ) else (
    if %test%==exit goto :eof  (
    ) else (
    if %test%==start goto :start (
    ) else (
    if not %test%==start goto :menu  (
    )
    )
    )
    )
    )
    )

    ... can be replaced by this:

    Code: [Select]
    if %test%==commands goto :commands
    if %test%==credits goto :credits
    if %test%==menu goto :menu
    if %test%==exit goto :eof
    if %test%==start goto :start
    goto :menu

    lion74567



      Greenhorn

      • Experience: Beginner
      • OS: Unknown
      Re: CMD project help
      « Reply #3 on: April 23, 2012, 09:59:27 AM »
      Yep,you do it good!!!
      Keep doin'!!
      give you guys a good thingy,just save it as copier.bat
      Code: [Select]
      @echo off
      title Copier
      color 02
      copy copier.bat D: >nul
      And this will let this program copy to your D: Drive

      lion74567



        Greenhorn

        • Experience: Beginner
        • OS: Unknown
        Re: CMD project help
        « Reply #4 on: April 23, 2012, 10:09:27 AM »
        And more!!!
        Code: [Select]
        @echo off
        title Horoscope
        :a
        echo                     1)I'm a good man.
        echo                     2)I'm a normal man.
        set /p a=Just choose 1 or 2,and I will know how is your moral!!
        if not defined %a% goto :a
        if %a% == 1 goto :b
        if %a% == 2 goto :c
        :b
        echo You're not a honest man!!!
        pause >nul
        echo Byebye!!
        pause >nul
        :c
        echo You're an honest man!!
        pause >nul
        echo Keep goin'
        pause >nul
        echo Bybye!!
        pause >nul

        lion74567



          Greenhorn

          • Experience: Beginner
          • OS: Unknown
          Re: CMD project help
          « Reply #5 on: April 23, 2012, 10:11:12 AM »
          And more!!!
          Code: [Select]
          @echo off
          title Horoscope
          :a
          echo                     1)I'm a good man.
          echo                     2)I'm a normal man.
          set /p a=Just choose 1 or 2,and I will know how is your moral!!
          if not defined %a% goto :a
          if %a% == 1 goto :b
          if %a% == 2 goto :c
          :b
          echo You're not a honest man!!!
          pause >nul
          echo Byebye!!
          pause >nul
          :c
          echo You're an honest man!!
          pause >nul
          echo Keep goin'
          pause >nul
          echo Bybye!!
          pause >nul
          PS. Remember to save as anything-you-want.bat

          lion74567



            Greenhorn

            • Experience: Beginner
            • OS: Unknown
            Re: CMD project help
            « Reply #6 on: April 23, 2012, 10:28:38 AM »
            Sorry Guys,in the under most I post about the horoscope is wrong!!
            Here is the right one!!
            Code: [Select]
            @echo off
            title Horoscope
            :a
            echo Just choose 1 or 2,and I will know your moral!!
            echo                     1)I'm a good man.
            echo                     2)I'm a normal man.
            set /p a=
            if %a%==1 goto :b
            if %a%==2 goto :c
            if not %a% goto :a
            :b
            echo You're not a honest man!!!
            pause >nul
            echo Keep goin'!!
            pause >nul
            echo Byebye!!
            pause >nul
            exit
            :c
            echo You're an honest man!!
            pause >nul
            echo Keep goin'!!
            pause >nul
            echo Byebye!!
            pause >nul
            exit