China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 17:04
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » It can also be calculated without using variable delay [setlocal enableDelayedExpansion] View 4,766 Replies 49
Floor 46 Posted 2008-06-26 19:18 ·  中国 北京 联通
银牌会员
★★★
Credits 1,287
Posts 634
Joined 2007-05-02 15:06
19-year member
UID 87277
Gender Male
From cmd.exe
Status Offline
call echo %var% ?
I feel like if
call echo %%var%%
Call once adds a pair of %
It seems..
Floor 47 Posted 2008-06-26 19:43 ·  中国 江苏 苏州 常熟市 电信
高级用户
★★
五星老土
Credits 558
Posts 172
Joined 2003-02-09 00:00
23-year member
UID 881
Gender Male
From 江苏
Status Offline
The code on floor 45 is really concise and clear.
我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已.
Floor 48 Posted 2008-06-27 02:16 ·  法国
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
But I still declare
This kind of abbreviation is really uninteresting
First execute for and then execute echo %n%
It is simple and clear
And it won't have the above-mentioned problems I mentioned


One-line code and multi-line code each have their own advantages and disadvantages

It is improper to erase the role of either party

The reason for writing it in one line is nothing but wanting to make use of call

Thus illustrating that call replaces the role of setlocal enabledelayedexpansion to a certain extent

Can it replace 100%? It's undecided!
菩提本无树,明镜亦非台,本来无一物,何处惹尘埃.
Floor 49 Posted 2008-06-27 13:05 ·  中国 福建 三明 电信
中级用户
★★
Credits 458
Posts 211
Joined 2006-07-26 19:42
20-year member
UID 59307
Status Offline
Originally posted by plp626 at 2008-6-26 18:53:
There was such a heated discussion just about variable delay. I feel that the code of the thread starter is nothing new, which I often use when writing "subroutines".

But let me say something off-topic, the example the thread starter gave is not...


Actually, it's because I thought of what you said about "subroutines" that I posted this. In addition to this place, it can also be used in other places that need to be incremented.

Also, I still don't know many commands, like find, findstr, etc. So some codes that could have been simple are also written complicated.
┌───────┐
├→学习→实践→┤
└───────┘
Floor 50 Posted 2009-08-07 04:15 ·  中国 广西 南宁 西乡塘区 电信
初级用户
★★
Credits 99
Posts 53
Joined 2006-08-18 18:44
19-year member
UID 60809
Status Offline
Originally posted by PPdos at 2008-6-25 19:51:
It is also possible to use the intermediate result

(for /f "tokens=*" %i in ('dir /b') do set /a n+=1 >nul&call set _%n%=%i >nul)&call echo There are %n% files(folders) in the directory

Paste the code into the command prompt and run it multiple times, and you will see that the number keeps increasing, which does not match the actual number of files(folders).

[ Last edited by asnahu on 2009-8-7 at 04:20 ]
Forum Jump: