|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
你要的延时变量所达到的效果:
第二种方法:
@echo %dbg% off
setlocal enabledelayedexpansion
set b=0
for /l %%i in (0,1,4) do (
echo !b!
call set /a b+=1
)
输出如下:
C:\TEMP\k>b.bat
0
1
2
3
4
The effect of the delay variable you want:
The second method:
@echo %dbg% off
setlocal enabledelayedexpansion
set b=0
for /l %%i in (0,1,4) do (
echo !b!
call set /a b+=1
)
The output is as follows:
C:\TEMP\k>b.bat
0
1
2
3
4
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-7 03:36 |
|
|
onlykier
初级用户
 
积分 50
发帖 23
注册 2006-11-3
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
楼上的兄弟,你完全是在偷巧阿
这样,我要求
@echo %dbg% off
for /L %%i in (0,1,4) do (
echo %%i
)
echo %%i 中不能用%%i来显示,要用另外一个变量显示,该变量和%%i一点关系都不能有
Brother upstairs, you are completely taking a shortcut.
In this way, I require:
@echo %dbg% off
for /L %%i in (0,1,4) do (
echo %%i
)
echo %%i cannot be displayed using %%i. Another variable needs to be used for display, and there should be no relation at all between this variable and %%i
|
|
2006-11-7 03:44 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
onlykier兄,看了你8楼的代码例子,并运行了很多次并调试……
不过,你上面要处理的问题并没有跟上你的思路:)
你想了如何去解决一个问题,可是偏偏出现错误的地方几乎全都是因为一些基础的知识点所影响着:)
而onlykier兄的学习速度太快了,但最后还要回到那些基础的变量赋值、SET、延时变量、For的结构、特殊符号的运行和转义……
所以,建议onlykier把下面链接中所提到的知识点重新、从头到尾的一行一行代码全都键入一遍~:)
然后回过头来再看,相信onlykier兄会超越现在……
而这一切过程很可能仅仅几天甚至一、两天就够了,
可是这一两天的从头到尾做一遍这些知识点,相信onlykier永远都不再会问题了,
而是开始走入了知道如何处理一些不知道的问题并可以极快的找到办法:)
[简单索引]关于SET变量、延时变量、各种符号的用法……
http://www.cn-dos.net/forum/viewthread.php?tid=24549&fpage=1
Last edited by redtek on 2006-11-7 at 03:57 AM ]
Brother onlykier, I have read your code example on floor 8 and have run and debugged it many times...
However, the problem you were trying to address above didn't follow your line of thinking :)
You thought about how to solve a problem, but almost all the places where errors occurred were affected by some basic knowledge points :)
And Brother onlykier is learning very fast, but in the end, he still has to return to those basic variable assignments, SET, delay variables, For structures, operation and escape of special symbols...
So, it is suggested that onlykier retype all the knowledge points mentioned in the following link line by line from start to finish ~:)
Then come back and look again, I believe Brother onlykier will surpass the present...
And this whole process may only take a few days or even one or two days.
But doing this whole thing from start to finish in these one or two days, I believe onlykier will never have problems again,
but will start to enter the state of knowing how to handle some unknown problems and can find solutions very quickly :)
About SET variables, delay variables, usage of various symbols...
http://www.cn-dos.net/forum/viewthread.php?tid=24549&fpage=1
Last edited by redtek on 2006-11-7 at 03:57 AM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-7 03:47 |
|
|
onlykier
初级用户
 
积分 50
发帖 23
注册 2006-11-3
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
楼上的兄弟,你杀了我吧
我再来个例子
我只想显示第一行,下面的代码确都显示,why?
@echo off
dir d: /b>>d:\1.txt
set c=0
echo 1,%c%
for /f %%i in (d:\1.txt) do (
if %c% equ 0 (set c=1
echo 2,%c%
echo %%i)
)
Last edited by onlykier on 2006-11-6 at 03:12 PM ]
Brother upstairs, just kill me
I'll give another example
I just want to display the first line, but the following code displays all, why?
@echo off
dir d: /b>>d:\1.txt
set c=0
echo 1,%c%
for /f %%i in (d:\1.txt) do (
if %c% equ 0 (set c=1
echo 2,%c%
echo %%i)
)
Last edited by onlykier on 2006-11-6 at 03:12 PM ]
|
|
2006-11-7 04:02 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
楼上的兄弟,我不杀你,还是你让我自杀吧~:)
你的 for (你这里不加 /f 参数能读出文件内容来吗?) %%i in (d:\1.txt) do (
Brother upstairs, I won't kill you, or you let me commit suicide~:)
In your for %%i in (d:\1.txt) do (without adding the /f parameter here, can you read the file content?)
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-7 04:10 |
|
|
onlykier
初级用户
 
积分 50
发帖 23
注册 2006-11-3
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
我修改了,楼上的兄弟,你qq多少,我等答案等的的心痛啊
I have made modifications. Brother upstairs, what's your QQ number? I'm so anxious waiting for the answer.
|
|
2006-11-7 04:12 |
|
|
onlykier
初级用户
 
积分 50
发帖 23
注册 2006-11-3
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
set c=1
echo 2,%c%
为什么输出的 %c%还是0阿??
set c=1
echo 2,%c%
Why is the output %c% still 0?
|
|
2006-11-7 04:14 |
|
|
onlykier
初级用户
 
积分 50
发帖 23
注册 2006-11-3
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
论坛翻页,没看到redtek 的第二种方法 ^^!
set b=0
for /l %%i in (0,1,4) do (
echo !b!
call set /a b+=1
再请教下,这里问什么要有call呢?
Forum pagination, didn't see redtek's second method ^^!
set b=0
for /l %%i in (0,1,4) do (
echo !b!
call set /a b+=1
And then ask, why is there a call here?
|
|
2006-11-7 04:28 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
@echo %dbg% off
:: 延时变量
setlocal enabledelayedexpansion
dir d: /b>>d:\1.txt
set c=0
echo 1,%c%
:: /f 参数
:: "delims=" 可以读取含空格的字符串……
for /f "delims=" %%i in (d:\1.txt) do (
if !c! equ 0 (
set c=1
echo 2,!c!
echo %%i
)
)
建议这样按缩进书写代码:)
Last edited by redtek on 2006-11-7 at 04:36 AM ]
@echo %dbg% off
:: Delay variable
setlocal enabledelayedexpansion
dir d: /b>>d:\1.txt
set c=0
echo 1,%c%
:: /f parameter
:: "delims=" can read strings with spaces...
for /f "delims=" %%i in (d:\1.txt) do (
if !c! equ 0 (
set c=1
echo 2,!c!
echo %%i
)
)
It is suggested to write code with indentation like this:)
Last edited by redtek on 2006-11-7 at 04:36 AM ]
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-7 04:30 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
@echo off
dir c:\ /b>>c:\1.txt
set /p s=<c:\1.txt
echo %s%
pause
```
@echo off
dir c:\ /b>>c:\1.txt
set /p s=<c:\1.txt
echo %s%
pause
```
|
|
2006-11-7 04:30 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
Originally posted by onlykier at 2006-11-7 04:28:
论坛翻页,没看到redtek 的第二种方法 ^^!
set b=0
for /l %%i in (0,1,4) do (
echo !b!
call set /a b+=1
再请教下,这里问什么要有call呢?
那个 call 删了吧,那是做别的实验留下的COPY上来时忘了删了~:)
Originally posted by onlykier at 2006-11-7 04:28:
Forum page turning, didn't see redtek's second method ^^!
set b=0
for /l %%i in (0,1,4) do (
echo !b!
call set /a b+=1
Please ask again, why is there a call here?
That call should be deleted, that was left over from another experiment when copying and forgetting to delete it~ : )
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-7 04:31 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
lxmxn兄代码非常简捷,欣赏~:)
Brother lxmxn's code is very concise, appreciate it~:)
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-11-7 04:32 |
|
|
onlykier
初级用户
 
积分 50
发帖 23
注册 2006-11-3
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
@echo off
dir c:\ /b>>c:\1.txt
set /p s=<c:\1.txt
echo %s%
pause
这段代码为什么只显示第一行?
我觉的应该显示好多阿,因为c:\1.txt内容给了s了阿
@echo off
dir c:\ /b>>c:\1.txt
set /p s=<c:\1.txt
echo %s%
pause
Why does this code only display the first line? I thought it should display many lines because the content of c:\1.txt is assigned to s.
|
|
2006-11-7 04:48 |
|
|