1.

Solve : batch files & variables?

Answer» QUOTE from: contrex on September 24, 2007, 12:42:33 PM

Quote from: TheHamelinPiper on September 24, 2007, 12:03:19 PM
what is are the "%%" about.. i know when using a varible that is already set you surround the var name in then



Quote
You have "ordinary" variables which are like %this%

set fruit=apple

echo %fruit%

if "%fruit%"=="orange" echo PEEL me now

etc

Then you have FOR variables. They are different. At the COMMAND line they have ONE percent sign, in a batch file they have two.

FOR %%VARIABLE IN (data set) do (
something
)

Get a good batch scripting book.



Quote from: contrex on September 24, 2007, 02:22:04 PM
You have 52 possible variables that can exist at the same time in the same batch... %%a to %%z and %%A to %%Z (i.e. case matters)


does that apply "across the board" or only for the FOR command?

suppose %var%, %var2%....%var52% .. can there be a %var53%

OR is that some backwards compatible rule for running on older versions of dos?

OR OR did you just mean exactly what you said.. there can only be 52 variables within the same batch (excluding system variables i assume)
There can only be 52 of the special FOR variables eg %%A %%z active at any one time within the same batch file. Reason: They are case sensitive and there are only 26 letters of the alphabet. You can have any number of ordinary variables eg %apples% %pears%.

Quote
suppose %var%, %var2%....%var52% .. can there be a %var53%

Sure. There can be a %var99999999% and more...





Discussion

No Comment Found