如何使用%x%和%y%代替14 32

时间:2019-03-17 18:15:55

标签: batch-file

这是我的高级BAT到EXE转换器脚本:

:start
cls
title Money Madness - The Game
set o1 = 13
set o2 = 15
cls
rem ChangeColor 11 0
rem ShadeBoxAt 6 31 15 1 4
rem ShadeBoxAt 20 32 1 19 4
rem ShadeBoxAt 6 50 14 1 4
rem ShadeBoxAt 6 32 1 18 4
rem ChangeColor 10 0
rem Locate %o1% %o2%
echo a
pause

但是我收到一个错误:

  

找到[选项计数错误]

完整代码在这里:


@echo off
:startup
title Money Madness - loading
rem ChangeColor 10 0
rem ShadeBoxAt 6 11 15 1 4
rem ShadeBoxAt 20 12 1 9 4
rem ShadeBoxAt 14 22 7 1 4
rem ShadeBoxAt 14 30 7 1 4
rem ShadeBoxAt 14 23 1 7 4
rem ShadeBoxAt 20 23 1 7 4
rem ShadeBoxAt 14 32 7 1 4
rem ShadeBoxAt 14 33 2 7 4
rem ShadeBoxAt 14 40 7 1 4
rem ShadeBoxAt 18 33 1 7 4
rem ShadeBoxAt 14 42 7 1 4
rem ShadeBoxAt 14 43 2 3 4
rem ShadeBoxAt 19 43 2 3 4
rem ShadeBoxAt 19 46 2 1 4
rem ShadeBoxAt 15 46 4 3 4
rem ShadeBoxAt 14 46 6 2 4
rem ShadeBoxAt 13 42 1 5 4
rem ShadeBoxAt 13 32 1 9 4
rem ShadeBoxAt 13 22 1 9 4
rem ShadeBoxAt 13 50 8 1 4
rem ShadeBoxAt 11 50 1 1 4
rem ShadeBoxAt 11 52 10 1 4
rem ShadeBoxAt 11 53 2 2 4
rem ShadeBoxAt 13 55 2 2 4
rem ShadeBoxAt 15 57 2 2 4
rem ShadeBoxAt 17 59 2 2 4
rem ShadeBoxAt 19 61 2 3 4
rem ShadeBoxAt 11 63 8 1 4
rem ShadeBoxAt 11 66 10 2 4
rem ShadeBoxAt 11 68 2 6 4
rem ShadeBoxAt 20 68 1 7 4
rem ShadeBoxAt 17 72 4 3 4
rem ShadeBoxAt 16 70 1 5 4
rem wait 3000
rem Locate 24 2
echo Press any key to continue to the menu screen
pause>nul
cls

:menu
cls
title Money Madness - Menu
rem ChangeColor 11 0
rem PrintBoxAt 1 1 25 80 2
rem PrintBoxAt 2 2 23 78 1
rem ChangeColor 15 0
rem Locate 8 30
echo Money Madness!
rem Locate 9 27
echo ---------------------
rem Locate 11 16
echo 1. Start
rem Locate 12 16
echo 2. Help
rem Locate 13 16
echo 3. Exit
rem Locate 15 16
echo Type the corresponding number, then press enter...
rem Locate 17 16
set /p MenuChoice=
if %MenuChoice% == 1 goto start
if %MenuChoice% == 2 goto help
if %MenuChoice% == 3 exit
goto menu

:help
cls
title Money Madness - Help
pause
goto menu

:start
cls
title Money Madness - The Game
set o1 = 13
set o2 = 15
cls
rem ChangeColor 11 0
rem ShadeBoxAt 6 31 15 1 4
rem ShadeBoxAt 20 32 1 19 4
rem ShadeBoxAt 6 50 14 1 4
rem ShadeBoxAt 6 32 1 18 4
rem ChangeColor 10 0
rem Locate %o1% %o2%
echo a
pause

尽管我已经尝试过,但是我无法使它正常工作。

1 个答案:

答案 0 :(得分:1)

set命令中空格很重要。您已经创建了一个名为%o1 %的变量,其值为 13和一个名为%o2 %的变量,其值为 15。删除空格(并添加引号,以便您不会在结尾处意外添加多余的空格)。

:start
cls

title Money Madness - The Game

set "o1=13"
set "o2=15"

cls
rem ChangeColor 11 0
rem ShadeBoxAt 6 31 15 1 4
rem ShadeBoxAt 20 32 1 19 4
rem ShadeBoxAt 6 50 14 1 4
rem ShadeBoxAt 6 32 1 18 4
rem ChangeColor 10 0
rem Locate %o1% %o2%
echo a
pause