Board logo

标题: [其他] 【已解决】批处理Set语法为何无法做出正确判断? [打印本页]

作者: 小渣飞    时间: 2019-2-3 23:34     标题: 【已解决】批处理Set语法为何无法做出正确判断?

下面这串代码有谁能告诉我错在哪里嘛,运行起来是正常的但是,但是Y部分就无法做出正确判断了,无论 %A% 是什么都是返回BEGIN
  1. rem 坐标轴X
  2. :X
  3. SET A=
  4. if "!mouseX!"=="2" (SET A=B & GOTO Y) else (if "!mouseX!"=="3" (SET A=B & GOTO Y) else (if "!mouseX!"=="4" (SET A=B & GOTO Y) else (if "!mouseX!"=="5" (SET A=B & GOTO Y) else (if "!mouseX!"=="6" (SET A=B & GOTO Y) else (if "!mouseX!"=="7" (SET A=B & GOTO Y) else (if "!mouseX!"=="11" (SET A=C & GOTO Y) else (if "!mouseX!"=="12" (SET A=C & GOTO Y) else (if "!mouseX!"=="13" (SET A=C & GOTO Y) else (if "!mouseX!"=="14" (SET A=C & GOTO Y) else (if "!mouseX!"=="15" (SET A=C & GOTO Y) else (if "!mouseX!"=="16" (SET A=C & GOTO Y) else (if "!mouseX!"=="20" (SET A=D & GOTO Y) else (if "!mouseX!"=="21" (SET A=D & GOTO Y) else (if "!mouseX!"=="22" (SET A=D & GOTO Y) else (if "!mouseX!"=="23" (SET A=D & GOTO Y) else (if "!mouseX!"=="24" (SET A=D & GOTO Y) else (if "!mouseX!"=="25" (SET A=D & GOTO Y) else (if "!mouseX!"=="29" (SET A=E & GOTO Y) else (if "!mouseX!"=="30" (SET A=E & GOTO Y) else (if "!mouseX!"=="31" (SET A=E & GOTO Y) else (if "!mouseX!"=="32" (SET A=E & GOTO Y) else (if "!mouseX!"=="33" (SET A=E & GOTO Y) else (if "!mouseX!"=="34" (SET A=E & GOTO Y) else (if "!mouseX!"=="38" (SET A=F & GOTO Y) else (if "!mouseX!"=="39" (SET A=F & GOTO Y) else (if "!mouseX!"=="40" (SET A=F & GOTO Y) else (if "!mouseX!"=="41" (SET A=F & GOTO Y) else (if "!mouseX!"=="42" (SET A=F & GOTO Y) else (if "!mouseX!"=="43" (SET A=F & GOTO Y) else (if "!mouseX!"=="46" (SET A=H & GOTO Y) else (if "!mouseX!"=="47" (SET A=H & GOTO Y) else (if "!mouseX!"=="48" (SET A=H & GOTO Y) else (if "!mouseX!"=="49" (SET A=H & GOTO Y)else (if "!mouseX!"=="50" (SET A=H & GOTO Y)else (if "!mouseX!"=="51" (SET A=H & GOTO Y))))))))))))))))))))))))))))))))))))
  5. GOTO BEGIN
  6. rem 坐标轴Y
  7. :Y
  8. if "!mouseY!"=="0" (
  9.                    if "%A%"=="B" GOTO LOGIN
  10.                       if "%A%"=="C" GOTO SEND
  11.                          if "%A%"=="D" GOTO GET
  12.                             if "%A%"=="E" GOTO SET.
  13.                                if "%A%"=="F" GOTO ABOUT REM OK
  14.                                   if "%A%"=="H" GOTO END REM OK
  15. ) else (goto begin
  16. )
复制代码

作者: 老刘1号    时间: 2019-2-4 17:12

可怕的代码,可怕的缩进
作者: 小渣飞    时间: 2019-2-4 19:46

回复 2# 老刘1号


    你好,新年快乐,能告诉我错在哪了嘛
作者: 老刘1号    时间: 2019-2-5 23:03

本帖最后由 老刘1号 于 2019-2-5 23:07 编辑

回复 3# 小渣飞


    新年快乐,貌似没错
可能是cmd处理不了1640长度的语句
无意义的else,可以写成多行;也可以使用for来简化代码
作者: 小渣飞    时间: 2019-2-6 00:02

回复 4# 老刘1号

受教了谢谢您,但X部分好像是没有错的,echo %A% 显示的是正确的,但是一到Y就就不正常了,
作者: flashercs    时间: 2019-2-6 07:31

本帖最后由 flashercs 于 2019-2-6 07:33 编辑

回复 5# 小渣飞

%A%含有空格;不信你echo "%A%"看看。建议改成如下这样:
  1. set "A=F" & goto Y
复制代码
或者
  1. set A=F&goto Y
复制代码

作者: 小渣飞    时间: 2019-2-6 13:28

本帖最后由 小渣飞 于 2019-2-6 13:32 编辑

回复 6# flashercs


    啊~这个问题困扰了我两天终于解决了,原来问题出在这太大意了,太谢谢你祝你新年快乐=-=




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2