sambul35 wrote:How these expressions work?
I can't find on the web a
SET /P syntax without variable name. Also redirection
< nul is not explained anywhere I looked.
![Wink :wink:](./images/smilies/icon_wink.gif)
Using a variable in a set /p statement is totally optional; it's just that the vast majority of the time, you want to set user input to something. In this case, you have the option of setting it to a variable that you'll never use, but there's no point.
< is the input redirection operator. When combined with a set /p command, this will set the variable to the first line of the file. For example,
set /p first_line=<file.txt will set the variable %first_line% to the first line of file.txt.
nul is a non-existent file (it's the same thing as /dev/null if you're familiar with Linux). Since the first line of nothing is nothing, <nul passes nothing to the set /p command, so a variable would also be set to nothing, except we're not using a variable here, so all the code does is display the prompt string without taking input from the user.
This code is used to display text without ending the string in a newline character like echo does.
sambul35 wrote:Does that select a digit from the
digits array matching errorlevel value?
Yes, it returns the %errorlevel%th digit in the array (with the first digit being at position 0).