找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 23919|回复: 6

[其他] 【已解决】批处理Set语法为何无法做出正确判断?

[复制链接]
发表于 2019-2-3 23:34:39 | 显示全部楼层 |阅读模式
下面这串代码有谁能告诉我错在哪里嘛,运行起来是正常的但是,但是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. )
复制代码
发表于 2019-2-4 17:12:12 | 显示全部楼层
可怕的代码,可怕的缩进
 楼主| 发表于 2019-2-4 19:46:25 | 显示全部楼层
回复 2# 老刘1号


    你好,新年快乐,能告诉我错在哪了嘛
发表于 2019-2-5 23:03:58 | 显示全部楼层
本帖最后由 老刘1号 于 2019-2-5 23:07 编辑

回复 3# 小渣飞


    新年快乐,貌似没错
可能是cmd处理不了1640长度的语句
无意义的else,可以写成多行;也可以使用for来简化代码
 楼主| 发表于 2019-2-6 00:02:31 | 显示全部楼层
回复 4# 老刘1号

受教了谢谢您,但X部分好像是没有错的,echo %A% 显示的是正确的,但是一到Y就就不正常了,
发表于 2019-2-6 07:31:10 | 显示全部楼层
本帖最后由 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:36 | 显示全部楼层
本帖最后由 小渣飞 于 2019-2-6 13:32 编辑

回复 6# flashercs


    啊~这个问题困扰了我两天终于解决了,原来问题出在这太大意了,太谢谢你祝你新年快乐=-=
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-21 03:28 , Processed in 0.029598 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表