| 1. |
Solve : Help with .bat and IF / ELSE commands? |
|
Answer» Hey all notice I added "/i" this will make the if statement compare them as integers. No it won't; using if with the /i switch makes the comparison case-insensitive, or makes it ignore case if you prefer. Since numerical digits don't have "upper" or "lower" case, it will have no effect whatsoever. Quote I've also added the " " around the values we're comparing Good practice Quote and I stuck it on one line cos I reakon it's easier to read. Ditto This is an alternative Code: [Select]if "%variable%"=="1" (start test.bat) else goto test2 Quote from: Dias de verano on May 09, 2008, 10:50:00 AM Quote from: blastman on May 09, 2008, 08:30:06 AMnotice I added "/i" this will make the if statement compare them as integers. I may have miss understood the explaintion for the help option. "and the /I switch, if SPECIFIED, says to do case insensitive string compares. The /I switch can also be used on the string1==string2 form of IF." and the bit that confused me... "These comparisons are generic, in that if both string1 and string2 are both comprised of all numeric digits, then the stings are converted to numbers and a numeric comparison is performed" I guess I thought that last section was part of the explation of the /I switch. oh well. as long as it works eh??? Quote from: blastman on May 09, 2008, 01:41:19 PM the bit that confused me... That means decimal (or lesser base) integers (the only numbers that don't contain punctuation or letters) are compared as numbers, everything else as strings. (Numeric comparisons are made as if all the numbers were base ten, so comparing an octal and a decimal number would often give wrong results.) Thanks for the reply guys and it works |
|