如何在CMD批处理脚本中调用一个标签,当你使用超过9参数呢? [英] How do you utilize more than 9 arguments when calling a label in a CMD batch-script?
问题描述
我想知道如何调用一个标签时批处理脚本中调用超过9说法。例如,下面的节目,我有12个参数分配以及试图呼应他们。
I would like to know how to call more than 9 argument within a batch script when calling a label. For example, the following shows that I have 12 arguments assigned along with attempting to echo all of them.
CALL:LABEL "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve"
PAUSE
GOTO:EOF
:LABEL
echo %1
echo %2
echo %3
echo %4
echo %5
echo %6
echo %7
echo %8
echo %9
echo %10
echo %11
echo %12
为10%,11%和%12的输出最终被one0 one1 one2。我已经使用大括号,括号,报价单,围绕数字单引号没有任何运气尝试。
The output for %10 %11 and %12 ends up being one0 one1 one2. I've tried using curly brackets, brackets, quotations, single quotes around the numbers without any luck.
推荐答案
有是 移
该命令。
There is the shift
command for that.
您可以使用一个循环,转移前的变量存储,或者做快速的是这样的:
You can either use a loop, store the variables before shifting, or do it quick like this:
CALL:LABEL "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve"
PAUSE
GOTO:EOF
:LABEL
echo %1
echo %2
echo %3
echo %4
echo %5
echo %6
echo %7
echo %8
echo %9
shift
shift
shift
echo %7
echo %8
echo %9
您可以在情况下,你有很多参数的循环更换换档命令。对于循环的执行移
九次,使%1
将成为第十个参数。
You can replace the shift commands with a loop in case you have many arguments. The following for loop executes shift
nine times, so that %1
will be the tenth argument.
@for /L %%i in (0,1,8) do shift
这篇关于如何在CMD批处理脚本中调用一个标签,当你使用超过9参数呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!