我的批处理脚本与注释一起崩溃:
“此时设置意外”
我只能通过视频录制和逐帧检查才能看到 这是脚本:
@echo off
color 6f
set min=0
set max=25
goto REDIR
:REDIR
set var=0
goto TOP
:TOP
cls
set /a var=%var%+1
set /a rand%var%=%random% %% (max - min + 1)+ min
if %rand2%==%rand1% set var=0&goto TOP
if %rand3%==%rand2% set var=1&goto TOP
if %rand4%==%rand3% set var=2&goto TOP
if %rand5%==%rand4% set var=3&oto TOP
if %rand6%==%rand5% set var=4&goto TOP
if %rand7%==%rand6% set var=5&goto TOP
if %rand8%==%rand7% set var=6&goto TOP
if %rand9%==%rand8% set var=7&goto TOP
if %rand10%==%rand9% set var=8&goto TOP
if %rand11%==%rand10% set var=9&goto TOP
if %rand12%==%rand11% set var=10&goto TOP
if %rand13%==%rand12% set var=11&goto TOP
if %rand14%==%rand13% set var=12&goto TOP
if %rand15%==%rand14% set var=13&goto TOP
if %rand16%==%rand15% set var=14&goto TOP
if %rand17%==%rand16% set var=15&goto TOP
if %rand18%==%rand17% set var=16&goto TOP
if %rand19%==%rand18% set var=17&goto TOP
if %rand20%==%rand19% set var=18&goto TOP
if %rand21%==%rand20% set var=19&goto TOP
if %rand22%==%rand21% set var=20&goto TOP
if %rand23%==%rand22% set var=21&goto TOP
if %rand24%==%rand23% set var=22&goto TOP
if %rand25%==%rand24% set var=23&goto TOP
if %rand26%==%rand25% set var=24&goto TOP
if %var%==26 goto SHOW
goto TOP
:SHOW
cls
echo A=%rand1%
echo B=%rand2%
echo C=%rand3%
echo D=%rand4%
echo E=%rand5%
echo F=%rand6%
echo G=%rand7%
echo H=%rand8%
echo I=%rand9%
echo J=%rand10%
echo K=%rand11%
echo L=%rand12%
echo M=%rand13%
echo N=%rand14%
echo O=%rand15%
echo P=%rand16%
echo Q=%rand17%
echo R=%rand18%
echo S=%rand19%
echo T=%rand20%
echo U=%rand21%
echo V=%rand22%
echo W=%rand23%
echo X=%rand24%
echo Y=%rand25%
echo Z=%rand26%
pause
goto REDIR
答案 0 :(得分:1)
您运行的代码是(简化版)
set var=0
set /a var=%var%+1
set /a rand%var%=%random% %% (max - min + 1)+ min
if %rand2%==%rand1% set var=0&goto TOP
当达到if
时,%rand2%
仍未分配值,因此它为空并且执行的行是
if ==18 set var=0
rand1
有一定价值(示例中为18),rand2
没有值,结果为set was unexpected at this time