各位哥哥、姐姐:您好!
请帮我一把,我实在是无能为力了,昨天写了一个简单的获取命令参数的程序,老是显示第一个参数a,而不显示其它参数(b,c),变成了废物,各位高手也调诫不出来,代码如下:- @echo off
- rem useage: testargs.bat a b c
- setlocal enabledelayedexpansion
- for /l %%i in (1,1,3) do (
- echo %1
- shift
- )
复制代码 运行结果如下:
a
a
a
今天,按照各位高手的教导改进了一下,可是%%i变成了废物,只运行了一次,就完蛋了!代码如下:- @echo off
- rem testargs.bat
- rem useage: testargs.bat a b c
- setlocal enabledelayedexpansion
- set/a count=0
- for /l %%i in (1,1,3) do (
- echo "%%i is :" %%i
- goto y:
-
- :x
- echo %%i
- shift
- goto :y
- )
-
- :y
- set/a count+=1
- echo "arg%count% is :" %1
- if %count%==3 goto :eof
- goto :x
复制代码 运行结果如下:
"1 is :" 1
"arg1 is :" a
%i
"arg2 is :" b
%i
"arg3 is :" c
恳请各位哥哥姐姐伸手救助小弟一把,该死的batch编程太难了! |