|
Answer» Hello, I am having some trouble diagnosing a syntax error and was wondering if anyone could help.
I have narrowed it down to the line between the two pauses
Code: [Select]... :ok4 set a=0 set b=0 cls echo Enter Red 1's score (##) set /p red1= if "%red1:~0,1%" =="1" set a=1 if "%red1:~0,1%" =="2" set a=1 if "%red1:~0,1%" =="3" set a=1 if "%red1:~0,1%" =="4" set a=1 if "%red1:~0,1%" =="5" set a=1 if "%red1:~0,1%" =="6" set a=1 if "%red1:~0,1%" =="7" set a=1 if "%red1:~0,1%" =="8" set a=1 if "%red1:~0,1%" =="9" set a=1 if "%red1:~0,1%" =="0" set a=1 if "%red1:~1,1%" =="1" set b=1 if "%red1:~1,1%" =="2" set b=1 if "%red1:~1,1%" =="3" set b=1 if "%red1:~1,1%" =="4" set b=1 if "%red1:~1,1%" =="5" set b=1 if "%red1:~1,1%" =="6" set b=1 if "%red1:~1,1%" =="7" set b=1 if "%red1:~1,1%" =="8" set b=1 if "%red1:~1,1%" =="9" set b=1 if "%red1:~1,1%" =="0" set b=1 set /a c=%a%+%b% if "%c%" =="2" goto ok5
:ok5 set a=0 set b=0 cls echo Enter Red 2's score (##) set /p red2= pause if "%red2:~0,1%” =="1" set a=1 pause if "%red2:~0,1%” =="2" set a=1 if "%red2:~0,1%” =="3" set a=1 if "%red2:~0,1%” =="4" set a=1 if "%red2:~0,1%” =="5" set a=1 if "%red2:~0,1%” =="6" set a=1 if "%red2:~0,1%” =="7" set a=1 if "%red2:~0,1%” =="8" set a=1 if "%red2:~0,1%” =="9" set a=1 if "%red2:~0,1%” =="0" set a=1 if "%red2:~1,1%” =="1" set b=1 if "%red2:~1,1%” =="2" set b=1 if "%red2:~1,1%” =="3" set b=1 if "%red2:~1,1%” =="4" set b=1 if "%red2:~1,1%” =="5" set b=1 if "%red2:~1,1%” =="6" set b=1 if "%red2:~1,1%” =="7" set b=1 if "%red2:~1,1%” =="8" set b=1 if "%red2:~1,1%” =="9" set b=1 if "%red2:~1,1%” =="0" set b=1 set /a c=%a%+%b% if "%c%" =="2" goto ok6 goto ok5 ...
Thanks a ton!Isit not obvious?
Code: [Select]if "%red2:~0,1%” =="1" set a=1
Quote D:\bat>if "%red2:~0,1%” =="1" set a=1 The syntax of the command is incorrect. D:\bat>
Code: [Select]if "%red1:~0,1%" =="1" set a=1The above works fine. What are you trying to do?
My vision is very poor, but I can see the PROBLEM. Is this a quiz?
Quote from: Geek-9pm on March 13, 2012, 12:28:40 AMIsit not obvious?
Code: [Select]if "%red2:~0,1%” =="1" set a=1
Code: [Select]if "%red1:~0,1%" =="1" set a=1The above works fine. What are you trying to do?
My vision is very poor, but I can see the problem. Is this a quiz?
What is difference in the two lines of code?As I said in the PM, you used EXTENDED ASCII code.
Quote from: Geek-9pm on March 13, 2012, 12:28:40 AMIsit not obvious?
Code: [Select]if "%red2:~0,1%” =="1" set a=1
Code: [Select]if "%red1:~0,1%" =="1" set a=1The above works fine. What are you trying to do?
My vision is very poor, but I can see the problem. Is this a quiz?
I am writing a questionare to fill out a txt file in a certain format. this line is to make sure that the imput for red2 =## and not a bunch of letters and no, I'm on a FIRST robotics team, and my friend wanted this for his php server.
Quote from: Geek-9pm on March 13, 2012, 10:02:34 AMAs I said in the PM, you used extended ASCII code.
Not sure what you mean by this.
QuoteNot sure what you mean by this.
One of the quotes chars is not the right one. In the first ASCII set there is only one; it looks like this: " Most keyboards will not generate chars beyond code 127. And such chars from 128 up has to come from the on-screen keyboard. Or some word process editors use the emended pair. They look like this: “ ” I can force those codes by holing the alt key and hitting 223 or 224 on the numeric pad. (Hard to do on a laptop, takes 3 fingers.) This link below is for reference for all that wish to dig deeper into what 'extended ASCII' means in the jargon. http://www.ascii-code.com/ Moral: don't use strange chars in a batch file. if "%red2:~0,1%” =="1" set a=1 ^ | don't use smart quotes
Quote from: Salmon Trout on March 13, 2012, 12:43:12 PM if "%red2:~0,1%” =="1" set a=1 ^ | don't use smart quotes
MIND = blown
thanks guys
|