I'm having difficulty with number comparisons like <, >, and == in my Batch code. What Im doing is generating a random number and using that answer to do something, this is what I've written:
set rand=%random%
set rand=%rand:~1,1%
If %rand%==9 goto nine
If %rand%>5 goto above 5
If %rand%>1 goto above 1
If %rand%==0 goto zero
And the code just closes when I run it. I tried putting space between the two objects being compared and the inequality but it still doesn't work.
Remember, this is Batch code on Windows.
For the if
commands use these keys instead of the equal and greater than symbols:
EQU - equal
NEQ - not equal
LSS - less than
LEQ - less than or equal
GTR - greater than
GEQ - greater than or equal
But I would suggest using ==
instead of EQU
. It is easier to type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With