|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『楼 主』:
[分享]批处理编程的异类
学过DOS的人,或多或少都听过批处理。它小巧轻便,而且是系统级源代码解释,不用编译和连接而直接运行,曾经吸引了不少DOS的爱好者和编程者。众多人士的参与,无数奇思妙想的涌现,构成了批处理编程中的"异类"。它们并不是单纯为解决某些"成批处理的问题"而设计,而是真正将批处理做为一种语言,来体现它无限的创造力。
下面是我搜集的一些批处理程序,他们或许并非是技术上的精品,但绝对是构思上的突破。我会不断的更新和完善这个主题,也希望大家同我一道努力,完成这个"异类"收藏。
索引
======
1楼:本主题
2楼:游戏(Game):
1、三子棋(TicTacToe)
3楼:数学(Math):
1、随机数(Random)生成、随机矩阵生成,共2个
2、2K/XP表达式计算
4楼:时钟(Clock):
1、暂停(Pause)、延迟(Delay)、等待(Wait)或睡眠(Sleep),共5个
声明
======
1,为保持本帖的结构,仅为赞美和支持的同志请尽量不要在此回帖;
2,对本帖某些程序有任何疑问和建议的朋友,请访问下面的主题
http://www.cn-dos.net/forum/viewthread.php?tid=12388
3,有意推荐程序的朋友,请注意以下的选择标准:
(1),程序实现的功能具有一定的通用性和创新性;
(2),程序不依赖于任何特殊或定制的本地环境(比如程序的路径);
(3),程序未使用任何第三方工具或者软件;
(4),程序最好适用于所有的 Windows 和 DOS 平台,如有特殊要求请注明;
4,本主题采用淘汰制,即完成相同或相似功能的代码将采用编写质量最优秀者,无法区分优劣时,或者同时在一帖内列出,或者融合二者的优秀之处改遍成新的代码;被淘汰者或者单独发表主题列出,或者列出可引用的链接。
更新记录
======
2004.06.20: 发出"[讨论]批处理编程的异类"主题,并与"[分享]批处理编程的异类"互相链接
2005.07.16: 更新7楼的 prompt 变量获取程序
2005.08.18: 修改3楼为数学(Math)主题,并增加随机数和随机阵列生成程序
2005.08.19: 修改4楼为时钟(Clock)主题,增加“暂停”程序5个
2005.09.11: 3楼数学(Math)主题增加“2K/XP表达式计算批处理”
[ Last edited by willsort on 2005-9-11 at 13:35 ]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-11 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
2 楼』:
批处理编程异类——游戏(Game)
程序:TicTacToe(三子棋、井字棋、打井、提担挑)
作者:M0eRtH
原文:TicTacToe (a.k.a. Noughts''''''''n''''''''Crosses) BATch version 1.1
http://users.volja.net/sarcasmus/M0/tictactoe/tttbat.html
下载:http://users.volja.net/sarcasmus/M0/tictactoe/tictactoebat.zip
环境:1,程序应该在英文的命令行环境下运行;
2,程序使用了大量的环境变量,应该修改程序运行时环境空间的大小;
3,程序在WIN2K/XP运行需要CHOICE的支持;
备注:
这是我见到第一个用批处理编写的真正具有游戏性的程序,虽然程序并不提供AI对手,但是其优美的结构仍然值得称道。正文中出现的乱码字是因为作者使用了ANSI的表格字符。
同类:
福尔摩斯问答:http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=6&ID=8272
ZD庄园的迷魂阵:http://zdland.xiloo.com/planets/psa.html
正文:
Quote: | @echo off
mode con cols=40 lines=25
cls
echo.
echo TicTacToe (a.k.a. Noughts''''''''n''''''''Crosses)
echo BATch Version 1.1
echo (c)2002 M0eRtH
echo.
echo Updates and more free stuff at
echo http://m0erth.cjb.net
echo.
echo The keys:
echo.
echo - X - - O -
echo.
echo 7 ?8 ?9 Q ?W ?E
echo 哪呐哪呐哪? 哪呐哪呐哪?
echo 4 ?5 ?6 A ?S ?D
echo 哪呐哪呐哪? 哪呐哪呐哪?
echo 1 ?2 ?3 Z/Y?X ?C
echo.
echo Ctrl+R = Reset game Ctrl+Q = Quit
echo.
echo Note:
echo X, make sure the NumLock is ON. ;-)
echo.
pause
set a1=-
set a2=-
set a3=-
set b1=-
set b2=-
set b3=-
set c1=-
set c2=-
set c3=-
set turn=X
set win=-
set result=-
set scoreX=-
set scoreO=-
set games=-
set maxgames=-++++++++++++++++++++
:draw
cls
echo.
echo TicTacToe (a.k.a. Noughts''''''''n''''''''Crosses)
echo BATch Version 1.1
echo (c)2002 M0eRtH
echo.
echo Score
echo X:%scoreX%
echo O:%scoreO%
echo.
echo %a1% ?%a2% ?%a3%
echo 哪呐哪呐哪?
echo %b1% ?%b2% ?%b3%
echo 哪呐哪呐哪?
echo %c1% ?%c2% ?%c3%
echo.
:chkWin
set result=%a1%%a2%%a3%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
set result=%b1%%b2%%b3%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
set result=%c1%%c2%%c3%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
set result=%a1%%b1%%c1%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
set result=%a2%%b2%%c2%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
set result=%a3%%b3%%c3%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
set result=%a1%%b2%%c3%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
set result=%c1%%b2%%a3%
if %result%==XXX goto XWon
if %result%==OOO goto OWon
:getKeys
echo %turn%''''''''s turn
choice /c:789456123qweasdzyxc /n :
if errorlevel 21 goto reset
if errorlevel 20 goto quit
if errorlevel 19 goto setOC3
if errorlevel 18 goto setOC2
if errorlevel 17 goto setOC1
if errorlevel 16 goto setOC1
if errorlevel 15 goto setOB3
if errorlevel 14 goto setOB2
if errorlevel 13 goto setOB1
if errorlevel 12 goto setOA3
if errorlevel 11 goto setOA2
if errorlevel 10 goto setOA1
if errorlevel 9 goto setXC3
if errorlevel 8 goto setXC2
if errorlevel 7 goto setXC1
if errorlevel 6 goto setXB3
if errorlevel 5 goto setXB2
if errorlevel 4 goto setXB1
if errorlevel 3 goto setXA3
if errorlevel 2 goto setXA2
if errorlevel 1 goto setXA1
goto draw
:reset
set a1=-
set a2=-
set a3=-
set b1=-
set b2=-
set b3=-
set c1=-
set c2=-
set c3=-
goto draw
:setXA1
if not %a1%==- goto draw
if %turn%==O goto draw
set a1=X
goto changeTurn
:setXA2
if not %a2%==- goto draw
if %turn%==O goto draw
set a2=X
goto changeTurn
:setXA3
if not %a3%==- goto draw
if %turn%==O goto draw
set a3=X
goto changeTurn
:setXB1
if not %b1%==- goto draw
if %turn%==O goto draw
set b1=X
goto changeTurn
:setXB2
if not %b2%==- goto draw
if %turn%==O goto draw
set b2=X
goto changeTurn
:setXB3
if not %b3%==- goto draw
if %turn%==O goto draw
set b3=X
goto changeTurn
:setXC1
if not %c1%==- goto draw
if %turn%==O goto draw
set c1=X
goto changeTurn
:setXC2
if not %c2%==- goto draw
if %turn%==O goto draw
set c2=X
goto changeTurn
:setXC3
if not %c3%==- goto draw
if %turn%==O goto draw
set c3=X
goto changeTurn
:setOA1
if not %a1%==- goto draw
if %turn%==X goto draw
set a1=O
goto changeTurn
:setOA2
if not %a2%==- goto draw
if %turn%==X goto draw
set a2=O
goto changeTurn
:setOA3
if not %a3%==- goto draw
if %turn%==X goto draw
set a3=O
goto changeTurn
:setOB1
if not %b1%==- goto draw
if %turn%==X goto draw
set b1=O
goto changeTurn
:setOB2
if not %b2%==- goto draw
if %turn%==X goto draw
set b2=O
goto changeTurn
:setOB3
if not %b3%==- goto draw
if %turn%==X goto draw
set b3=O
goto changeTurn
:setOC1
if not %c1%==- goto draw
if %turn%==X goto draw
set c1=O
goto changeTurn
:setOC2
if not %c2%==- goto draw
if %turn%==X goto draw
set c2=O
goto changeTurn
:setOC3
if not %c3%==- goto draw
if %turn%==X goto draw
set c3=O
goto changeTurn
:changeTurn
if %turn%==X goto setTurnO
set turn=X
goto draw
:setTurnO
set turn=O
goto draw
:XWon
echo.
echo - X won! -
pause
set scoreX=%scoreX%+
set games=%games%+
if %games%==%maxgames% goto quit
goto reset
:OWon
echo.
echo - O won! -
pause
set scoreO=%scoreO%+
set games=%games%+
if %games%==%maxgames% goto quit
goto reset
:quit
mode con cols=80 lines=25
echo.
echo TicTacToe (a.k.a. Noughts''''''''n''''''''Crosses)
echo BATch Version 1.1
echo (c)2002 M0eRtH
echo.
echo Updates and more free stuff at
echo http://m0erth.cjb.net
echo.
echo.
echo X scored: %scoreX%
echo O scored: %scoreO%
echo.
set a1=
set a2=
set a3=
set b1=
set b2=
set b3=
set c1=
set c2=
set c3=
set turn=
set win=
set result=
set scoreX=
set scoreO=
set games=
set maxgames=
pause |
|
[此贴子已经被作者于2004-6-20 下午 05:42:48编辑过]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-11 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
3 楼』:
批处理编程的异类——数学(Math)
1、数学——随机
1)随机数发生器:运行后可产生一个00~99的随机整数,并保存于环境变量 %_random% 中。
如果要产生更复杂的随机数,也可以利用这个程序进行修改来得到,比如两次产生的随机数组合,即可得到0000~9999的随机数;在随机数前加上小数点,即可得到0.00-0.99的随机小数;将 prompt _$T$_:: 中的第一个下划线去除,可以得到0~9的随机数;用debug可以去除某些随机数的前缀0。根据以上方法,即可组合得到任意形式的随机数了。
:: GenARnd.Bat - Generate a random integer (00~99)
:: Will Sort - 12:06 2005-8-18 - V2 - MSDOS7.10/CMD@WinXP/MSDOS6.22
@echo off
echo exit|%comspec% /k prompt _$T$_::> _GenARnd.bat
echo e 100 "set _random=">_GenARnd.asd
for %%s in (w q) do echo %%s>>_GenARnd.asd
debug _GenARnd.bat < _GenARnd.asd > nul
call _GenARnd.bat
for %%f in (_GenARnd*.*) do del %%f
if not "%_random%"=="" if not [%1]==[@] echo Random number : %_random%
:End 2)随机阵列发生器:运行后将生成一张随机概率分布矩阵图。
此图24行63列,由字符“-”(假)和“o”(真)组成,从上到下每三行为一组,呈现出o的分布概率依次降低。其中矩阵中的左图为真假序列分布,右图为真假数目对比。
:: RndArray.bat - Generate a serial of random numbers(- or o)
:: Will Sort - 2004/11/24
@echo off
if "%1"==":" goto %2
set no=
set num=0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
:loop
set no=I%no%
set line=
set -=
set o=
for %%c in (%num%) do call %0 : random %no%
echo %line% : %-%%o%
set line=
set -=
set o=
for %%c in (%num%) do call %0 : random %no%
echo %line% : %-%%o%
set line=
set -=
set o=
for %%c in (%num%) do call %0 : random %no%
echo %line% : %-%%o%
if not [%no%]==[IIIIIIII] goto loop
:quit
del _Random.tmp
for %%e in (- o no num line) do set %%e=
goto end
:random
echo. | time > _Random.tmp
::echo exit | %comspec% /k prompt $T>_Random.tmp
goto %3
find ".0"<_Random.tmp>nul
if not errorlevel 1 goto true
:I
find ".3"<_Random.tmp>nul
if not errorlevel 1 goto true
:II
find ".6"<_Random.tmp>nul
if not errorlevel 1 goto true
:III
find ".9"<_Random.tmp>nul
if not errorlevel 1 goto true
:IIII
find ".2"<_Random.tmp>nul
if not errorlevel 1 goto true
:IIIII
find ".5"<_Random.tmp>nul
if not errorlevel 1 goto true
:IIIIII
find ".8"<_Random.tmp>nul
if not errorlevel 1 goto true
:IIIIIII
find ".1"<_Random.tmp>nul
if not errorlevel 1 goto true
:IIIIIIII
find ".4"<_Random.tmp>nul
if not errorlevel 1 goto true
find ".7"<_Random.tmp>nul
if not errorlevel 1 goto true
::del _Random.tmp
:false
set line=%line%-
set -=-%-%
goto end
:true
set line=%line%o
set o=o%o%
goto end
:end 2、数学——表达式
1)2K/XP表达式计算批处理,由 Brglng 原创并维护。转帖时精简了程序中的文档部分,可以通过以下链接查阅完整的代码和文档。
{16534}2K/XP表达式计算批处理
http://www.cn-dos.net/forum/viewthread.php?tid=16534
:: Eval.cmd - 2K/XP表达式计算批处理
:: Brglng - 2005.8.31
@echo off
setlocal
if /i "%1"=="/A" if "%2"=="" echo 必须指定文件路径!& goto end
if /i not "%1"=="/A" if /i not "%1"=="/N" if not "%1"=="" goto EvalArgument
echo 请输入表达式(输入"Q"退出) & goto inputExpr
:EvalArgument
set /a EvalExpr="%1"
if "%EvalExpr%"=="" echo 表达式输入错误! & goto end
echo %1=%EvalExpr%
if "%2"=="" goto end
echo %1=%EvalExpr% >>"%2"
echo 算式和计算结果已存入"%2"!
goto end
:inputExpr
set Expr=
set EvalExpr=
set /p Expr=^>
if "%Expr%"=="" goto inputExpr
if /i "%Expr%"=="Q" goto end
set /a EvalExpr="%Expr%"
if "%EvalExpr%"=="" echo 输入错误! & goto inputExpr
echo 计算结果为:%EvalExpr%
if /i "%1"=="/A" goto autosave
if /i "%1"=="/N" goto inputExpr
:if_save
set SaveEval=
set /p SaveEval=是否将表达式和计算结果存入文件[Y/N]?
if /i "%SaveEval%"=="Y" goto save
if /i "%SaveEval%"=="N" goto inputExpr
goto if_save
:save
set /p SaveEvalPath=请输入文件路径及文件名(如C:\Windows\file.txt。若只输入文件名则自动存入当前文件夹,留空则为上一次输入的路径):
echo "%Expr%"=%EvalExpr% >>"%SaveEvalPath%"
echo 表达式以及计算结果已存入"%SaveEvalPath%"!
goto inputExpr
:autosave
echo "%Expr%"=%EvalExpr% >>"%2"
goto inputExpr
:end [ Last edited by willsort on 2005-9-11 at 13:37 ]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
4 楼』:
批处理编程的异类——时钟(Clock)
1、暂停(Pause)、延迟(Delay)、等待(Wait)、睡眠(Sleep)
1)for+set+if,时间精度为0.01秒,适用平台为WinNT/2K/XP/2003。
利用for解析变量%time%并存为两个时间点%start%和%now%,再利用set /a计算两个时间点的时间差,最后用if判断时间差是否达到设定的暂停时间。
@echo off
setlocal enableextensions
echo %time%
call :ProcDelay 200
echo %time%
goto :EOF
:ProcDelay delayMSec_
setlocal enableextensions
for /f "tokens=1-4 delims=:. " %%h in ("%time%") do set start_=%%h%%i%%j%%k
:_procwaitloop
for /f "tokens=1-4 delims=:. " %%h in ("%time%") do set now_=%%h%%i%%j%%k
set /a diff_=%now_%-%start_%
if %diff_% LSS %1 goto _procwaitloop
endlocal & goto :EOF 2)VBS脚本中的sleep函数,时间精度为0.001秒,使用平台为Win9x/WinNT系列。
动态创建一个调用sleep()函数的VBS脚本,然后用Windows脚本宿主的命令行版本cscript调用它。
@echo off & setlocal enableextensions enabledelayedexpansion
echo WScript.Sleep 2000 > %temp%\tmp$$$.vbs
echo %time%
cscript //nologo %temp%\tmp$$$.vbs
echo %time%
for %%f in (%temp%\tmp$$$.vbs) do if exist %%f del %%f
endlocal & goto :EOF 3)ping的消息发送间隔,时间精度为1秒,使用平台为Win9x/WinNT系列。
需要你的Windows系统中正常安装了网卡的TCP/IP协议,有两种方案,方案二不建议采用,见主题 [讨论]批处理编程的异类 12、13楼:
(1) 利用ping两次发送消息之间的间隔时间。ping在发送多个消息时,在得到上一次消息的回应后,它会再等待1秒的时间才发送下一次消息,而这个回应时间因机型、系统和网络配置而不同,其中IP地址尤其关键,只有本地的回送地址 127.0.0.1 因为是立即回应所以才是相对恒定的,其他地址大多会产生显著的差异。此种方法要等待更大的时间,是指定发送的消息数为等待的时间加一,因为第一个消息是不等待的,IP 地址必须是 127.0.0.1 。其等待2秒的程序如下:
::根据植树原则,n后的数字为暂停秒数加一
ping -n 3 127.0.0.1>nul (2) 利用ping的最大等待时间。ping向0.0.0.1发送一次“网际消息控制协议 (ICMP)”回响请求消息,因为 0.0.0.1 是个无法响应 ping 请求的IP地址,所以默认情况下,ping会等待一定的最大响应时间——4秒后便停止等待,而-w可以改变这个每发送一次消息所等待的最大响应时间。而如果将 IP 地址改为立即响应的127.0.0.1或其他响应时间很短的IP ,那 -w 便失去了作用,因为每次发送等待时间都不会达到最大的响应时间,此时延时会缩短。此种方法要等待更大的时间,可以直接使用 -w 指定,但是需要减去一定的发送延时,这个延时需要自己事先测定一下,否则会有不到1秒的误差;而且 IP 地址必须是不响应请求的地址。其等待2秒的程序如下:
ping -n 2 -w 500 0.0.0.1>nul 4)choice的缺省选择等待功能,时间精度为1秒,适用平台为MS-DOS/Win9x/WinNT系列。
/t:y,2 将缺省选择字符设置为y,等待时间是2秒,/n禁止[y,n]提示出现在命令行上,“rem|”的作用是禁止choice从键盘接受按键,从而暂停不会因为按下y或者其它键而被意外终止。
rem|choice /t:y,2 /n >nul 5)ASCII汇编代码,延迟精度为0.001秒,适用平台为MS-DOS/Win9x/WinNT。
德国人Herbert Kleebauer给出了一个通用方案,通过ASCII汇编器间接产生一个sleep.exe程序来实现延迟,这个程序分为DOS和Win两个模块,分别调用DOS系统中断服务和WindowsAPI。
:: Sleep.bat - Sleep/Delay/Wait n seconds
:: Herbert Kleebauer(Germany) - 2005/05/29
:: Modified by Will Sort - 2005/06/02, 07-25
@echo off
echo q | debug>nul
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>sleep.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>sleep.com
echo T}{z~~@GwkBG@OEKcUt`~}@MqqBsy?seHB~_Phxr?@zAB`LrPEyoDt@Cj?>>sleep.com
echo pky_jN@QEKpEt@ij?jySjN@REKpEt@jj?jyGjN@SEKkjtlGuNw?p@pjirz>>sleep.com
echo LFvAURQ?OYLTQ@@?~QCoOL~RDU@?aU?@{QOq?@}IKuNWpe~FpeQFwH?Vkk>>sleep.com
echo _GSqoCvH{OjeOSeIQRmA@KnEFB?p??mcjNne~B?M??QhetLBgBPHexh@e=>>sleep.com
echo EsOgwTLbLK?sFU`?LDOD@@K@xO?SUudA?_FKJ@N?KD@?UA??O}HCQOQ??R>>sleep.com
echo _OQOL?CLA?CEU?_FU?UAQ?UBD?LOC?ORO?UOL?UOD?OOI?UgL?LOR@YUO?>>sleep.com
echo dsmSQswDOR[BQAQ?LUA?_L_oUNUScLOOuLOODUO?UOE@OwH?UOQ?DJTSDM>>sleep.com
echo QTqrK@kcmSULkPcLOOuLOOFUO?hwDTqOsTdbnTQrrDsdFTlnBTm`lThKcT>>sleep.com
echo @dmTkRQSoddTT~?K?OCOQp?o??Gds?wOw?PGAtaCHQvNntQv_w?A?it\EH>>sleep.com
echo {zpQpKGk?Jbs?FqokOH{T?jPvP@IQBDFAN?OHROL?Kj??pd~aN?OHROd?G>>sleep.com
echo Q??PGT~B??OC~?ipO?T?~U?p~cUo0x>>sleep.com
sleep.com>sleep.exe
echo wait %1 seconds:
sleep.exe %1000
del sleep.com
del sleep.exe [ Last edited by willsort on 2005-12-4 at 21:37 ]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
5 楼』:
以下是一个用字符方式画图的程序,原文来自网易广州站DOS版。
http://fe2.gz.163.com/cgi/readsrh?b=DOS&t=15763&i=15763&al=5&n=0&l=40&back=2&st=0&kw=MAP
这个程序的工作方式很简陋,不过已经具备了一些基本的功能,比如画,擦,更换画笔字符,保存和提取字符画,备份和恢复字符画,使字符画可执行化等。程序用到了ANSI.SYS 的支持功能,所以 ECHO 后的方框字符实际上是 ASCII 码为27的符号,可在DOS下的 EDIT 中按 CTRL+P 然后按 ESC 输入此字符。
------------------------------------
Quote: | @ECHO OFF
:START
IF NOT [%3]==[] GOTO MAP%1
IF [%1]==[/?] GOTO MAPHELP
CHOICE Initizing, Please waiting../C:. /T:.,1 /N
IF [%1]==[R:] GOTO MAPRESTORE
IF [%1]==[E:] GOTO MAPEXTRACT
IF [%1]==[T:] GOTO MAPTRYSAVE
MEM /C|FIND "ANSI">NUL
IF ERRORLEVEL 1 GOTO MAPERR1
IF [%1]==[] GOTO MAPINIT
IF [%2]==[] GOTO MAPERR2
IF [%1]==[C:] IF NOT [%2]==[/LINE] IF NOT [%2]==[/PIPE] SET $F=%2
IF [%1]==[C:] GOTO MAPSTART
IF NOT EXIST %2.MAP GOTO MAPERR5
FIND "[s" %2.MAP>NUL
IF ERRORLEVEL 1 GOTO MAPERR3
REM FIND "[25;80H" %2.MAP>NUL
REM IF ERRORLEVEL 1 GOTO MAPERR4
IF [%1]==[V:] GOTO MAPVIEW
IF [%1]==[L:] GOTO MAPLOAD
IF [%1]==[M:] GOTO MAPMAKE
:MAPINIT
CLS
SET $F=?
SET PRE=C
GOTO MAPSTART
:MAPHELP
ECHO.
ECHO Use: Draw a map with painter of characterS, and save to map file.
ECHO Usage: %0 option: parameter
ECHO Option:
ECHO L Load map file from the specified location.
ECHO M Make map file to selfexec map program.
ECHO E Extract selfexec map to map file.
ECHO T Try save map file from temporary location.
ECHO R Restore the map backuped map file.
ECHO V View the map file parameter specifle.
ECHO C define painter with Character parameter specifle.
ECHO.
CHOICE View guide of draw:
IF ERRORLEVEL 2 GOTO MAPEND
ECHO.
ECHO All operation control by keyboard keys.
ECHO.
ECHO Key: Use:
ECHO 1 Left and down ----)
ECHO 2 Down )
ECHO 3 Right and down )
ECHO 4 Left )---Painter Move keys
ECHO 6 Right )
ECHO 7 Left and up )
ECHO 8 Up )
ECHO 9 Right and up------)
ECHO 5 painter
ECHO 0(Ins) change to draw state
ECHO .(Del) change to delete state
ECHO.
GOTO MAPEND
:MAPERR1
ECHO.
ECHO Error 1 in %0: Not continue for not load ANSI.
ECHO.
GOTO MAPEND
:MAPERR2
ECHO.
ECHO Error 2 in %0: Not specified second parameter.
ECHO.
GOTO MAPEND
:MAPERR3
ECHO.
ECHO Error 3 in %0: False map file.
ECHO.
GOTO MAPEND
:MAPERR4
ECHO.
ECHO Error 4 in %0: Not accomplish map file.
ECHO.
GOTO MAPEND
:MAPERR5
ECHO.
ECHO Error 5 in %0: Not exist map file.
ECHO.
GOTO MAPEND
:MAPERR6
ECHO.
ECHO Error 6 in %0: Not backup map file.
ECHO.
GOTO MAPEND
:MAPERR7
ECHO.
ECHO Error 7 in %0: Not make selfexec map program.
ECHO.
GOTO MAPEND
:MAPERR8
ECHO.
ECHO Error 8 in %0: Not correctly pattern selfexec map program.
ECHO.
GOTO MAPEND
:MAPERR9
ECHO.
ECHO Error 9 in %0: Can''''t view map file.
ECHO.
GOTO MAPEND
:MAPERR10
ECHO.
ECHO Error 10 in %0: enviroment parameter PRE is null.
::MAPPICK
IF EXIST %2.MAP CHOICE Modify this map file
IF ERRORLEVEL 2 GOTO MAPEND
ECHO @CLS>PAINTER.BAT
ECHO @SET $F=%%1>>PAINTER.BAT
ECHO @%0 START %2 /S>>PAINTER.BAT
ECHO Please choose painter of character with style (PAINTER=char).
PROMPT
GOTO MAPEND
:MAPSAVEPRE
ECHO @ECHO OFF>>SAVEFILE.BAT
IF [%3]==[] ECHO IF NOT [%%1]==[] %0 SAVE %%1 /G>>SAVEFILE.BAT
IF [%3]==[/L] ECHO IF NOT [%%1]==[] %0 SAVE %%1 /G %2>>SAVEFILE.BAT
ECHO ECHO Please input save path again:>>SAVEFILE.BAT
ECHO Please save file and path with (SAVEFILE=path\file) style:
PROMPT
GOTO MAPEND
:MAPSAVE
IF NOT EXIST %2.MAP GOTO MAPSSUF
IF NOT [%4]==[] GOTO MAPSSUF
CHOICE Map name exist, rename
IF ERRORLEVEL 2 GOTO MAPSSUF
ECHO Please input save path again:
GOTO MAPEND
:MAPSSUF
PROMPT $P$G
IF EXIST SAVEFILE.BAT DEL SAVEFILE.BAT
IF [%2]==[%4] COPY %4.MAP %4.MBK /Y>NUL
COPY %TEMP%\TEMP.MP$ %2.MAP /Y>NUL
DEL %TEMP%\TEMP.MP$
GOTO MAPEND
:MAPLOAD
COPY %2.MAP %TEMP%\%2.BAT>NUL
ECHO @ECHO OFF>PAINTER.BAT
ECHO CLS>>PAINTER.BAT
ECHO IF [%%1]==[] GOTO PEND>>PAINTER.BAT
ECHO SET $F=%%1>>PAINTER.BAT
ECHO CALL %0 KEYON # /G>>PAINTER.BAT
ECHO CALL %TEMP%\%2.BAT>>PAINTER.BAT
ECHO %0 START %2 /L>>PAINTER.BAT
ECHO END>>PAINTER.BAT
ECHO Please choose painter of character with style (PAINTER=char).
PROMPT
GOTO MAPEND
:MAPVIEW
IF NOT EXIST %2.MAP GOTO MAPERR5
COPY %2.MAP %TEMP%\%2.BAT>NUL
CLS
CALL %TEMP%\%2.BAT
ECHO [24;80H
DEL %TEMP%\%2.BAT
GOTO MAPEND
:MAPMAKE
IF NOT EXIST %2.MAP GOTO MAPERR5
IF EXIST %2.BAT CHOICE Modify existed selfexec map file
IF ERRORLEVEL 2 GOTO MAPEND
ECHO Making...
ECHO @ECHO OFF>MAP.H
ECHO MEM/C|FIND "ANSI">>MAP.H
ECHO IF NOT ERRORLEVEL 1 GOTO MAPAINT>>MAP.H
ECHO.>>MAP.H
ECHO :MAPERROR>>MAP.H
ECHO ECHO.>>MAP.H
ECHO ECHO Error 1: Not load this map file for not load ANSI.>>MAP.H
ECHO ECHO.>>MAP.H
ECHO GOTO MAPEND>>MAP.H
ECHO.>>MAP.H
ECHO :MAPAINT>>MAP.H
ECHO CLS>>MAP.H
IF EXIST %2.BAT ATTRIB -R %2.BAT
COPY /B MAP.H+%2.MAP %2.BAT>NUL
ECHO.>>%2.BAT
ECHO :MAPEND>>%2.BAT
ATTRIB +R %2.BAT
DEL MAP.H
ECHO Made success.
GOTO MAPEND
:MAPRESTORE
IF NOT EXIST %2.MBK GOTO MAPERR6
IF EXIST %2.MAP CHOICE Realy restore and overwrite map file
IF ERRORLEVEL 2 GOTO MAPEND
COPY %2.MBK %2.MAP /Y>NUL
DEL %2.MBK
ECHO Restored.
%0 V: %2
GOTO MAPERR9
:MAPEXTRACT
IF NOT EXIST %2.BAT GOTO MAPERR7
IF EXIST %2.MAP CHOICE Realy extract and overwrite map file
FIND ":MAPAINT" %2.BAT>NUL
IF ERRORLEVEL 1 GOTO MAPERR8
TYPE %2.BAT|FIND "[">%2.MAP
CHOICE Extracted. Delete selfexec map file
IF NOT ERRORLEVEL 1 DEL %2.BAT
%0 V: %2
GOTO MAPERR9
:MAPTRYSAVE
IF NOT EXIST %TEMP%\TEMP.MP$ GOTO MAPEND
IF EXIST %2.MAP CHOICE Realy try to save and overwrite map file
COPY %TEMP%\TEMP.MP$ %2.MAP /Y>NUL
ECHO Try success.
%0 V: %2
GOTO MAPERR9
:MAPKEYON
ECHO ["7";"U"p
ECHO ["8";"I"p
ECHO ["9";"O"p
ECHO ["4";"J"p
ECHO ["5";"K"p
ECHO ["6";"L"p
ECHO ["1";"M"p
ECHO ["2";","p
ECHO ["3";"."p
ECHO ["0";"Y"p
ECHO [".";"N"p
ECHO [0;71;"U"p
ECHO [0;72;"I"p
ECHO [0;73;"O"p
ECHO [0;75;"J"p
ECHO [0;76;"K"p
ECHO [0;77;"L"p
ECHO [0;79;"M"p
ECHO [0;80;","p
ECHO [0;81;"."p
ECHO [0;82;"Y"p
ECHO [0;83;"N"p
GOTO MAPEND
:MAPKEYOFF
ECHO [0;71;0;71p
ECHO [0;72;0;72p
ECHO [0;73;0;73p
ECHO [0;75;0;75p
ECHO [0;76;0;76p
ECHO [0;77;0;77p
ECHO [0;79;0;79p
ECHO [0;80;0;80p
ECHO [0;81;0;81p
ECHO [0;82;0;82p
ECHO [0;83;0;83p
ECHO ["7";"7"p
ECHO ["8";"8"p
ECHO ["9";"9"p
ECHO ["4";"4"p
ECHO ["5";"5"p
ECHO ["6";"6"p
ECHO ["1";"1"p
ECHO ["2";"2"p
ECHO ["3";"3"p
ECHO ["0";"0"p
ECHO [".";"."p
GOTO MAPEND
:MAPSTART
IF EXIST PAINTER.BAT DEL PAINTER.BAT
IF NOT [%3]==[/L] CALL %0 KEYON # /G
IF [%2]==[/LINE] GOTO MAPEDIT
IF [%2]==[/PIPE] GOTO MAPEDIT
:MAPLENG
SET $M=
SET $CN=[1C
SET $DN=[1D
SET $LN=[1D
SET $A$=%$F%
:MAPSET
FOR %%A IN (/%$A$%) DO SET $B$=%%A
IF [%$A$%]==[%$B$%] GOTO MAPEDIT
SET $A$=%$B$%
SET $DN=%$DN%[1D
SET $CN=%$CN%[1C
SET $LN=%$DN%
SET $M=%$M%
GOTO MAPSET
:MAPCHANGE
ECHO [u?
IF ERRORLEVEL 2 SET $F=?
IF ERRORLEVEL 2 GOTO MAPPIPE
SET $F=@
GOTO MAPLINE
:MAPEDIT
IF NOT [%3]==[/L] GOTO MAPNEW
COPY %2.MAP %TEMP%\TEMP.MP$ /Y>NUL
SET $SN=%$LN%
SET $LN=
SET $SF=%$F%
SET $F=
IF [%2]==[/LINE] GOTO MAPLINE
IF [%2]==[/PIPE] GOTO MAPPIPE
GOTO MAPCHAR
:MAPNEW
IF EXIST %TEMP%\TEMP.MP$ DEL %TEMP%\TEMP.MP$
ECHO [0m[33;44;1m[2J
ECHO [12;21H[s%$F%
ECHO ECHO [12;21H[s%$F%>>%TEMP%\TEMP.MP$
IF [%2]==[/LINE] GOTO MAPLINE
IF [%2]==[/PIPE] GOTO MAPPIPE
GOTO MAPCHAR
:MAPCHAR
ECHO [u%$F%
CHOICE /C:QYNUOKM.IJ,L /N>NUL
IF ERRORLEVEL 12 GOTO MAPCRIGHT
IF ERRORLEVEL 11 GOTO MAPCDOWN
IF ERRORLEVEL 10 GOTO MAPCLEFT
IF ERRORLEVEL 9 GOTO MAPCUP
IF ERRORLEVEL 8 GOTO MAPCRGDW
IF ERRORLEVEL 7 GOTO MAPCLTDW
IF ERRORLEVEL 6 GOTO MAPCTAB
IF ERRORLEVEL 5 GOTO MAPCRGUP
IF ERRORLEVEL 4 GOTO MAPCLTUP
IF ERRORLEVEL 3 GOTO MAPCDEL
IF ERRORLEVEL 2 GOTO MAPCINS
GOTO MAPCLEAN
:MAPCTAB
REM ECHO [0m[33;44;1m[u%$F%[32;45;5m
IF NOT [%$F%]==[] GOTO MAPCOVER
SET $LN=%$SN%
SET $SN=
SET $F=%$SF%
SET $SF=
GOTO MAPCHAR
:MAPCOVER
SET $SN=%$LN%
SET $LN=
SET $SF=%$F%
SET $F=
GOTO MAPCHAR
:MAPCINS
IF [%$F%]==[] GOTO MAPCOINS
IF NOT [%$F%]==[%$M%] GOTO MAPCHAR
SET $F=%$T%
SET $T=
GOTO MAPCHAR
:MAPCOINS
IF NOT [%$SF%]==[%$M%] GOTO MAPCHAR
SET $SF=%$T%
SET $T=
GOTO MAPCHAR
:MAPCDEL
IF [%$F%]==[] GOTO MAPCODEL
IF [%$F%]==[%$M%] GOTO MAPCHAR
SET $T=%$F%
SET $F=%$M%
GOTO MAPCHAR
:MAPCODEL
IF [%$SF%]==[%$M%] GOTO MAPCHAR
SET $T=%$SF%
SET $SF=%$M%
GOTO MAPCHAR
:MAPCRGDW
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u%$CN%[1B[s
ECHO ECHO [u%$CN%[1B%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPCLTDW
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u%$DN%[1B[s
ECHO ECHO [u%$DN%[1B%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPCRGUP
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u%$CN%[1A[s
ECHO ECHO [u%$CN%[1A%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPCLTUP
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u%$DN%[1A[s
ECHO ECHO [u%$DN%[1A%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPCRIGHT
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u%$CN%[s
ECHO ECHO [u%$CN%%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPCDOWN
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u[1B[s
ECHO ECHO [u[1B%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPCLEFT
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u%$DN%[s
ECHO ECHO [u%$DN%%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPCUP
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO [u[1A[s
ECHO ECHO [u[1A%$F%%$LN%[s>>%TEMP%\TEMP.MP$
GOTO MAPCHAR
:MAPLINE
ECHO [u%$F%
CHOICE /C:ZAWRXVSEFCDYNIJ,LKQP /N>NUL
IF ERRORLEVEL 20 GOTO MAPCHANGE
IF ERRORLEVEL 19 GOTO MAPCLEAN
IF ERRORLEVEL 18 GOTO MAPLTAB
IF ERRORLEVEL 17 GOTO MAPLRIGHT
IF ERRORLEVEL 16 GOTO MAPLDOWN
IF ERRORLEVEL 15 GOTO MAPLLEFT
IF ERRORLEVEL 14 GOTO MAPLUP
IF ERRORLEVEL 13 GOTO MAPLDEL
IF ERRORLEVEL 12 GOTO MAPLINS
SET HPF=1
ECHO [0m[33;44;1m
FOR %%A IN (1 2 3 4 5 6 7 8 9 10 11) DO IF ERRORLEVEL %%A GOTO MAPLP%%A
ECHO [32;45;5m
GOTO MAPLINE
:MAPLP1
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP2
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP3
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP4
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP5
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP6
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP7
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP8
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP9
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP10
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLP11
ECHO [u?
SET $F=?
GOTO MAPLINE
:MAPLTAB
REM ECHO [0m[33;44;1m[u%$F%[32;45;5m
IF NOT [%$F%]==[] GOTO MAPLOVER
SET $F=%$SF%
SET $SF=
GOTO MAPLINE
:MAPLOVER
SET $SF=%$F%
SET $F=
GOTO MAPLINE
:MAPLINS
IF [%$F%]==[] GOTO MAPLOINS
IF NOT [%$F%]==[%$M%] GOTO MAPLINE
SET $F=%$T%
SET $T=
GOTO MAPLINE
:MAPLOINS
IF NOT [%$SF%]==[%$M%] GOTO MAPLINE
SET $SF=%$T%
SET $T=
GOTO MAPLINE
:MAPLDEL
IF [%$F%]==[] GOTO MAPLODEL
IF [%$F%]==[%$M%] GOTO MAPLINE
SET $T=%$F%
SET $F=%$M%
GOTO MAPLINE
:MAPLODEL
IF [%$SF%]==[%$M%] GOTO MAPLINE
SET $T=%$SF%
SET $SF=%$M%
GOTO MAPLINE
:MAPLRIGHT
SET $BF=?
IF [%PRE%]==[A] SET $BF=?
IF [%PRE%]==[B] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1C[s
SET PRE=C
GOTO MAPLINE
:MAPLDOWN
SET $BF=?
IF [%PRE%]==[C] SET $BF=?
IF [%PRE%]==[D] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1B[s
SET PRE=B
GOTO MAPLINE
:MAPLLEFT
SET $BF=?
IF [%PRE%]==[A] SET $BF=?
IF [%PRE%]==[B] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1D[s
SET PRE=D
GOTO MAPLINE
:MAPLUP
SET $BF=?
IF [%PRE%]==[C] SET $BF=?
IF [%PRE%]==[D] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1A[s
SET PRE=A
GOTO MAPLINE
:MAPPIPE
ECHO [u%$F%
CHOICE /C:ZAWRXVSEFCDYNIJ,LKQP /N>NUL
IF ERRORLEVEL 20 GOTO MAPCHANGE
IF ERRORLEVEL 19 GOTO MAPCLEAN
IF ERRORLEVEL 18 GOTO MAPPTAB
IF ERRORLEVEL 17 GOTO MAPPRIGHT
IF ERRORLEVEL 16 GOTO MAPPDOWN
IF ERRORLEVEL 15 GOTO MAPPLEFT
IF ERRORLEVEL 14 GOTO MAPPUP
IF ERRORLEVEL 13 GOTO MAPPDEL
IF ERRORLEVEL 12 GOTO MAPPINS
SET HPF=1
ECHO [0m[33;44;1m
FOR %%A IN (1 2 3 4 5 6 7 8 9 10 11) DO IF ERRORLEVEL %%A GOTO MAPPP%%A
ECHO [32;45;5m
GOTO MAPPIPE
:MAPPP1
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP2
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP3
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP4
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP5
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP6
ECHO [u
SET $F=
GOTO MAPPIPE
:MAPPP7
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP8
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP9
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP10
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPP11
ECHO [u?
SET $F=?
GOTO MAPPIPE
:MAPPTAB
REM ECHO [0m[33;44;1m[u%$F%[32;45;5m
IF NOT [%$F%]==[] GOTO MAPPOVER
SET $F=%$SF%
SET $SF=
GOTO MAPPIPE
:MAPPOVER
SET $SF=%$F%
SET $F=
GOTO MAPPIPE
:MAPPINS
IF [%$F%]==[] GOTO MAPPOINS
IF NOT [%$F%]==[%$M%] GOTO MAPPIPE
SET $F=%$T%
SET $T=
GOTO MAPPIPE
:MAPPOINS
IF NOT [%$SF%]==[%$M%] GOTO MAPPIPE
SET $SF=%$T%
SET $T=
GOTO MAPPIPE
:MAPPDEL
IF [%$F%]==[] GOTO MAPPODEL
IF [%$F%]==[%$M%] GOTO MAPPIPE
SET $T=%$F%
SET $F=%$M%
GOTO MAPPIPE
:MAPPODEL
IF [%$SF%]==[%$M%] GOTO MAPPIPE
SET $T=%$SF%
SET $SF=%$M%
GOTO MAPPIPE
:MAPPRIGHT
SET $BF=?
IF [%PRE%]==[A] SET $BF=?
IF [%PRE%]==[B] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1C[s
SET PRE=C
GOTO MAPPIPE
:MAPPDOWN
SET $BF=?
IF [%PRE%]==[C] SET $BF=?
IF [%PRE%]==[D] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1B[s
SET PRE=B
GOTO MAPPIPE
:MAPPLEFT
SET $BF=?
IF [%PRE%]==[A] SET $BF=?
IF [%PRE%]==[B] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1D[s
SET PRE=D
GOTO MAPPIPE
:MAPPUP
SET $BF=?
IF [%PRE%]==[C] SET $BF=?
IF [%PRE%]==[D] SET $BF=?
IF [%HPF%]==[] SET $F=%$BF%
ECHO [0m[33;44;1m[u%$F%[32;45;5m
ECHO ECHO [u[1%PRE%%$F%[1D[s>>%TEMP%\TEMP.MP$
SET HPF=
SET $F=?
ECHO [u[1A[s
SET PRE=A
GOTO MAPPIPE
:MAPCLEAN
ECHO ::NEXT>>%TEMP%\TEMP.MP$
CLS
CALL %0 KEYOFF # /G
PROMPT $P$G
ECHO [0m[33;44;1m
SET $F=
SET $SF=
SET $T=
SET $N=
SET $SN=
SET $DN=
SET $CN=
SET $LN=
SET $A$=
SET $B$=
SET $M=
SET PRE=
SET HPF=
CLS
CHOICE Save map to map file
IF NOT ERRORLEVEL 2 GOTO MAPSAVEPRE
:MAPEND |
|
[此贴子已经被作者于2004-1-12 7:15:56编辑过]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
6 楼』:
以下是个在命名行提示上画一只字符小狗的程序,原文来自网易北京站的DOS版。
http://fe4.bj.163.com/cgi/readsrh?b=DOS&t=38819&i=38819&al=5&n=0&l=40&back=2&st=0&kw=DOS%B5%C4%CD%BC%D0%CE
程序需ANSI支持。其中存在缺陷,解决的方法请查询原网址。
--------------------------------------
Quote: | @PROMPT { (\__ }
ECHO [1A[30C
@PROMPT { (\ `\__ }
ECHO [1A[30C
@PROMPT {(`, .------.,-' b $B }
ECHO [1A[30C
@PROMPT {`-/ ',__,-"` }
ECHO [1A[30C
@PROMPT { $B `; , $B }
ECHO [1A[30C
@PROMPT { \ ;.----/ ,/ }
ECHO [1A[30C
@PROMPT { ) // / ( ( \ }
ECHO [1A[30C
@PROMPT { \ \`.`\ \ \ \ }
ECHO [1A[30C
@PROMPT { `-` `" `-`" }
ECHO [1A[30C
@PORMPT $P$G |
|
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
7 楼』:
以下是一个获取PROMPT系统状态数据的程序,原文来自网易广州站的DOS版。
http://fe2.gz.163.com/cgi/readsrh?b=DOS&t=25501&i=25609&al=5&n=0&l=40&back=2&st=1&kw=willsort
运行时,加上存放数据的变量名和prompt对应变量名即可,如:
getvar curver $v
可以提取的系统状态数据有:
$T Current time
$D Current date
$P Current drive and path
$V System version number
$N Current drive
------------------------------------
::getvar.bat
@if [%1]==[invoke] prompt set %2=%3
@if [%1]==[invoke] goto end
@echo off
%comspec% /c %0 invoke %1 %2>tt.bat
call tt
:end ------------------------------------
2005.07.16 更新:
:: GetVar.bat - Get from 'PROMPT' text to environment variable
:: Will Sort - 10:29 2005-7-16 - CMD@XP/COMMAND@Win98/MSDOS6.22
@echo off
echo exit | %comspec% /k prompt set %1=%2$_:: > _GetVar.bat
call _GetVar.bat
for %%f in (_GetVar*.*) do del %%f [此贴子已经被作者于2004-1-12 0:58:40编辑过]
[ Last edited by willsort on 2005-10-29 at 12:36 ]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
8 楼』:
以下是一个定时器程序,原文来自网易广州站的DOS版。
http://fe2.gz.163.com/cgi/readsrh?b=DOS&t=13486&i=15375&al=5&n=40&l=40&back=2&st=1&kw=willsort
程序中的 CURRENT.BAT 可以更换为自己需要执行的内容。FIND 一句的时间可以根据自己的需要设定,也可用参数%1代替。还可以改为 TIME 改为 DATE 以完成的定期执行的功能。
------------------------------
Quote: | ::CURRENT.BAT
@echo off
echo Haha, it's the time to go!!
::TIMER.BAT
@echo off
:start
echo.|time|find "10:30:00">run.bat
choice /c:y /t:y,59 /n>nul
call run.bat
goto start |
|
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
9 楼』:
批处理编程的异类——网络(Network)
1、共享
1)删除win2k/xp系统默认共享
原文来自《批处理简明教程》
http://www.realhack.org/article/articleshow.asp?ArticleID=954
@echo preparing to delete all the default shares. when ready press any key.
@pause
@echo off
:Rem check parameters if null show usage.
if {%1}=={} goto :Usage
:Rem code start.
echo.
echo ------------------------------------------------------
echo.
echo Now deleting all the default shares.
echo.
net share %1$ /delete
net share %2$ /delete
net share %3$ /delete
net share %4$ /delete
net share %5$ /delete
net share %6$ /delete
net share %7$ /delete
net share %8$ /delete
net share %9$ /delete
net stop Server
net start Server
echo.
echo All the shares have been deleteed
echo.
echo ------------------------------------------------------
echo.
echo Now modify the registry to change the system default properties.
echo.
echo Now creating the registry file
echo Windows Registry Editor Version 5.00> c:\delshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]>> c:\delshare.reg
echo "AutoShareWks"=dword:00000000>> c:\delshare.reg
echo "AutoShareServer"=dword:00000000>> c:\delshare.reg
echo Nowing using the registry file to chang the system default properties.
regedit /s c:\delshare.reg
echo Deleting the temprotarily files.
del c:\delshare.reg
goto :END
:Usage
echo.
echo ------------------------------------------------------
echo.
echo ☆ A example for batch file ☆
echo ☆ [Use batch file to change the sysytem share properties.] ☆
echo.
echo Author:Ex4rch
echo Mail:Ex4rch@hotmail.com QQ:1672602
echo.
echo Error:Not enough parameters
echo.
echo ☆ Please enter the share disk you wanna delete ☆
echo.
echo For instance,to delete the default shares:
echo delshare c d e ipc admin print
echo.
echo If the disklable is not as C: D: E: ,Please chang it youself.
echo.
echo example:
echo If locak disklable are C: D: E: X: Y: Z: ,you should chang the command into :
echo delshare c d e x y z ipc admin print
echo.
echo *** you can delete nine shares once in a useing ***
echo.
echo ------------------------------------------------------
goto :EOF
:END
echo.
echo ------------------------------------------------------
echo.
echo OK,delshare.bat has deleted all the share you assigned.
echo.Any questions ,feel free to mail to Ex4rch@hotmail.com.
echo
echo.
echo ------------------------------------------------------
echo.
:EOF
echo end of the batch file 2)PING某个区段内的所有IP的程序
原文来自网易北京站的DOS版。
http://fe4.bj.163.com/cgi/readsrh?b=DOS&t=94897&i=96159&al=5&n=0&l=40&back=2&st=1&kw=willsort
在命令行输入 a.bat 0 1 2 3 4 5 6 7 8 9 ,就能显示某区段的所有 IP 地址 192.168.1.0 - 192.168.1.99 ,将其中的 echo 改成 ping 就行,其中的 choice 和 if 语句是等待用户判断是否继续,可以删除,但这样中断程序比较麻烦。
@echo off
:redo
if "%1" == "" goto end
for %%a in (0,1,2,3,4,5,6,7,8,9) do echo 192.168.1.%1%%a
choice continue
if errorlevel 2 goto end
shift
goto redo
:end [ Last edited by willsort on 2005-8-19 at 17:17 ]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
10 楼』:
以下是一个修改文件的更新日期的程序,原文来自网易北京站的DOS版。
http://fe4.bj.163.com/cgi/readsrh?b=DOS&t=85861&i=85878&al=5&n=0&l=40&back=2&st=1&kw=willsort
原文代码中有若干错误,下为修正版。
--------------------------------------
Quote: | @echo off
rem 保存系统时间
echo.|date>sysdate.bat
echo.|time>systime.bat
rem 修改系统时间为指定时间,日期为参数一,时间为参数二,文件名为参数三
date %1
time %2
rem 修改文件的时间
copy %3+,,>nul
rem 恢复系统时间
echo date %%4>current.bat
call sysdate
echo time %%3>current.bat
call systime
rem 程序执行完毕
echo Success.
del systime.bat
del sysdate.bat
del current.bat
echo on |
|
[此贴子已经被作者于2004-1-12 1:41:05编辑过]
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
11 楼』:
以下是一个文件遍历程序,原文来自网易广州站的DOS版。
http://fe2.gz.163.com/cgi/readsrh?b=DOS&t=21718&i=21882&al=5&n=0&l=40&back=2&st=1&kw=willsort
原文中用到了两个外部程序,VARSET 和 LMOD,可能在本站或者新DOS时代就有下载。
----------------------------------
Quote: | @echo off
rem ///////////////////搜索所有目录下的所有txt文件///////////////////
rem 找当前目录(根目录)的*.txt
for %%a in (*.txt) do type %%a
rem 以下为找当前目录(根目录)的所有子目录下的所有*.txt
set i=1
set j=1
set filenum=0
set dirnum=0
varset root=FULL of . >temp.bat
call temp.bat
varset rootdir=string(3) %root% >temp.bat
call temp.bat
dir /ad /b /s >temp.txt
varset dirnum=lines temp.txt >temp.bat
call temp.bat
:loop1
type %root%\temp.txt | %root%\LMOD /L%i% set curdir=[] >%root%\temp.bat
call %root%\temp.bat
varset curdir=string(3) %curdir% >%root%\temp.bat
call %root%\temp.bat
cd %curdir%
echo %curdir%
set j=1
:loop2
%root%\varset filenum=files *.txt >%root%\temp.bat
call %root%\temp.bat
if %filenum%==0 goto end2
dir *.txt /b | %root%\LMOD /L%j% set curfile=[] >%root%\temp.bat
call %root%\temp.bat
type %curfile%
if %j%==%filenum% goto end2
%root%\varset j=%j%+1 >%root%\temp.bat
call %root%\temp.bat
goto loop2
:end2
cd %rootdir%
if %i%==%dirnum% goto end1
%root%\varset i=%i%+1 >%root%\temp.bat
call %root%\temp.bat
goto loop1
:end1
del %root%\temp.bat
del %root%\temp.txt
set i=
set j=
set filenum=
set dirnum=
set root=
set rootdir=
set curdir=
set curfile= |
|
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
willsort
元老会员
Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第
12 楼』:
以下是一个接收键盘输入字符串的程序,原文来自本站教学室。
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=12&replyID=34149&ID=5283&skin=1
此文的关键技巧在于 FC 和 DEBUG 的巧妙结合使用。%TEMP%.\filename.ext 的用法也很有技巧性。%%?的用法也很新鲜。
---------------------------------------
Quote: | :: Get user input - includes error check
@echo off
echo e102'set %%1='> %temp%.\t1.dat
for %%? in (w q) do echo %%?>> %temp%.\t1.dat
:input
echo.
echo Type input:
FC con nul /lb1 /n |FIND "1:" > %temp%.\t2.bat
:: Error checking begins here
FIND "|" %temp%.\t2.bat > nul
if not errorlevel=1 goto error
FIND "=" %temp%.\t2.bat > nul
if not errorlevel=1 goto error
FIND " nul
if not errorlevel=1 goto error
FIND ">" %temp%.\t2.bat > nul
if not errorlevel=1 goto error
:: Error checking end
DEBUG %temp%.\t2.bat nul
call %temp%.\t2.bat 字符串
for %%? in (t1.dat t2.bat) do del %temp%.\%%?
echo 字符串=%字符串%
goto eof
:error
echo.
echo @PROMPT Invalid input. Invalid characters: $Q $L $G $B$_> %temp%.\t2.bat
%comspec% /c %temp%.\t2.bat |FIND ":"
goto input
:eof |
|
|
※ Batchinger 致 Bat Fans:请访问 [讨论]批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-1-12 00:00 |
|
|
pizigao
银牌会员
三生缘里笑红尘
积分 1063
发帖 292
注册 2003-3-9
状态 离线
|
『第
13 楼』:
ding
|
|
|
2004-1-13 00:00 |
|
|
pizigao
银牌会员
三生缘里笑红尘
积分 1063
发帖 292
注册 2003-3-9
状态 离线
|
『第
14 楼』:
willsort大哥,帮忙看看我的帖子
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=9&ID=8920
[此贴子已经被作者于2004-1-13 10:38:37编辑过]
|
|
|
2004-1-13 00:00 |
|
|
zww3008
初级用户
积分 197
发帖 21
注册 2004-1-9
状态 离线
|
『第
15 楼』:
这些都是很精典的批处理程序,很值得初学者学习参考体味,如果不希望贴子灌水的话,那就请版主置顶吧!不要让贴子沉了。
|
|
2004-1-14 00:00 |
|