| 1. |
Solve : IF statement with variable? |
|
Answer» Hello, I am pretty sure that my problem is with the IF statements, but I am not sure what I am doing wrong. Thank you in advance for reading through this and I look forward to any guidance anyone can offer. Your problem is, that code is not batch language. It is some other language maybe not yet invented. There are 2 problems. The IFs and the labels. (1) IF statements in batch are usually like this on one line. You don't have "END". IF %ip% GTR 200 goto group1 IF %ip% GTR 190 goto group2 (2) You got the labels back-to-front. The colon goes BEFORE the label name :group1 .....do stuff.... EXIT :group2 .....do stuff.... EXIT It is not compulsory to put *anything* in a batch file in capital letters. If you want a multiline if, use braces (parentheses) like this if %ip% gtr 200 ( echo it was more than 200 echo another line goto group1 ) :group1 Or use & like this if %ip% gtr 200 echo more than 200 & echo some more text & goto group1 |
|