中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-11-13 07:40
47,815 topics / 349,931 posts / today 1 new / 48,293 members
DOS批处理 & 脚本技术(批处理室) » [Share] The Oddities in Batch Programming
Printable Version  34,291 / 50
Floor16 willsort Posted 2004-02-06 00:00
元老会员 Posts 1,512 Credits 4,432
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
Floor17 willsort Posted 2004-02-06 00:00
元老会员 Posts 1,512 Credits 4,432
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%






Floor18 pontiff Posted 2004-05-13 00:00
初级用户 Posts 7 Credits 119
Good
A very classic batch script
Floor19 bush Posted 2004-06-22 00:00
银牌会员 Posts 730 Credits 2,165
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.
Floor20 bush Posted 2004-06-23 00:00
银牌会员 Posts 730 Credits 2,165
I still don't know how to use












Floor21 龙王 Posted 2004-10-14 00:00
银牌会员 Posts 334 Credits 1,186
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
Floor22 defrag Posted 2005-02-24 00:00
中级用户 Posts 570 Credits 456
Floor23 lhz95418005 Posted 2005-02-25 00:00
初级用户 Posts 3 Credits 106
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.
Floor24 yangfw54 Posted 2005-11-20 14:28
新手上路 Posts 3 Credits 10
It is indeed a rare and good teaching material, and I'll bring it back to the top again!
Floor25 doscc Posted 2006-03-30 13:08
中级用户 Posts 93 Credits 256 From 广东
```
Top top top
```
Floor26 kmlxk Posted 2006-09-30 09:29
初级用户 Posts 17 Credits 45
O.O Such a classic thing, extremely powerful!
Floor27 electronixtar Posted 2006-09-30 11:31
铂金会员 Posts 2,672 Credits 7,493
Can't help but top it again, miss willsort
Floor28 lxmxn Posted 2006-10-20 03:06
版主 Posts 4,938 Credits 11,386
Yeah, it's been a long time since I saw Brother willsort's wonderful "lecture", miss it...
Floor29 redtek Posted 2007-02-08 07:09
金牌会员 Posts 1,147 Credits 2,902
How can such a wonderful post be allowed to sink ~:)
Appreciation ~:)
Floor30 anqing Posted 2007-02-08 08:40
高级用户 Posts 413 Credits 859
Nice
Prev  1 2 3 4  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023