我如何仅通过用户输入接受以下值?
即
SET /P POSID=Enter POS Number:
SET test=1%POSID%
IF %test% EQU 11, 12, 13, 14, 15 (11-15) 21, 22, 23, 24,25 (21-25) GOTO POSIDGOOD
答案 0 :(得分:3)
for %%a in (11, 12, 13, 14, 15, 21, 22, 23, 24,25) do if "%posid%"=="%%a" GOTO POSIDGOOD
echo bad posid
答案 1 :(得分:0)
setlocal
for %%a in (11 12 13 14 15 21 22 23 24 25) do set valid[%%a]=true
SET /P POSID=Enter POS Number:
if defined valid[%POSID%] GOTO POSIDGOOD
echo bad posid
您可以使用previous answer的相同变量:
if defined posNum[%POSID%] GOTO POSIDGOOD