Thursday, 15 September 2011

Squaring step variable - Batch for loop -


Whether it is possible to group increments / step increment in batches for loops.

This is exactly what it looks like

  FOR / L %% A IN (1024,1000, 1048576) DO (do stuff)  < / Pre> 

Although going up to 1000 every time, I want to go above 2 ^ 10, 2 ^ 11 ... 2 ^ 20 (1048576) Is it possible to do this?

No, for the the / l end can not control the geometric growth But you can use batch arithmetic for it

 for  / l %% a in (10 1 20) do (set / a " A = 1 & lt; & lt; %% for a setlocal enabledelayedexpansion %% (!!!) (Endoklal your code here - echo the material %% A))  

Delayed detail is required to change variable variables inside the blocks of code if your internal code If there is no problem with delayed extension being activated, then it can be simplified

  for setlocal enabled extensions / l %% Do a (10 1 20) in (set / an "A = 1"  
< / Html>

No comments:

Post a Comment