标题: [求助] 98 FOR 的 DO 后面要接一条以上的语句应该怎么办 [打印本页] 作者: NaturalJ0 时间: 2006-8-15 19:11 标题: [求助] 98 FOR 的 DO 后面要接一条以上的语句应该怎么办
运行环境是98最简启动盘(三文件)加了一个 98 的 FIND.EXE 文件
c:\num.txt 内容为
num=2
1.bat 内容为
@echo off
FOR %%i in (1,2,3) do find "num=%%i" c:\num.txt>nul & if errorlevel 0 if not errorlevel 1 set num=%%i
echo num=%num%
运行结果是
C:\>1
File not found - &File not found - ifFile not found - errorlevelFile not found
0File not found - ifFile not found - notFile not found - errorlevelFile not fo
nd - 1File not found - setInvalid keyword
File not found - &File not found - ifFile not found - errorlevelFile not found
0File not found - ifFile not found - notFile not found - errorlevelFile not fo
nd - 1File not found - setInvalid keyword
File not found - &File not found - ifFile not found - errorlevelFile not found
0File not found - ifFile not found - notFile not found - errorlevelFile not fo
nd - 1File not found - setInvalid keyword
num=
C:\>_
3.bat 内容为
@echo off
find "num=1" c:\num.txt>nul
if errorlevel 0 if not errorlevel 1 set num=1
find "num=2" c:\num.txt>nul
if errorlevel 0 if not errorlevel 1 set num=2
find "num=3" c:\num.txt>nul
if errorlevel 0 if not errorlevel 1 set num=3
echo num=%num%
运行结果是
C:\>3
num=2
C:\>_
请问像这种情况,FOR 应该怎么写?非常感谢。
[ Last edited by NaturalJ0 on 2006-8-16 at 15:22 ]作者: NaturalJ0 时间: 2006-8-16 10:14 难道只能调用另一个 BAT ?有没办法就在这一个 BAT 中解决问题?作者: namejm 时间: 2006-8-16 10:27 看了你的代码,意图似乎是读取num.txt的内容,type c:\num.txt不就成了吗?只是不知道type是不是98的内部命令。作者: NaturalJ0 时间: 2006-8-16 10:36 非常感谢楼上的回复。
我的愿意是要读里面的值给变量,后面的处理中想用变量。
[ Last edited by NaturalJ0 on 2006-8-16 at 10:37 ]作者: namejm 时间: 2006-8-16 11:37