Change in script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mor.bas
Posts: 66
Joined: 25 Apr 2012 04:28

Change in script

#1 Post by mor.bas » 20 Aug 2012 06:08

SET /P IP_INDEX="Please Enter IP index:[1..5]"
if %IP_INDEX% > 5 echo error

I want that if the user choose number grater then 5 it will output you need to choose number between 1 and 5 and print again
Please Enter IP index:[1..5]

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Change in script

#2 Post by Squashman » 20 Aug 2012 06:12

:Label
SET /P IP_INDEX="Please Enter IP index:[1..5]"
if %IP_INDEX% GTR 5 echo you need to choose number between 1 and 5 && GOTO :Label

mor.bas
Posts: 66
Joined: 25 Apr 2012 04:28

Re: Change in script

#3 Post by mor.bas » 20 Aug 2012 06:25

You need also to check that the user don't choose zero

mor.bas
Posts: 66
Joined: 25 Apr 2012 04:28

Re: Change in script

#4 Post by mor.bas » 20 Aug 2012 06:41

And also to check the input is a number and not string or something else

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Change in script

#5 Post by Squashman » 20 Aug 2012 06:41

mor.bas wrote:You need also to check that the user don't choose zero

Wow!!!! That is pretty demanding. Since when do you tell other people what they need to do.
I gave you the basic logic. I am pretty sure you can figure out how to check if it is Zero.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Change in script

#6 Post by Squashman » 20 Aug 2012 06:43

mor.bas wrote:And also to check the input is a number and not string or something else

Anything else you want while you are asking. Maybe I can do other things for you as well. Nobody likes re-writing a script a half dozen times! :evil:

Post Reply