无忧启动论坛

标题: Set Choice=%Choice:~0,1%是什么意思 [打印本页]

作者: freesoft00    时间: 2009-8-30 08:04
标题: Set Choice=%Choice:~0,1%是什么意思
::Set Choice=
Set /P Choice=   请选择要进行的操作 (1/2/Q) ,然后按回车:
If "%Choice%"=="" Goto Start
If Not "%Choice%"=="" Set Choice=%Choice:~0,1%
If /I "%Choice%"=="1" Goto INSTALL
If /I "%Choice%"=="2" Goto UNINSTALL
If /I "%Choice%"=="Q" Exit
Goto Start


红色的一行是什么意思,不懂
作者: dos时代菜鸟    时间: 2009-8-30 09:06
设置  choice 为 原choice变量的第一个字符。
作者: freesoft00    时间: 2009-8-30 11:42
谢谢,可是我还是不是太懂,能不能具体点,举个例子也可以。
作者: namejm    时间: 2009-8-30 13:50
  当你输入一串字符的时候,只取第一个字符作为最终输入。

  set str=%str:~x,y%,表示从第x+1位起,截取%str%值的y个字符,赋予变量str。
作者: wowfans    时间: 2009-8-30 14:18
楼主在命令行打一下SET /?
什么都有了


The /P switch allows you to set the value of a variable to a line of input
entered by the user.  Displays the specified promptString before reading
the line of input.  The promptString can be empty.

Environment variable substitution has been enhanced as follows:

    %PATH:str1=str2%

would expand the PATH environment variable, substituting each occurrence
of "str1" in the expanded result with "str2".  "str2" can be the empty
string to effectively delete all occurrences of "str1" from the expanded
output.  "str1" can begin with an asterisk, in which case it will match
everything from the beginning of the expanded output to the first
occurrence of the remaining portion of str1.

May also specify substrings for an expansion.

    %PATH:~10,5%

would expand the PATH environment variable, and then use only the 5
characters that begin at the 11th (offset 10) character of the expanded
result.  If the length is not specified, then it defaults to the
remainder of the variable value.  If either number (offset or length) is
negative, then the number used is the length of the environment variable
value added to the offset or length specified.

    %PATH:~-10%

would extract the last 10 characters of the PATH variable.

    %PATH:~0,-2%


本人系统是英文的,你找个中文的系统帮助下就是中文说明了
作者: freesoft00    时间: 2009-8-30 15:49
好谢谢上面的各位,我在电脑上试试,看看set /? 如何
作者: yjd    时间: 2009-8-31 09:49
还是高手的解释比较直观,set /?看有时候糊涂^_^
作者: freesoft00    时间: 2009-8-31 18:12
set /? 看了,确实很晦涩。
作者: x9tian    时间: 2009-8-31 19:36
微软的帮助, 是帮助鬼的,   看着莫名其秒
作者: opq    时间: 2011-4-13 21:52
标题: 是正解!
  当你输入一串字符的时候,只取第一个字符作为最终输入。

  set str=%str:~x,y%,表示从第x+1位起,截取%str%值的y个字符,赋予变量str。




欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/) Powered by Discuz! X3.3