Menu question

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tebee
Posts: 13
Joined: 21 May 2011 08:41

Menu question

#1 Post by tebee » 25 May 2011 00:53

Probably already solved, how to set a default answer in menu? User should just hit enter to carry on (if he agree) or type what he wants, overriding the offered answer, and press enter.
Of course, no choice support...

Thanks

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Menu question

#2 Post by orange_batch » 25 May 2011 01:44

Edit: Read next post.
Last edited by orange_batch on 25 May 2011 07:36, edited 1 time in total.

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Menu question

#3 Post by dbenham » 25 May 2011 05:15

Actually there is a simpler solution - the value of choice remains unchanged if <Enter> is pressed without entering anything:

Code: Select all

set choice=banana
set /p "choice=Pick your fruit (default=%choice%): "
echo:Your choice is %choice%.


Dave Benham

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Menu question

#4 Post by orange_batch » 25 May 2011 07:36

...I knew that. :shock: I was drunk (really) lol. I use a choice function I wrote 8 months ago exclusively now, so it was in the back of my mind. 8)

Post Reply