Board logo

标题: [其他] [已解决]批处理if如何使用变量嵌套? [打印本页]

作者: smg无聊人    时间: 2021-1-6 18:55     标题: [已解决]批处理if如何使用变量嵌套?

本帖最后由 smg无聊人 于 2021-1-31 01:01 编辑

if如何使用变量嵌套


主程序
  1. set EBlognum=1
  2. call Blogexist.bat
  3. set StartEBlognum=%EBlognum%
  4. :Next
  5. set /a EBlognum=%EBlognum%+1
  6. set /a AV=%EBlognum%-%StartEBlognum%
  7. call if %%NEB%EBlognum%%%==E goto NBBlog
  8. if %AV%==101 exit
  9. goto Next
  10. :NBBlog
  11. echo 文章存在(文章编号:%EBlognum%)
  12. pause
复制代码
Blogexist.bat
  1. set NEB0=E
  2. set NEB88=E
复制代码
上一个帖子没说清楚意思实在不好意思
这次说清楚意思了
麻烦了
谢谢
作者: WHY    时间: 2021-1-6 19:55

  1. @echo off
  2. set EBlognum=1
  3. call Blogexist.bat
  4. set StartEBlognum=%EBlognum%
  5. :Next
  6. set /a EBlognum += 1
  7. set /a AV=EBlognum - StartEBlognum
  8. call set "xx=%%NEB%EBlognum%%%"
  9. if "%xx%"=="E" goto NBBlog
  10. if "%AV%"=="101" exit
  11. goto Next
  12. :NBBlog
  13. echo 文章存在(文章编号:%EBlognum%)
  14. pause
复制代码
该加引号的必须加引号,否则会出现语法错误,Blogexist.bat 中 E 值后面不能含空格




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