首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >批处理脚本崩溃

批处理脚本崩溃
EN

Stack Overflow用户
提问于 2014-06-08 19:43:41
回答 1查看 89关注 0票数 0

我的批处理脚本一直与便条一起崩溃:

“布景在这个时候出乎意料”

我只能通过一帧一帧的视频记录和检查。

下面是脚本:

代码语言:javascript
复制
@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
EN

回答 1

Stack Overflow用户

发布于 2014-06-08 21:22:15

您正在运行的代码是(简化版本)。

代码语言:javascript
复制
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%仍然没有被赋值,所以它是空的,执行的行是

代码语言:javascript
复制
if ==18 set var=0

rand1有一些值(示例中的18 ),rand2没有值,结果是set was unexpected at this time

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24110124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档