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-20 01:37
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Share] The Oddities in Batch Programming DigestI View 30,934 Replies 50
Floor 16 Posted 2004-02-06 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Below is a program for converting strings in table order. The original text comes from the development room of this site:
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=6&ID=9250

This program is written for the sequential conversion of string values in batch processing. It is generally called as a subroutine by other programs. It can also be slightly modified and added as a sub-module call in a specific batch processing program.


@echo off
if == goto %2
if == goto nullargu

:main Main module: The parameter lists of count and match can be reset and increased or decreased as needed
set factor=%1
call %0 $ count 1 2 3 4 5 7 8 9
call %0 $ match c d e f g h i j
goto display

:count Counting module: Set variable values #a1, #a2 according to the specified parameter factor
if == goto overflow
set #a1=%#a1%-
if not == goto count_2
set #a1=
set #a2=%#a2%+
if == goto overflow
:count_2
if == goto end
shift
goto count

:match Matching module: Loop to increment variables #b1, #b2. If they are equal to #a1, #a2 respectively, then specify the result value as the current loop parameter 3.
if == goto overflow
set #b1=%#b1%-
if not == goto match_2
set #b1=
set #b2=%#b2%+
if == goto overflow
:match_2
if == if == set result=%3
if not == goto end
shift
goto match

:display Display module: Display the assignment result
if == echo %factor% convert %result%
set result=
set factor=
set error=
set #a1=
set #a2=
set #b1=
set #b2=
goto end

:nullargu
echo.
echo Error: argument 1 not specified.
echo.
goto end

verflow
echo.
echo Error: number is overflow.
set error=overflow
echo.
goto end

:end
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 17 Posted 2004-02-06 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Here is the translation:

The following is a program to get the errorlevel value into an environment variable. The original text comes from the development room of this site:
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=6&ID=9358

@echo off
set el=0
if errorlevel 1 set el=1
if not errorlevel 2 goto end

:partbydec
for %%h in (1 2) do if errorlevel %%h00 set elh=%%h
if == for %%t in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %elh%%%t0 set elt=%elh%%%t
if == for %%t in (0 1 2 3 4 5) do if errorlevel %elh%%%t0 set elt=%elh%%%t
if not == for %%o in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %elt%%%o set el=%elt%%%o
if == for %%o in (0 1 2 3 4 5) do if errorlevel %elt%%%o set el=%elt%%%o
set elh=
set elt=

:end
if not == echo current errolevel is %el%






※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 18 Posted 2004-05-13 00:00 ·  中国 云南 昭通 中移铁通
初级用户
Credits 119
Posts 7
Joined 2004-05-11 00:00
22-year member
UID 24052
Gender Male
Status Offline
Good
A very classic batch script
Floor 19 Posted 2004-06-22 00:00 ·  中国 重庆 渝中区 电信
银牌会员
★★★
Credits 2,165
Posts 730
Joined 2004-04-21 00:00
22-year member
UID 22966
Gender Male
Status Offline
The LZ really has a special liking for batch processing. I'll take it first and read it slowly. (Can't help but reply first, and strive to gain something in a few days)

Originally I once planned to make a batch processing that traverses directories, but didn't write it out. Later I used C to write, but the result is also very clumsy - some directories will crash. It's best to complete this kind of thing with DOS itself.
Floor 20 Posted 2004-06-23 00:00 ·  中国 重庆 渝中区 电信
银牌会员
★★★
Credits 2,165
Posts 730
Joined 2004-04-21 00:00
22-year member
UID 22966
Gender Male
Status Offline
I still don't know how to use












Floor 21 Posted 2004-10-14 00:00 ·  中国 河南 安阳 联通
银牌会员
★★★
Credits 1,186
Posts 334
Joined 2003-05-30 00:00
23-year member
UID 2626
Gender Male
Status Offline
The following is the statement from zww3008 on 2004-1-14 15:42:25:
These are all very classic batch processing programs, which are very worthy for beginners to learn, refer to and experience. If you don't want the post to be watered down, then please ask the moderator to pin it! Don't let the post sink.

Finally found it again
I'm really lucky~~
For everyone
I'll give it a top
Floor 22 Posted 2005-02-24 00:00 ·  中国 山东 济宁 电信
中级用户
★★★
痴迷DOS者
Credits 456
Posts 570
Joined 2004-10-09 00:00
21-year member
UID 32281
Gender Male
Status Offline
DOS不是万能的,没有DOS是万万不能的
自古系统谁无死?留取胆清照汗青!uploadImages/20035317345478982.png
Floor 23 Posted 2005-02-25 00:00 ·  中国 山西 太原 中移铁通
初级用户
Credits 106
Posts 3
Joined 2005-02-25 00:00
21-year member
UID 36475
Gender Male
Status Offline
Depressed, why do I feel that the more I learn, the more things I don't understand? I just wanted to play for a few more days at the beginning of school. I'll go to the library tomorrow.
Floor 24 Posted 2005-11-20 14:28 ·  中国 辽宁 葫芦岛 中移铁通
新手上路
Credits 10
Posts 3
Joined 2005-11-19 21:20
20-year member
UID 45570
Gender Male
Status Offline
It is indeed a rare and good teaching material, and I'll bring it back to the top again!
Floor 25 Posted 2006-03-30 13:08 ·  中国 广东 广州 中移铁通
中级用户
★★
Credits 256
Posts 93
Joined 2006-03-26 22:12
20-year member
UID 52853
Gender Male
From 广东
Status Offline
```
Top top top
```
Floor 26 Posted 2006-09-30 09:29 ·  中国 重庆 电信
初级用户
Credits 45
Posts 17
Joined 2006-09-23 13:24
19-year member
UID 63469
Status Offline
O.O Such a classic thing, extremely powerful!
Floor 27 Posted 2006-09-30 11:31 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Can't help but top it again, miss willsort

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 28 Posted 2006-10-20 03:06 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Yeah, it's been a long time since I saw Brother willsort's wonderful "lecture", miss it...
Floor 29 Posted 2007-02-08 07:09 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
How can such a wonderful post be allowed to sink ~:)
Appreciation ~:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 30 Posted 2007-02-08 08:40 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Nice
Forum Jump: