Google Answers Logo
View Question
 
Q: Accepting user input in a DOS batch file ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Accepting user input in a DOS batch file
Category: Computers > Programming
Asked by: headless-ga
List Price: $25.00
Posted: 31 Oct 2002 22:03 PST
Expires: 30 Nov 2002 22:03 PST
Question ID: 95070
The subject sounds simple doesn't it?  We'll see....

My task is to take a collection of bios, firmware, and driver files,
compress them, wrap a license agreement around them and post them on
the web for download.  When the user runs the downloaded executable, I
present them with the option to make individual floppy disks from the
compressed file so they can pick and choose which files they want to
extract.  For example, they might just want to make a bios disk and
forget about the drivers.

Of course, there are some limitations:
1) I do not have a license to redistribute any DOS files, so I can't
bundle choice.com in the package.
2) The software I distribute is not public domain, so I can't
redistribute any files that are covered under the GNU license (which
eliminates Free DOS).
3) The user is expected to run the executable file on a windows-based
PC to make the floppy disks.
4) This has to be done without paying for any new software licenses,
can't violate copyright law, and I can't put my software into the
public domain as defined by the GNU license.
5) The user can't be expected to open and edit any of the batch files
themselves.

So far, I have all of this working with a series of batch files:
1.BAT creates the BIOS disk on drive A:
2.BAT creates the firmware disk on drive A:
etc

All the user has to do is type in the correct number and they get the
disk they want.  The problem is that some users don't have a floppy
drive designated as "A:".  They use external USB floppy drives that
can be any drive letter.  I
-could- create 100+ little batch files that cover every drive letter
from A to Z for every disk option, but the user menu would be too
large and confusing.

Given these limitations, how can I let the user designate the
appropriate drive letter for the floppy disk or somehow figure out
what drive letter is assigned to the floppy disk and then use that
drive letter to extract the files appropriately?
Answer  
Subject: Re: Accepting user input in a DOS batch file
Answered By: alexander-ga on 31 Oct 2002 22:20 PST
Rated:5 out of 5 stars
 
Easier than you think. Wherever the string "%1" appears in the batch
file, it will be replaced with the first parameter to the batch file.

So, say you had a batch file called "f.bat". You would tell the user
to type F and then the drive letter, so, for example:

F A:

In your batch file, you would do something like:

format %1

Then, when the batch file is run, it will execute the command "format
a:"

You can use the %1 in your batch file as many times as you want.

Same with %2, %3, etc.

Clarification of Answer by alexander-ga on 31 Oct 2002 22:24 PST
Not sure if you've thought of this, but it struck me a bit odd that
you're presenting a menu and then asking for input on the command
line. If you do something in your batch file like:

prompt Enter your selection:

It'll look a lot cleaner. When you're done,

prompt $p$g

puts back the standard prompt.

Clarification of Answer by alexander-ga on 31 Oct 2002 22:38 PST
Wow, apparently you can also do some crazy machinations to get some
degree of real input capability, though it might not work with current
Windows systems. (The CON file, which is the dependency, is present in
my Win98 install, but that's the most recent I have available right
now.)

http://www.pressroom.com/~tglbatch/input.htm

Request for Answer Clarification by headless-ga on 01 Nov 2002 14:35 PST
Alexander,

I'd read about the %1 string, but didn't make the connection that it
would apply here.  Excellent suggestion and easy money for you!  Also,
thanks for the tip on the prompt.  I didn't think of that either. 
You're right about how there's lots of crazy ways to accept user
input.  This page has lots more ways that involve scripting:
http://www.ericphelps.com/batch/userin/index.htm#qbasic

--H

Clarification of Answer by alexander-ga on 01 Nov 2002 19:23 PST
Glad I could be of help. :)
headless-ga rated this answer:5 out of 5 stars

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy