如何使用户的输入,然后一个变量? [英] How to make user's input then a variable?
问题描述
我如何让用户的输入变量? (我不知道问这个,因为我工作的一个安装...)
How I make the user's input a variable? (I have no idea asking this because I'm working on a setup...)
例如,如果用户的输入将是输入可能使一个变量,它是用户的输入?如果用户的输入为3的变量将是3,如果用户的输入(或应答)将是4,则变量将是4
For example, if the user's input would be "input" could I make a variable that is the user's input? If the user's input is "3" the variable would be 3. If the input of the user (or answer) would be 4 then the variable would be 4.
code:
:loop
set /p input=input something here:
if %input%==. goto loop
if not %input%==. goto store_userinput_as_variable
:store_userinput_as_variable
cls
echo Your input has been stored in a variable.
但我怎么做一个变量,它是用户inputed什么?请帮助!
But how i make a variable that is what the user inputed? Please help!
推荐答案
我不完全相信你想什么来完成,但也许这会有所帮助。
I'm not exactly sure what you are trying to accomplish, but maybe this will help.
@ECHO OFF
:loop
set /p input=input something here:
if %input%==. goto loop
if not %input%==. goto store_userinput_as_variable
:store_userinput_as_variable
cls
ECHO You entered: %input%
REM Create a variable with the same name as the value they entered.
CALL SET %input%=New Variable
CALL ECHO The variable "%input%" has a value of "%%%input%%%"
所以,如果你输入你好时,输出将是:
So if you enter "Hello", the output would be:
You entered: Hello
The variable "Hello" has a value of "New Variable"
这篇关于如何使用户的输入,然后一个变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!