mardi 19 décembre 2017

Comparing "+" symbol with variable entered by user using if statement in batch file

So I have some problems with batch file
File should accept input of 2 numbers from user and then accept input of sign
after that compare users entered sign with "+" sign, however it's not working...
Prob my explanation isn't very clear, but maybe u will be able to understand better from my code:

echo please enter first number
set /p number0=

echo please enter second number
set /p number1=

echo enter one of the numbers - ^+ - / ^*
set /p symbol="set the variable: "

echo %symbol%
set plus=+
echo %plus%
pause

if /i "%symbol%" EQU "+"(
    echo your choice is to sum up the numbers
    pause
    set /a answ = %number0% + %number1%
    echo answer:
    echo %answ%
)

So i already tried using if /i %symbol% == plus, tried to use quotes in any combination i was able to imagine
tried to assign operator plus variable like this set /p plus="+" then using "" around symbol variable, and so on....
But still nothing works, after i reach part where variable should be compared with symbol + my batch file just crashes.
*ps all variables are assigned correctly
waiting for any help as soon as possible
thats the link to see full file if its necessary, however please note that full file isn't written in English language https://1drv.ms/u/s!Ap4-t2P-Igzihb5shQZLNkKySEWOrQ

Aucun commentaire:

Enregistrer un commentaire