Notices
Non Scooby Related Anything Non-Scooby related

DOS command line question..

Thread Tools
 
Search this Thread
 
Old Oct 2, 2001 | 01:19 PM
  #1  
SD's Avatar
SD
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 678
Likes: 0
Question

All to be run in Windows NT:

C'mon then you IT guys. My DOS days are long behind me now, but how do I do this?

In a batch file I want to prompt for an input and then pass that input to a variable. For example

"What is your name?"

You would input your name and that would be passed to a variable user_name

Any thoughts?

And I don't want to use Kix to achieve this!

Cheers,

Simon
Reply
Old Oct 2, 2001 | 02:29 PM
  #2  
simon_prickett's Avatar
simon_prickett
Scooby Regular
 
Joined: Oct 2000
Posts: 1,013
Likes: 0
Exclamation

Have done this before with a noddy C program that asks the user the question, which it pulls from a text file, then sets the env variable on exit.

Not sure how to do it just in NT commands - think I got bored of trying and just did it in C.

Simon.
Reply
Old Oct 2, 2001 | 03:39 PM
  #3  
fast bloke's Avatar
fast bloke
Scooby Regular
 
Joined: Nov 2000
Posts: 26,619
Likes: 0
Post

you can do it, but it won't be pretty. You need to ask the question then add each character to a string (which you set to be blank at the start) after checking that it is not return.
You can use a nested If then append statement to do this. Not sure of the syntax but I'm sure someone will have it in seconds
Reply
Old Oct 2, 2001 | 04:21 PM
  #4  
SD's Avatar
SD
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 678
Likes: 0
Lightbulb

Cheers guys. The simplest things once again made impossible by the man with the bowl haircut.
Reply
Old Oct 2, 2001 | 04:35 PM
  #5  
Crispin's Avatar
Crispin
Scooby Regular
 
Joined: Jan 2001
Posts: 534
Likes: 0
Post

Reply
Old Oct 2, 2001 | 04:48 PM
  #6  
Scumbag's Avatar
Scumbag
Scooby Regular
 
Joined: Aug 2001
Posts: 429
Likes: 0
Thumbs up

Dont know if I'm missing some of your requirements, but try this:

Create a file (Scumbag.bat) in notepad (make sure it as saved under all files not text, otherwise you'll get that sodding .txt extension)

Make a single line entry of :
echo %1 %2

Now invoke the file from DOS as:
Scumbag X Y

This should now take the two values X and Y and feed them into the %1 and %2 variables, and you'll get the echo you require.

You can do this for as many variables as you want, and obviously you'll be wanting to do something more interesting than printing them back to the screen

[and before you ask, God knows where I dragged that from]
Hope this helps

SB
Reply
Old Oct 2, 2001 | 04:50 PM
  #7  
Scumbag's Avatar
Scumbag
Scooby Regular
 
Joined: Aug 2001
Posts: 429
Likes: 0
Post

oops,

just re-read + realised that the above is completely useless if you have already invoked the file

....I'll get me coat
Reply
Old Oct 2, 2001 | 05:43 PM
  #8  
carl's Avatar
carl
Scooby Regular
 
Joined: May 1999
Posts: 7,901
Likes: 0
Post

Scumbag -- if you already have a file that you'd like to append to you can do something like:

echo %1>temp.txt
copy already_invoked_file.txt+temp.txt already_invoked_file.txt

but I think this is diverging from the requirement.

I was going to suggest use of the scankey command, which returns the ASCII value of the entered character into the %errorlevel% variable, but I found this webpage:
Reply
Old Oct 2, 2001 | 06:46 PM
  #9  
SD's Avatar
SD
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 678
Likes: 0
Thumbs up

Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Pro-Line Motorsport
Car Parts For Sale
48
Jul 21, 2017 09:50 PM
Ganz1983
Subaru
5
Oct 2, 2015 09:22 AM
Pro-Line Motorsport
Car Parts For Sale
2
Sep 29, 2015 07:36 PM
Pro-Line Motorsport
ScoobyNet General
9
Sep 28, 2015 09:48 PM
Pro-Line Motorsport
Car Parts For Sale
0
Sep 27, 2015 11:23 AM




All times are GMT +1. The time now is 04:10 PM.