|
Answer» Hello, I would like to ask what -1 means in this part of batch FILE ?
choice /C:0123456789ABCDEF Specify text color: set /A SRIFTAS=%errorlevel%-1It means "minus one". If you read the SET DOCUMENTATION -- type SET /? at the prompt -- you will see what SET /A means. Hint: A is for Arithmetic.
Thanks It subtracts one.
The logic is this:
1. User presses a key whose character is in this string: 0123456789ABCDEF
2. Choice.exe returns a value in %errorlevel% which is the position of this character from the start of this string. If the user presses 0 then the errorlevel will be 1 (because 0 is the first character in the string), if the user presses F then choice.exe will return 16 (because F is the 16th character).
3. You will notice that these VALUES are 1 more than the hex value represented by each character.
4. The parameters for the Color command start at 0 therefore you need to SUBTRACT 1 from %errorlevel%.
|