The following code is not working. Whatever I input just returns an error, and then goes back to Retry
.
@echo off
:maths
set /p Mathsa=\"first
It's the quotes around your Mathso
variable. Change them all to use quotes around both sides of the equality, such as with:
if "%Mathso%" == "+" GOTO run
and they should work better.
The reason for this is that cmd
is not quite the same as UNIXy shells. The quotes are preserved on the left hand of the equality so that what you end up with is:
if "+" == + then ...
and "+"
is not equal to +
.
By putting quotes on both sides, it becomes:
if "+" == "+" then ...
which is true.
And, as Aacini points out in the comment, your calculation set
uses the wrong variable for the operator. You should change:
set /a Mathsans=%Mathsa%%Mathsp%%Mathsb%
into:
set /a Mathsans=%Mathsa%%Mathso%%Mathsb%
^
|
see here