Your current code suggests that only entries of 0
and 1
are permitted. According to your comment however, your intention is to receive inputs of only 0
, 1
, 2
, 3
, 4
, 5
, 6
, and 7
. The easiest way to do that is to use the correct command; the choice
command!
The choice
command, (technically the built-in choice.exe
utility), benefits in that you can only submit entries which match those listed at its /C
option.
@Echo Off
SetLocal EnableExtensions
Color 1F
ClS
Echo(
%__AppDir__%choice.exe /C 01234567
Set /A A = %ErrorLevel% - 1
Echo Valore %A%
Pause
To learn how to use the choice
command, open a Command Prompt window, type choice /?
, and press the ENTER key.
From the usage information you could then, if you still wanted to not give your end user an indication of what their possible choices, (sceltas), were, you could match your initial prompt:
%__AppDir__%choice.exe /C 01 /N /M "Scelta:"