Variable Question
Posted: 24 May 2011 15:18
Okay. So I know how to use the set /p command on a basic level of options.
For example,
===================================
echo 1
echo 2
echo 3
set /p choice=(Pick a number!)
if not '%choice%'==set choice=%choice=~0,1%
if '%choice%'=='1' goto 1
if '%choice%'=='2' goto 2
if '%choice%'=='3' goto 3
echo '%choice%' is not a valid number!
:1
echo Hello!
pause>nul
:2
echo Hello!
pause>nul
:3
echo Hello!
pause>nul
===========================================
Now the question is, how long is this variable saved for? This script I originally copied from somewhere but have become somewhat familiar with it. (I'm talking about the set /p choice thing. Not the thing above.) How do I have the user define other variables and then I can run them later.
Question #2
===============
Next question. How do I get a batch file to create, edit, and be able to read the text document?
Thanks Guys!
For example,
===================================
echo 1
echo 2
echo 3
set /p choice=(Pick a number!)
if not '%choice%'==set choice=%choice=~0,1%
if '%choice%'=='1' goto 1
if '%choice%'=='2' goto 2
if '%choice%'=='3' goto 3
echo '%choice%' is not a valid number!
:1
echo Hello!
pause>nul
:2
echo Hello!
pause>nul
:3
echo Hello!
pause>nul
===========================================
Now the question is, how long is this variable saved for? This script I originally copied from somewhere but have become somewhat familiar with it. (I'm talking about the set /p choice thing. Not the thing above.) How do I have the user define other variables and then I can run them later.
Question #2
===============
Next question. How do I get a batch file to create, edit, and be able to read the text document?
Thanks Guys!