|
Answer» This is what i want my batch to do:
set var2= set /p var2=var2:
if %var1% GTR %var2% goto ___ if %var1% LSS %var2% goto ___
var2 has to be a VARIABLE as it is set by the user each TIME the batch is run. unfortunatley %var2% is ignored each time. What am i doing wrong?Not sure what you mean by var2 being ignored but a COUPLE of things come to mind.
Where did var1 come from and what is it's value? What is your plan if var1 = var2?
When checking batch files it's best to leave echo on so you can see the values and how the file behaves during execution.
This isn't a complete script. var1 would come from earlier on.
As for if var1=var2 i meant to use GEQ and LSS.
What i mean by var2 being ignored is: for example if var2 was set as 10 by the user, it doesn't check if var1 is equal to or greater than 10. With echo on it looks like this: if %var1% GTR goto ___ (var2 is missing) Therefore the line does nothing and the script continues.
I have checked and it does work if I put: if %var1% GEQ 10 goto ___.Syntactically there is nothing wrong with your code. I even tested it and it checks out fine. The place to start MONITORING the code is not the if statement, but the set /p var2 statement.
Just for laffs, what OS are you using?
This is weird. Ive just been fiddling about with different layouts/syntax etc. and my PROBLEM is fixed The strange thing is ive been back over it and it looks the same as it did the first time i tried. Thanks for the help anyhow.
BTW OS is Vista home premium
|