I suggested using Set /A where you are asking a user to type in a number.
Code:
Set /P _Resp="Enter a number"
If %_Resp% LEQ 10 Echo You entered a number less than 10.
If they just press enter, the IF statement will fail. If you use Set /A, it will convert the null entry to 0. No need to check for a null entry, or having to quote both sides of the condition if you can accept pressing Enter as zero.
Code:
Set /P _Resp="Enter a number"
Set /A _Resp=_Resp
If %_Resp% LEQ 10 Echo You entered a number less than 10
It can also be used to remove leading spaces from a number.
Some of the special characters are treated as regular characters when they appear between quotes:
Compare these lines:
Code:
Echo This string ^ has a Special Character
Echo "This string ^ has a Special Character"
Echo This string ^ has some | Special Characters
Echo "This string ^ has some | Special Characters"
Echo This string & has some | Special Characters
Echo "This string & has some | Special Characters"
If you don't want the quotes, you have to escape the characters.
Works with redirection characters as well
Code:
Echo This string has a Special Char>acter
This will create a file named
acter in the current directory that contains the string
This string has a Special Char Code:
Echo "This string has a Special Char>acter"
This will output the line to the screen.
I didn't try changing the parentheses until now. I removed the outermost pair, and both of these work for me, as did removing the outermost pair for the dividend:
Code:
set /a number=((%random% - %minrand%) * %range%) / ((%rangerand% + %min%) ^^ %rand%)
set /a number="((%random% - %minrand%) * %range%) / ((%rangerand% + %min%) ^ %rand%)"
set /a number="(%random% - %minrand%) * %range% / ((%rangerand% + %min%) ^ %rand%)"
If you remove the outermost pair from the
divisor, it will still work, but it changes the formula. Without those parentheses, the division will be done first, then the XOR will be done to the result as XOR has a lower precedence.