Solved How to use a for loop to check if a variable equals a set of

September 7, 2012 at 13:37:15
Specs: Windows 7, 4.17Ghz 8GB ram
I would like to create a for loop that will check if x is equal to 40-80

Right now I'm using this going to 80

if %x%==40 (
goto regular
)
if %x%==41 (
goto regular
)

Im assuming it would be something like this

where it would start at 40 add 1 every time untill it gets to 80

FOR %%A IN (40 1 80) DO if !X!==%%A GOTO regular

right now it only does it if x is 1, 40 or 80

I think im close but im missing something.

any help would be greatly appreciated.


See More: How to use a for loop to check if a variable equals a set of

Report •


#1
September 7, 2012 at 14:10:38
if %x% geq 40 if %x% leq 80 goto regular

How To Ask Questions The Smart Way


Report •

#2
September 7, 2012 at 14:14:46
I actually solved it my self sorry. it was

FOR /L %%A IN (40, 1, 80) DO if !X!==%%A GOTO regular


Report •

#3
September 7, 2012 at 14:51:33
✔ Best Answer
Well yeah, but my version does like 1/20 of the work yours does, but it's good you got a working version going.

How To Ask Questions The Smart Way


Report •

Related Solutions


Ask Question