FOR %%VV IN (1 2 3) DO ECHO %%VV, why single V always?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

FOR %%VV IN (1 2 3) DO ECHO %%VV, why single V always?

#1 Post by nnnmmm » 30 Aug 2017 00:26

FOR %%VV IN (1 2 3) DO ECHO %%VV

why cant you have double V as a variable, why single always? what do call this kind of variable?

what if you run out of variables?

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: FOR %%VV IN (1 2 3) DO ECHO %%VV, why single V always?

#2 Post by ShadowThief » 30 Aug 2017 00:33

nnnmmm wrote:why cant you have double V as a variable, why single always?

Because that's how Microsoft decided to do it.

nnnmmm wrote:what do call this kind of variable?

A for loop variable. You may also see it called a for loop parameter or a token.

nnnmmm wrote:what if you run out of variables?

Then you seriously need to re-evaluate how you're parsing the data. Also, you aren't limited to letters; you can use almost any of the 128 basic ASCII characters.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: FOR %%VV IN (1 2 3) DO ECHO %%VV, why single V always?

#3 Post by penpen » 30 Aug 2017 03:17

You could use "enough" for-variables.

Key idea accessing huge amounts of for-variable names:
http://www.dostips.com/forum/viewtopic.php?p=51537#p51537.

List of characters that could be used as a for-variable name (in hexadecimal):
http://www.dostips.com/forum/viewtopic.php?p=51622#p51622.
(see Point 4)

You also could use many tokens simultaniously:
http://www.dostips.com/forum/viewtopic.php?p=51595#p51595.


penpen

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: FOR %%VV IN (1 2 3) DO ECHO %%VV, why single V always?

#4 Post by Squashman » 30 Aug 2017 11:30

Please read the documentation for a command before you ask questions.

The help file for the FOR command is quite clear. All you had to do was read the first 3 lines of the help file for the FOR command.

Code: Select all

H:\>for /?
Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a single letter replaceable parameter.


Single does not equal double.

nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

Re: FOR %%VV IN (1 2 3) DO ECHO %%VV, why single V always?

#5 Post by nnnmmm » 30 Aug 2017 14:38

sorry about the question,
i just had to ask that once in my life as to what experts think about it.

Post Reply