Board logo

标题: set b=%%a:~%1%,%2%% 这样写不知道对不对 [打印本页]

作者: huzixuan     时间: 2007-1-10 01:56    标题: set b=%%a:~%1%,%2%% 这样写不知道对不对

-------------如下-----------------------------------------
@echo off
set a=a b c d e f g
set 1=0
set 2=1

set b=%%a:~%1%,%2%%
echo %b%>ttttttttt.txt
----如上------------------------------------



我不知道怎么表达我的意思,总之我认为 这段代码
set b=%%a:~%1%,%2%%
echo %b%>ttttttttt.txt
运行结果应该等同于
set b=%a:~0,1%
echo %b%>ttttttttt.txt

ttttttttt.txt显示的应该是 a
可却不是这样 不知道是怎么回事?
作者: 9527     时间: 2007-1-10 02:08
这样试试
call set b=%%a:~%1%,%2%%

作者: huzixuan     时间: 2007-1-10 02:16
不知道嘛,是这样???
@echo off
set a=a b c d e f g
set 1=0
set 2=1

call set b=%a:~%1%,%2%%
echo %b%>ttttttttt.txt


还是不行
作者: 9527     时间: 2007-1-10 02:21

call set b=%a:~%1%,%2%%
echo %b%>ttttttttt.txt
这里错了,跟我的一样吗?
作者: tghksj     时间: 2007-1-10 03:17

@ECHO %dbg% OFF
setlocal ENABLEDELAYEDEXPANSION

set a=a b c d e f g
set 1=0
set 2=1

call set b=%%a:~!1!,!2!%%
echo %b%>ttttttttt.txt

作者: huzixuan     时间: 2007-1-10 04:49
谢楼上了
作者: 429499381     时间: 2007-1-11 14:10


  Quote:
Originally posted by tghksj at 2007-1-9 02:17 PM:
@ECHO %dbg% OFF
setlocal ENABLEDELAYEDEXPANSION

set a=a b c d e f g
set 1=0
set 2=1

call set b=%%a:~!1!,!2!%%
echo %b%>ttttttttt.txt

C:\>set b
b=%a:~!1!,!2!%
为什么我在CMD中使用就会是这个结果!!:(