Computing.Net > Forums > Disk Operating System > Input question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Input question

Reply to Message Icon

Name: noob1
Date: April 16, 2003 at 08:54:31 Pacific
OS: Dos
CPU/Ram: 3.06 mhz/512
Comment:

What is the command to allow a user to input a filename then when they press enter it takes them to the right commandline. I dont want the one where you enter a variable and it has a choice and errorlevel to goto the commandline.

Thanks for any assistance you can give me.



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: April 16, 2003 at 11:17:07 Pacific
Reply:

By "the one where you enter a variable and it has a choice and errorlevel to goto the commandline" you're probably refering to the CHOICE cmd, right?

If you're on DOS (really DOS, not just command prompt for NT) or Win9x, my FAQ will help:

FAQ #06 - Get user input

If you're on Windows 2000 or XP, use this command:

set /P FILENAME=Type filename:

That will display the message "Type filename:" and will wait for input. After user hits enter, the data goes to the variable specified on the left of the equals sign (in this case the variable %FILENAME%) and that's it (no loop back, it's already ended).

And finally, for Win NT 4-, use this:

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=> %temp%.\input.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>> %temp%.\input.com
echo @]yI?@xAp~sA`LZNt@x[}?MGI@]A?nsl@]}G@tLC?sBZ`LBL`_jN0xxxxx>> %temp%.\input.com
for /F "tokens=*" %%I in ('%temp%.\input.com') do set INPUT=%%I
del %temp%.\input.com

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br

___________________________________________________________________________________


0

Response Number 2
Name: noob1
Date: April 17, 2003 at 08:59:27 Pacific
Reply:

Heres one that i want for multiple uses:

maketrn multst07.trn /p="BANE.ini"

How do i write it if i want where "bane.ini" is to ask the user to input a "?.ini" then the line will execute?



0

Response Number 3
Name: noob1
Date: April 17, 2003 at 09:20:17 Pacific
Reply:

o and it needs to search for the existing .ini in this path. C:/Program Files/Activision/Battlezone


Thank you for your help I really appreciate it.



0

Response Number 4
Name: noob1
Date: April 17, 2003 at 09:22:18 Pacific
Reply:

oops wrong slash should be

C:\Program Files\Activision\Battlezone


0

Response Number 5
Name: Secret_Doom
Date: April 17, 2003 at 13:17:42 Pacific
Reply:

What? I can't understand what you mean...

You wrote:
> How do i write it if i want where "bane.ini"
> is to ask the user to input a "?.ini" then the
> line will execute?

What do you mean by that?

What I did describe is how to get user's input and save on an environment variable. I thought that was what you wanted. If it's not, please explain better and clearer.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Related Posts

See More



Response Number 6
Name: noob1
Date: April 18, 2003 at 09:02:28 Pacific
Reply:

What I am doing is making a program that does many things. It auto creates a map for a game through a dos map editor. Instead of manually typing all of the dos commands I am making this series of batches to add to an installer. Each batch will do different things. The one in particular I am stuck on right now is I need to create a user input line where the user inputs a .ini filename and it adds the filename of that .ini, "Bane.ini" for example, into the Dos command line and executes it. This is the command line.

maketrn multst07.trn /p="BANE.ini"

the "BANE.ini" is the area where I need the inputed filename to be inserted.

Like say I wanted to use the "Mars.ini" Then I would enter "Mars" and it would create the Command line like this.

maketrn multst07.trn /p="Mars.ini"

and then Execute it.

Sorry I hope that helps.


0

Response Number 7
Name: Secret_Doom
Date: April 18, 2003 at 09:54:05 Pacific
Reply:

Oh, it's much clearer now.

You can get user input with one of the scripts I posted above, according to the OS it's supposed to run. After getting the input saved on the variable %INPUT%, use it on the line:

maketrn multst07.trn /p="%input%.ini"

For instance, if the OS intended is WinXP, the 'global process' would be:

echo Type filename (without .ini extention)
set input=
:input
set /P input=
if "%input%"=="" goto input
maketrn multst07.trn /p="%input%.ini"

In that sample, I've also included an error check for blank inputs - if user enters nothing, the scritp will loop back to the input getting.

You could also make something simpler: accept the filename as a variable of the batch script. User would invoke the script as this:

bscript.bat mars

And then, %1 would represent the first parameter "mars". The line for the map editor would become:

maketrn multst07.trn /p="%1.ini"

In that case, the filename would better not contain spaces, because a space would break it in two parameters (%1 and %2). That's not a problem with the other input methods (those that send input to variable). Oh, it's good to include some help information so user knows how to pass the parameter, and also some error checks.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br

_________________________________________________________


0

Response Number 8
Name: Secret_Doom
Date: April 18, 2003 at 11:16:24 Pacific
Reply:

By the way, on my example:

bscript.bat mars

The "bscript.bat" is simply the batch script name, just an example.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br



0

Response Number 9
Name: noob1
Date: April 18, 2003 at 22:45:23 Pacific
Reply:

yes that is exactly what I needed :) Thanks alot I really appreciate it.



0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Input question

batch file question www.computing.net/answers/dos/batch-file-question/3271.html

user input unsolved www.computing.net/answers/dos/user-input-unsolved/3992.html

Reading input from a batch file www.computing.net/answers/dos/reading-input-from-a-batch-file/13892.html