![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-10-31 16:24 |
共 47,815 主题排行 / 349,930 发帖 / 今日 0 篇 / 48,290 会员排行 |
| DOS开发编程 & 发展交流 (开发室) » 这两天刚刚做了个简易的DOS浏览器,谁能简化它?? |
| 可打印版本 1,222 / 5 |
| 第1楼 GOTOmsdos | 发表于 2005-04-27 00:00 |
| 铂金会员 发帖 1,827 积分 5,154 | |
|
这两天刚刚做了个简易的DOS浏览器,谁能简化它?? 用WBAT和GET作了简易的DOS浏览器,目录和文件越深,DIR后面的数字就越大.
本着数字递增和递减的原理想了很多办法简化它,但由于DOS不能嵌套变量, (就是不能引用%%1%,%%变量%%), 所以绞尽脑汁还是不行.. 谁能有办法? ..... 批处理如下: @echo off goto begin :dirbars "上一级—→" : :filebars " 上一级—→" : :begin if exist drive.txt copy drive.txt dir0.txt if exist dir0.txt goto dir0 wbat box "没有驱动器!" 退出 goto end :dir0 call w.bat list dir0.txt if errorlevel 100 goto end :putdisk if not exist notready.txt goto dirbar1 find /i "%wbat%" notready.txt if errorlevel 1 goto dirbar1 wbat box "您还没有在%wbat%盘放入盘片!" 重试 call diskfind goto putdisk :dirbar1 set dir1=%wbat% :dirbars1 wbat box @%0:dirbars if errorlevel 100 goto dir0 if errorlevel 4 goto dir1 if errorlevel 3 goto flist1 if errorlevel 2 goto pikdir1 goto end :dir1 dir "%dir1%\" /b/ad/one>dir1.txt get f dir1.txt if not "%get%"=="0" goto dir1y wbat box "没有子目录!" 上一级,退出 if errorlevel 2 goto end goto dirbars1 :dir1y call w.bat list dir1.txt if errorlevel 100 goto dirbars1 set dir2=%dir1%\%wbat% :dirbars2 wbat box @%0:dirbars if errorlevel 100 goto dir1y if errorlevel 4 goto dir2 if errorlevel 3 goto flist2 if errorlevel 2 goto pikdir2 goto end :flist1 dir "%dir1%" /b/a-d/one>flist1.txt get f flist1.txt if not "%get%"=="0" goto flist1y wbat box "没有文件!" 上一级,退出 if errorlevel 2 goto end goto dirbars1 :flist1y call w.bat list flist1.txt if errorlevel 100 goto dirbars1 :fbars1 wbat box @%0:filebars if errorlevel 100 goto flist1y if errorlevel 5 goto info1 if errorlevel 4 goto text1 if errorlevel 3 goto exec1 if errorlevel 2 goto bat1 goto end :info1 dir "%dir1%\%wbat%" /a>info1.txt wbat list info1.txt goto fbars1 :text1 edit "%dir1%\%wbat%" goto fbars1 :exec1 "%dir1%\%wbat%" goto fbars1 :bat1 call "%dir1%\%wbat%" goto fbars1 :pikdir1 set gamesave=%dir1% goto end :dir2 dir "%dir2%" /b/ad/one>dir2.txt get f dir2.txt if not "%get%"=="0" goto dir2y wbat box "没有子目录!" 上一级,退出 if errorlevel 2 goto end goto dirbars2 :dir2y call w.bat list dir2.txt if errorlevel 100 goto dirbars2 set dir3=%dir2%\%wbat% :dirbars3 wbat box @%0:dirbars if errorlevel 100 goto dir2y if errorlevel 4 goto dir3 if errorlevel 3 goto flist3 if errorlevel 2 goto pikdir3 goto end :flist2 dir "%dir2%" /b/a-d/one>flist2.txt get f flist2.txt if not "%get%"=="0" goto flist2y wbat box "没有文件!" 上一级,退出 if errorlevel 2 goto end goto dirbars2 :flist2y call w.bat list flist2.txt if errorlevel 100 goto dirbars2 :fbars2 wbat box @%0:filebars if errorlevel 100 goto flist2y if errorlevel 5 goto info2 if errorlevel 4 goto text2 if errorlevel 3 goto exec2 if errorlevel 2 goto bat2 goto end :info2 dir "%dir2%\%wbat%" /a>info2.txt wbat list info2.txt goto fbars2 :text2 edit "%dir2%\%wbat%" goto fbars2 :exec2 "%dir2%\%wbat%" goto fbars2 :bat2 call "%dir2%\%wbat%" goto fbars2 :pikdir2 set gamesave=%dir2% goto end :dir3 dir "%dir3%" /b/ad/one>dir3.txt get f dir3.txt if not "%get%"=="0" goto dir3y wbat box "没有子目录!" 上一级,退出 if errorlevel 2 goto end goto dirbars3 :dir3y call w.bat list dir3.txt if errorlevel 100 goto dirbars3 set dir4=%dir3%\%wbat% :dirbars4 wbat box @%0:dirbars if errorlevel 100 goto dir3y if errorlevel 4 goto dir4 if errorlevel 3 goto flist4 if errorlevel 2 goto pikdir4 goto end :flist3 dir "%dir3%" /b/a-d/one>flist3.txt get f flist3.txt if not "%get%"=="0" goto flist3y wbat box "没有文件!" 上一级,退出 if errorlevel 2 goto end goto dirbars3 :flist3y call w.bat list flist3.txt if errorlevel 100 goto dirbars3 :fbars3 wbat box @%0:filebars if errorlevel 100 goto flist3y if errorlevel 5 goto info3 if errorlevel 4 goto text3 if errorlevel 3 goto exec3 if errorlevel 2 goto bat3 goto end :info3 dir "%dir3%\%wbat%" /a>info3.txt wbat list info3.txt goto fbars3 :text3 edit "%dir3%\%wbat%" goto fbars3 :exec3 "%dir3%\%wbat%" goto fbars3 :bat3 call "%dir3%\%wbat%" goto fbars3 :pikdir3 set gamesave=%dir3% goto end ... ... :end |
|
| 第2楼 GOTOmsdos | 发表于 2005-04-27 00:00 |
| 铂金会员 发帖 1,827 积分 5,154 | |
|
看了WILLSORT帖子,感觉好象能解决了!正在改。。
|
|
| 第3楼 9zhmke | 发表于 2005-05-12 00:00 |
| 中级用户 发帖 99 积分 355 | |
|
为什么不用循环变量呢?
|
|
| 第4楼 GOTOmsdos | 发表于 2005-05-12 00:00 |
| 铂金会员 发帖 1,827 积分 5,154 | |
|
已经用GET简化完成! 如下:用递增和递减实现前进和返回的简易DOS浏览器,<感谢willsort!,是他帮我解决了DOS的嵌套变量,才能把它精简>小到只有3KB,但可查看无限制深度的目录@echo off
goto begin:dirbars "上一级—→" ::filebars " 上一级—→" ::begin if exist drive.txt goto drive wbat cls ! box "没有驱动器!" 退出 goto end:drive call w.bat list drive.txt if errorlevel 100 goto end:putdisk if not exist notready.txt goto init1 find /i "%wbat%" notready.txt>nul if errorlevel 1 goto init1 wbat box "您还没有在%wbat%盘放入盘片!" 重试,返回 if errorlevel 2 goto end call diskfind goto putdisk:init1 set get=1 set dir%get%=%wbat%:dirb wbat box @%0:dirbars if errorlevel 100 goto sub1 if errorlevel 4 goto dir if errorlevel 3 goto file if errorlevel 2 goto pick goto end:dir if %get%==0 goto drive if %get%==1 goto rootdir echo dir "%%dir%get%%%" /b/ad/one %%"%%>%%"%% put.nst>nestvar.bat call nestvar goto subdir:rootdir dir %dir1%\ /b/ad/one>put.nst:subdir get f put.nst /vfsize>nul if not "%fsize%"=="0" goto havedir wbat box "没有子目录!" 上一级,退出 if errorlevel 2 goto end goto dirb:havedir call w.bat list put.nst if errorlevel 100 goto dirb get r "+" %get% /w1 /vgetadd1>nul echo set dir%getadd1%=%%dir%get%%%\%wbat%>nestvar.bat call nestvar wbat box @%0:dirbars if errorlevel 100 goto havedir if errorlevel 4 goto diradd1 if errorlevel 3 goto fileadd1 if errorlevel 2 goto pickadd1 goto end:file if %get%==1 goto rootfile echo dir "%%dir%get%%%" /b/a-d/one %%"%%>%%"%% put.nst>nestvar.bat call nestvar goto subfile:rootfile dir %dir1%\ /b/a-d/one>put.nst:subfile get f put.nst /vfsize>nul if not "%fsize%"=="0" goto havefile wbat box "没有文件!" 上一级,退出 if errorlevel 2 goto end goto dirb:havefile call w.bat list put.nst if errorlevel 100 goto dirb:fileb wbat cls ! text 24,2 (red on blue) @continue.bat:studio wbat box @%0:filebars if errorlevel 100 goto havefile if errorlevel 5 goto info if errorlevel 4 goto text if errorlevel 3 goto exec-bat if errorlevel 2 goto exec-bat goto end:info echo dir "%%dir%get%%%\%wbat%" /a %%"%%>%%"%% putfile.nst>nestvar.bat call nestvar wbat list putfile.nst goto fileb:text echo edit "%%dir%get%%%\%wbat%">nestvar.bat call nestvar goto fileb:exec-bat echo "%%dir%get%%%\%wbat%">nestvar.bat wbat cls call nestvar goto fileb:pick echo set %1=%%dir%get%%%>nestvar.bat call nestvar goto end:sub1 get r "-" %get% /w1>nul goto dir:diradd1 get r "+" %get% /w1>nul goto dir:fileadd1 get r "+" %get% /w1>nul goto file:pickadd1 get r "+" %get% /w1>nul goto pick:end for %%a in (nestvar.bat put.nst putfile.nst) do if exist %%a del %%a |
|
| 第5楼 9zhmke | 发表于 2005-05-13 00:00 |
| 中级用户 发帖 99 积分 355 | |
|
还可以精简,类似的几偿东西都可以精简,比如最后面的get r "+" %....这段,可以把后面的goto xxx 的XXX改成变量。一个句子就可以完成。
|
|
| 第6楼 GOTOmsdos | 发表于 2005-05-13 00:00 |
| 铂金会员 发帖 1,827 积分 5,154 | |
|
后面的3句GET 是一样,但GOTO到不同的地方,就这3句,你再用几个变量,反而烦琐了!
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |