Computing.Net > Forums > Disk Operating System > batch vars

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

batch vars

Reply to Message Icon

Name: simon
Date: April 24, 2003 at 02:33:04 Pacific
OS: XP
CPU/Ram: 256
Comment:

Hi there,

I'm currently running XP. How would it be possible to use a user_input system to do the following for example:

The user enters their name at a prompt, then their height at a seperate request.

The file then outputs "Hi %, your age is %!"

Any help appreciated,

Thanks.




Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: April 24, 2003 at 13:50:13 Pacific
Reply:

Is it height or age you want to ask on the second input? I'll assume it's age, doesn't make much difference. This will do:

@echo off
set name=
:input_name
set /P name=What's your name? %=%
if "%name%"=="" goto input_name
set age=
:input_age
set /P age=How old are you? %=%
if "%age%"=="" goto input_age
echo Hi %name%, your age is %age%!

-- Leonardo Pignataro - Secret_Doom --

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


0

Response Number 2
Name: nonconformist
Date: April 24, 2003 at 17:54:39 Pacific
Reply:

Okay... that doesn't seem to work, when I execute the file, nothing echos at all.

Is it for Windows 98?


0

Response Number 3
Name: Secret_Doom
Date: April 26, 2003 at 11:56:16 Pacific
Reply:

That script works just fine on Windows 2000 and XP environments. It will not run on Windows 98, nor on NT4. I've shown such method because you stated you were under XP.

In case you're under an OS other than Windows 2000 and XP, another method must be used. Which is the intended OS?

If you're on XP, I see absolutely no reason why it shouldn't work. Did any error messages come up? Are the prompts made, or the script simply ends instantly?

You gotta cut-paste that code I posted into a text file and save it with a .BAT extention, no other extention will work, you know that, don't you?

-- Leonardo Pignataro - Secret_Doom --

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


DOS Commands Msdos boot partition?



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: batch vars

batch - var/loop help www.computing.net/answers/dos/batch-varloop-help/13849.html

prompting user for var's in batch pgm www.computing.net/answers/dos/prompting-user-for-vars-in-batch-pgm/7967.html

how can i get var. in dos batch www.computing.net/answers/dos/how-can-i-get-var-in-dos-batch/12787.html