How do you utilize more than 9 arguments when calling a label in a CMD batch-script?

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

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.

Answers


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

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

Need Your Help

File sharing between devices using network

android networking send communicate

I want to write a simple app to communicate between devices. I mean send very small files (small images, text or audio files) from one device to another but not using bluetooth or nfc but by intern...

How to instantiate C++ member string reference

c++ string reference instantiation

I have a class with a std::string& as a member of that class. I want to instantiate that reference, but I don't have anything to instantiate it to until a bit later.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.