"CHOICE" command absent

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15600
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

"CHOICE" command absent

Post by ChrisGreaves »

I am busy making my automated DOS scripts run and for Win7 switched to the CHOICE command (the dear old Wait.COM 16-bit utility won't run under Win7/64 bit).
This morning to the IBM/WinXPSP3 machine ... only to find that CHOICE is unavailable in WinXP.
It is available in predecessors and successors, but not in Win XP.

How do they know what I want?
http://www.computerhope.com/choicehl.htm :-
Availability
The choice command is an external command and is available in
MS-DOS 6.0+
Windows 95
Windows 98
Windows Vista
Windows 7

(The chosen colour is as close as I could get to funereal purple)
There's nothing heavier than an empty water bottle

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: "CHOICE" command absent

Post by John Gray »

Code: Select all

@echo off
setlocal
:loop
set /p answer="Does this do a similar thing to that which CHOICE used to do?  "
if "%answer%"=="" echo Answer  y  or  n  please! & goto loop
if /i "%answer%"=="y" echo Yes, much the same & endlocal & goto :eof
if /i "%answer%"=="n" echo I'll bet you're Chris Greaves!! & endlocal & goto :eof
echo Answer  y  or  n  please! & goto loop
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
Argus
GoldLounger
Posts: 3081
Joined: 24 Jan 2010, 19:07

Re: "CHOICE" command absent

Post by Argus »

Since Windows 2000, same in XP, the SET command has some new switches; in this case /P (prompts for user input; sets the value of the variable to a line of input entered by the user) can be of some interest. As mentioned in the pages you linked to, and as shown in a very, ehm, straightforward way by John. :grin:

Another example: DOS Choice command replacement (from a random site; also shows the IF /I switch, used by John).

I think they removed CHOICE and put it in a resource kit, then included it (a different version) again.
Byelingual    When you speak two languages but start losing vocabulary in both of them.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15600
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: "CHOICE" command absent

Post by ChrisGreaves »

John Gray wrote:Does this do a similar thing to that which CHOICE used to do?
John, thanks for this. I'll take a look at it. (I'm sure you've tested it, though!).
My use of CHOICE was spurred by a web page that made use of CHOICE to implement a WAIT command.
In the meantime I test for the operating system version and use either the 16-bit Wait.COM or the Choice command, depending on.

:ranton: I know I complain, but I struggle to comprehend why, with a GB Operating System, MSoft drops items that are of use. I shudder to think of the man-hours burned up building workarounds in each new version of anything. :rantoff:
There's nothing heavier than an empty water bottle

User avatar
Argus
GoldLounger
Posts: 3081
Joined: 24 Jan 2010, 19:07

Re: "CHOICE" command absent

Post by Argus »

ChrisGreaves wrote:[...]I struggle to comprehend why, with a GB Operating System, MSoft drops items that are of use. I shudder to think of the man-hours burned up building workarounds in each new version of anything.
I don't know, I haven't looked closer at this, but see this for example. Items may be of use, but not work optimally, and if the environment (OS) changes ...
Availability
Choice.com was originally supplied on the Windows 95 install CD, however there are some issues with this version under NT - multiple concurrent invocations of CHOICE will clobber each other. CHOICE.com will also burn a lot of CPU's when in a wait state.
The NT and 2000 Resource Kits contain CHOICE.EXE which behaves a lot better.
In Windows 2003 CHOICE became a built-in command so it is no longer in the resource kit.
Byelingual    When you speak two languages but start losing vocabulary in both of them.

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: "CHOICE" command absent

Post by John Gray »

Chris

The standard WAIT command is PING -n 6 127.0.0.1 > nul where the value 6 is one more than the number of seconds to be waited, viz. 5.
Put 13 for a wait of 12 seconds, and so on. (Think of the PING number as the number of fence posts, thus giving n-1 fence panels = seconds in-between.)
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...