Filter out Number

March 13, 2010 at 10:21:59
Specs: Windows 7
I am trying to find a way to filter out the number 13 based from an input. I have a variable SET _MAXST=18 which is where I check. If the number is less than 1, it needs to go to MESSAGE, if it is larger than _MAXST, it also needs to go to MESSAGE, if is any other number 1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18 these are linking to INDIVIDUAL.

%choice% contains the users input.
This what I have

set /p choice=Type your number between 1 and 18:
IF /i '%choice%' LSS '1' (
goto MESSAGE
) ELSE (
IF /i '%choice%' LEQ '%_MAXST%' (
goto INDIVIDUAL
)
)

The output is the following message:
The system cannot find the file specified.

Any help would be extremely appreciated as the variable _MAXST could be adjusted to say 20 or 25 later if needed.


See More: Filter out Number

Report •

#1
March 13, 2010 at 13:09:45
@echo off
set _Maxst=18
set /p choice=Type your number between 1 and 18:
echo %choice% %_Maxst%
if %choice% NEQ 13 (
IF %choice% LSS 1 goto MESSAGE
IF %choice% LEQ %_MAXST% (goto INDIVIDUAL
) else (goto Message)
)
goto Done

:Message
echo Message
goto Done

:Individual
echo Individual
:Done
echo Done


Report •

#2
March 13, 2010 at 13:39:43
That is exactly what I was looking for. Thank you so much for assisting me with that.

I am glad that others can see beyond my problem and give me a solution.


Report •

#3
March 13, 2010 at 17:05:44
Hi dtech10,

I haven't seen you for a while.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
March 14, 2010 at 03:35:00
Adapted from response nr. 1
- using _Maxst as a variable, everywhere where needed
- changed usage of blocks to GOTO's (still bad programming but more readable IMO)
- catching empty response from SET

@echo off

set _Maxst=18

:question
set /p choice=Type your number between 1 and %_Maxst% (excluding 13) :
if "%choice%"=="" goto :question
echo %choice% %_Maxst%

if %choice% EQU 13 goto :question
IF %choice% LSS 1 goto :MESSAGE
IF %choice% LEQ %_MAXST% goto :INDIVIDUAL
:goto Message

:Message
echo Message
goto :EOF

:Individual
echo Individual
goto :EOF


Report •

#5
March 14, 2010 at 13:34:56
Hi Mechanix

I pop in now and again.
Nice to be missed.


Report •

Ask Question