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-06-24 06:50
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Wonderful] [Statistics of the Number of Occurrences of Batch Processing Characters] DigestI View 23,263 Replies 41
Floor 31 Posted 2006-11-30 06:14 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Can Brother youxi01 talk about the simple implementation principles and ideas? This is convenient for learning and can better understand and read the code~:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 32 Posted 2006-11-30 07:03 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Brother redtek, when I run the code on the 15th floor you posted, it always flashes by in an instant. I don't know why. So depressed...
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 33 Posted 2006-11-30 07:32 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Didn't add Pause, haha...
I operated on the command line :)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 34 Posted 2006-11-30 07:38 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
What command line is so powerful?
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 35 Posted 2006-11-30 07:48 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Hehe……
It always flashes by because you saved it with Notepad (probably to the desktop).
There is no "pause" in the batch code to wait for you to press any key before exiting, so when you double-click the batch file with the mouse, it runs and exits automatically, closing the CMD Shell window: )
First enter the CMD Shell command window, then type...BAt in it and run: )
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 36 Posted 2006-11-30 08:18 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Re lxmxn 『Post 23』:

  Brother NaiWaiHe's code in 7F also has similar issues. The problem lies in the two lines "if %%j GTR !l! set l=%%j & set m=%%i" and "if !.%1! GTR !maxN! set maxN=!.%1! && set max=.%1". The same problem occurs: there is an extra space before & and &&. Removing this space will fix it.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
tao0610 +2 2006-11-30 08:29
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 37 Posted 2006-11-30 08:23 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Changing the line "set . & goto :eof" on floor 15 to "set . &pause& goto :eof" will do it.

The simplest one ^_^
@echo off
setlocal EnableDelayedExpansion
set str=adadfdfseffserfefsefseetsdgadadfdfseffserfefsefseetsdga

:loop
set str$=%str$% %str:~0,1%&set str=%str:~1%
if not "%str%" == "" goto loop

for %%n in (%str$%) do (
set /a .%%n+=1
if !.%%n! GTR !maxN! set maxN=!.%%n!&&set max=%%n)
set .
echo The most frequent occurrence: %max%=%maxN%
pause
exit
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
namejm +2 2006-11-30 08:31
Floor 38 Posted 2006-11-30 08:26 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by namejm at 2006-11-29 20:18:
Re lxmxn 『第 23 楼』:

  Naihe brother's code in 7F also has similar problems. The cause is in if %%j GTR !l! set l=%%j & set m=%%i and if !.%1! GTR !maxN! set maxN=!.%1! && set max=...

It's indeed the case. What I modified in 18th floor is also like this. Generally, it is suggested that there should be no spaces in the best way of connecting with &, &&
Floor 39 Posted 2006-11-30 08:27 ·  中国 北京 朝阳区 联通
高级用户
★★
朦胧的世界
Credits 579
Posts 218
Joined 2006-10-24 04:29
19-year member
UID 67972
Status Offline
It seems that format specification is very important.

认识自己,降伏自己,改变自己
,才能改变别人!
Floor 40 Posted 2007-01-08 22:11 ·  中国 广西 梧州 电信
新手上路
Credits 5
Posts 3
Joined 2006-11-21 04:48
19-year member
UID 71207
Gender Male
Status Offline
Originally posted by tao0610 at 2006-11-29 04:29 PM:
I'll also post one using for /l!
@echo off&setlocal enabledelayedexpansion
set str=adadfdfseffserfefsefseetsdgdsfjkljdsklfjdsfdsgdsafdsaf

for /l %%i in (0,1,100) do (
if "!str:~% ...


After reading for so long... This friend's writing is still relatively good!
Floor 41 Posted 2007-04-22 05:04 ·  中国 江苏 无锡 电信
初级用户
Credits 80
Posts 43
Joined 2007-04-21 23:44
19-year member
UID 86017
Gender Male
Status Offline
If the value of %1 is greater than the value of maxN, then set maxN to the value of %1 and set max to %1.
Floor 42 Posted 2008-01-08 02:02 ·  中国 四川 自贡 大安区 电信
初级用户
Credits 30
Posts 10
Joined 2007-11-19 23:42
18-year member
UID 103177
Gender Male
Status Offline
Thank you everyone,

As a new user, I really want to see such good code. It's enough for me to study.

It's really helpful...

I just want to ask the moderator if there can be more such activities in the future, so as to give us new users a good opportunity to study?

On behalf of new users, I say thank you to everyone
Forum Jump: