0

How do I only accept the following values with user input?

i.e.

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
T-Diddy
  • 125
  • 1
  • 12

2 Answers2

3
for %%a in (11, 12, 13, 14, 15, 21, 22, 23, 24,25) do if "%posid%"=="%%a" GOTO POSIDGOOD
echo bad posid
Magoo
  • 77,302
  • 8
  • 62
  • 84
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

You may use the same variables of my previous answer:

if defined posNum[%POSID%] GOTO POSIDGOOD
Community
  • 1
  • 1
Aacini
  • 65,180
  • 12
  • 72
  • 108