运行环境是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 ]
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 ]
