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
  • 11

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
  • 72,034
  • 7
  • 58
  • 78
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
  • 61,954
  • 12
  • 66
  • 99