How can I goto a label if the answer is incorrect?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ironmanmk29
Posts: 11
Joined: 02 May 2015 00:13

How can I goto a label if the answer is incorrect?

#1 Post by ironmanmk29 » 16 Sep 2015 10:13

so, I was wondering if there was a way to make it so that if you answer anything that is not the correct answer then it goes to incorrect. put in my line of code and I wanted to know how to make it correct. [If "%problemtest1%'==" " goto incorrect]

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Batch

#2 Post by Squashman » 16 Sep 2015 10:22

Code: Select all

IF "%problemtest1%"=="correctanswer" (
   goto correct
) ELSE (
   goto incorrect
)

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Batch

#3 Post by Compo » 17 Sep 2015 11:11

Just to make the response better tailored to the question.
ether:

Code: Select all

IF NOT "%problemtest1%"=="correctanswer" GOTO incorrect
or:

Code: Select all

IF "%problemtest1%" NEQ "correctanswer" GOTO incorrect
Bear in mind that the comparisons are case sensitive, to remove that include the /I switch to follow IF.

Post Reply