“系统找不到指定的批处理标签”错误消息

时间:2016-04-06 16:43:47

标签: batch-file

这是我的批量代码。保存为Avalanche.bat。我一直收到错误The system cannot find the batch label specified。如果有人能解决这个问题,请告诉我!

setlocal enableextensions enabledelayedexpansion
echo off
title Avalanche
for /f "delims=" %%x in (Avalanche.bat) do set color=%%x
color %color%
if exist control.txt goto controlsetup
goto menu

:menu
    :: Main menu ::
    mode con cols=76 lines=12
        echo.
        echo   .:mmmm:.                                                        .:mmmm:.
        echo  ,mmMMMMmm,    .   .   .   .   .      .   .   .  .... .  . ....  ,mmMMMMmm,
        echo  :mMMMMMMm:  .: :. :. .: .: :. :    .: :. ::  : :     :  : :     :mMMMMMMm:
        echo  'mmMMMMmm'  :...:  :.:  :...: :    :...: : : : :     :::: :'''  'mmMMMMmm'
        echo   ':mmmm:'   :   :   :   :   : :::: :   : :  :: '.... :  : :...   ':mmmm:'
        echo.
        echo                                   1) PLAY
        echo                                   2) HELP
        echo                                   3) EXIT
        echo.
    choice /c 123 /n >nul
    if %errorlevel% equ 1 goto setup
    if %errorlevel% equ 2 goto help
    if %errorlevel% equ 3 exit
    goto menu

:help
    :: Help menu ::
    mode con cols=31 lines=12
    cls
        echo.
        echo            Help
        echo.
        echo  To play Avalanche, simply use
        echo  the A and D keys to move left
        echo  and right, respectively. If
        echo  you are hit by a falling
        echo  boulder, you die and lose the
        echo  game. During the game, press
        echo  Q to quit and P to pause.
        echo.
        echo      1) Change Color
        echo      2) Return to Menu
        echo.
    choice /c 12 /n >nul
    if %errorlevel% equ 1 goto color
    if %errorlevel% equ 2 goto menu
    goto help
:color
    :: Color changer ::
    mode con cols=35 lines=17
    cls
            echo.
            echo  Type two characters for their
            echo  corresponding colors. The first
            echo  color is the background and the
            echo  second is the text color. The
            echo  two cannot be the same color.
            echo.
            echo  0 = Black       8 = Gray
            echo  1 = Blue        9 = Light Blue
            echo  2 = Green       A = Light Green
            echo  3 = Aqua        B = Light Aqua
            echo  4 = Red         C = Light Red
            echo  5 = Purple      D = Light Purple
            echo  6 = Yellow      E = Light Yellow
            echo  7 = White       F = Bright White
            echo.
        set /p "color=Color: "
    if %errorlevel% equ 1 goto color
    color !color!
    echo !color!>>Avalanche.bat
    goto help

:controlsetup
        title Game Controls
        mode con cols=30 lines=1
:controlchoice
        choice /c adqp /n
        if !errorlevel! equ 1 set "dir=left"
        if !errorlevel! equ 2 set "dir=right"
        if !errorlevel! equ 3 set "dir=quit"
        if !errorlevel! equ 4 set "dir=pause"
goto controlwrite
:controlwrite
        echo !dir!>>control.txt
        if !dir! equ quit exit
        goto controlchoice

:setup
    set "b=O"

:play
    echo stop>>control.txt
    start Avalanche.bat
    mode con cols=16 lines=14

    set "b0y=1000"
    set "b1y=1000"
    set "b2y=1000"
    set "b3y=1000"
    set "b4y=1000"
    set "b5y=1000"
    set "b6y=1000"
    set "b7y=1000"
    set "b8y=1000"
    set "b9y=1000"
    set "px=5"


:loop
(


                    :: Resetting the board ::
                    set "0,0= "
                    set "0,1= "
                    set "0,2= "
                    set "0,3= "
                    set "0,4= "
                    set "0,5= "
                    set "0,6= "
                    set "0,7= "
                    set "0,8= "
                    set "0,9= "
                    set "1,0= "
                    set "1,1= "
                    set "1,2= "
                    set "1,3= "
                    set "1,4= "
                    set "1,5= "
                    set "1,6= "
                    set "1,7= "
                    set "1,8= "
                    set "1,9= "
                    set "2,0= "
                    set "2,1= "
                    set "2,2= "
                    set "2,3= "
                    set "2,4= "
                    set "2,5= "
                    set "2,6= "
                    set "2,7= "
                    set "2,8= "
                    set "2,9= "
                    set "3,0= "
                    set "3,1= "
                    set "3,2= "
                    set "3,3= "
                    set "3,4= "
                    set "3,5= "
                    set "3,6= "
                    set "3,7= "
                    set "3,8= "
                    set "3,9= "
                    set "4,0= "
                    set "4,1= "
                    set "4,2= "
                    set "4,3= "
                    set "4,4= "
                    set "4,5= "
                    set "4,6= "
                    set "4,7= "
                    set "4,8= "
                    set "4,9= "
                    set "5,0= "
                    set "5,1= "
                    set "5,2= "
                    set "5,3= "
                    set "5,4= "
                    set "5,5= "
                    set "5,6= "
                    set "5,7= "
                    set "5,8= "
                    set "5,9= "
                    set "6,0= "
                    set "6,1= "
                    set "6,2= "
                    set "6,3= "
                    set "6,4= "
                    set "6,5= "
                    set "6,6= "
                    set "6,7= "
                    set "6,8= "
                    set "6,9= "
                    set "7,0= "
                    set "7,1= "
                    set "7,2= "
                    set "7,3= "
                    set "7,4= "
                    set "7,5= "
                    set "7,6= "
                    set "7,7= "
                    set "7,8= "
                    set "7,9= "
                    set "8,0= "
                    set "8,1= "
                    set "8,2= "
                    set "8,3= "
                    set "8,4= "
                    set "8,5= "
                    set "8,6= "
                    set "8,7= "
                    set "8,8= "
                    set "8,9= "
                    set "9,0= "
                    set "9,1= "
                    set "9,2= "
                    set "9,3= "
                    set "9,4= "
                    set "9,5= "
                    set "9,6= "
                    set "9,7= "
                    set "9,8= "
                    set "9,9= "


                :: Set player and boulders ::
                set "!px!,0=@"

                if !b0y! lss 0 set "b0y=1000"
                if !b1y! lss 0 set "b1y=1000"
                if !b2y! lss 0 set "b2y=1000"
                if !b3y! lss 0 set "b3y=1000"
                if !b4y! lss 0 set "b4y=1000"
                if !b5y! lss 0 set "b5y=1000"
                if !b6y! lss 0 set "b6y=1000"
                if !b7y! lss 0 set "b7y=1000"
                if !b8y! lss 0 set "b8y=1000"
                if !b9y! lss 0 set "b9y=1000"

                if !b0y! leq 9 if !b0y! geq 0 set /a "b0y=!b0y!-1"
                set "0,!b0y!=!b!"
                if !b1y! leq 9 if !b1y! geq 0 set /a "b1y=!b1y!-1"
                set "1,!b1y!=!b!"
                if !b2y! leq 9 if !b2y! geq 0 set /a "b2y=!b2y!-1"
                set "2,!b2y!=!b!"
                if !b3y! leq 9 if !b3y! geq 0 set /a "b3y=!b3y!-1"
                set "3,!b3y!=!b!"
                if !b4y! leq 9 if !b4y! geq 0 set /a "b4y=!b4y!-1"
                set "4,!b4y!=!b!"
                if !b5y! leq 9 if !b5y! geq 0 set /a "b5y=!b5y!-1"
                set "5,!b5y!=!b!"
                if !b6y! leq 9 if !b6y! geq 0 set /a "b6y=!b6y!-1"
                set "6,!b6y!=!b!"
                if !b7y! leq 9 if !b7y! geq 0 set /a "b7y=!b7y!-1"
                set "7,!b7y!=!b!"
                if !b8y! leq 9 if !b8y! geq 0 set /a "b8y=!b8y!-1"
                set "8,!b8y!=!b!"
                if !b9y! leq 9 if !b9y! geq 0 set /a "b9y=!b9y!-1"
                set "9,!b9y!=!b!"


            :: The board ::
            cls
            echo.
            echo   ############
            echo   #!0,9!!1,9!!2,9!!3,9!!4,9!!5,9!!6,9!!7,9!!8,9!!9,9!#
            echo   #!0,8!!1,8!!2,8!!3,8!!4,8!!5,8!!6,8!!7,8!!8,8!!9,8!#
            echo   #!0,7!!1,7!!2,7!!3,7!!4,7!!5,7!!6,7!!7,7!!8,7!!9,7!#
            echo   #!0,6!!1,6!!2,6!!3,6!!4,6!!5,6!!6,6!!7,6!!8,6!!9,6!#
            echo   #!0,5!!1,5!!2,5!!3,5!!4,5!!5,5!!6,5!!7,5!!8,5!!9,5!#
            echo   #!0,4!!1,4!!2,4!!3,4!!4,4!!5,4!!6,4!!7,4!!8,4!!9,4!#
            echo   #!0,3!!1,3!!2,3!!3,3!!4,3!!5,3!!6,3!!7,3!!8,3!!9,3!#
            echo   #!0,2!!1,2!!2,2!!3,2!!4,2!!5,2!!6,2!!7,2!!8,2!!9,2!#
            echo   #!0,1!!1,1!!2,1!!3,1!!4,1!!5,1!!6,1!!7,1!!8,1!!9,1!#
            echo   #!0,0!!1,0!!2,0!!3,0!!4,0!!5,0!!6,0!!7,0!!8,0!!9,0!#
            echo   ############


        ::Checking for player input ::
:getinput
        for /f "delims=" %%x in (control.txt) do set dir=%%x
:checkinput
        if %dir% equ left set "px=!px!-1"
        if %dir% equ right set "px=!px!+1"
        if %dir% equ pause goto pause
        if %dir% equ quit goto end

        echo stop>>control.txt


        :: Choosing Boulder placement 
:chooseboulder1
        set /a "num=%random%*10/32768"
        if !b0y! leq 9 goto chooseboulder2
        if !b1y! leq 9 goto chooseboulder2
        if !b2y! leq 9 goto chooseboulder2
        if !b3y! leq 9 goto chooseboulder2
        if !b4y! leq 9 goto chooseboulder2
        if !b5y! leq 9 goto chooseboulder2
        if !b6y! leq 9 goto chooseboulder2
        if !b7y! leq 9 goto chooseboulder2
        if !b8y! leq 9 goto chooseboulder2
        if !b9y! leq 9 goto chooseboulder2
:chooseboulder2
        if !num! equ 0 goto chooseboulder
        if !num! equ 1 goto chooseboulder
        if !num! equ 2 goto chooseboulder
        if !num! equ 3 goto chooseboulder
        if !num! equ 4 goto chooseboulder
        if !num! equ 5 goto chooseboulder
        if !num! equ 6 goto chooseboulder
        if !num! equ 7 goto chooseboulder
        if !num! equ 8 goto chooseboulder
        if !num! equ 9 goto chooseboulder
        set "b!num!y=9"

    :: Delaying the game 0.5 seconds to make it easier to play ::
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
    ping localhost -n 1 >nul
)
goto loop


:pause
for /f "delims=" %%x in (control.txt) do set pause=%%x
if %pause% equ left goto checkinput
if %pause% equ right goto checkinput
if %pause% equ pause goto checkinput
if %pause% equ quit goto end

:end
del control.txt
mode con cols=15 lines=4
cls
echo    GAME OVER
echo     1) Menu
echo     2) Exit
choice /c 12 /n >nul
if %errorlevel% equ 1 goto menu
if %errorlevel% equ 2 exit

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: The following line(s) are color settings. Do not delete them. ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
0f

这个问题让我无法为互联网上的每个人发布此代码。如果我得到一个解决方案,帮助的人将把他们的名字包含在开发人员列表中,以及指向他们的stackoverflow配置文件的链接。

1 个答案:

答案 0 :(得分:2)

在选择Boulder展示位置时,您有:chooseboulder1:chooseboulder2个标签,但在某些行之后您会跳转到不存在的标签

:chooseboulder2
        if !num! equ 0 goto chooseboulder

应该是

:chooseboulder2
        if !num! equ 0 goto chooseboulder1