| 
 | 
 
[这个贴子最后由gotomsdos在 2005/04/29 08:23pm 第 4 次编辑] 
 
终于成功地运用了DOS的变量嵌套!从而解决了通过"递减和递增"简化了我刚写的WBAT的简易DOS浏览器!!! 
 
"递减和递增"简化是最简化的...(写出来的变量只用了区区三个!!,小小WBAT和GET!就实现了浏览几乎无限制的深层目录及其文件!,也可顺带编辑文本文件,执行可执行程序,批处理程序,也可随时把用户的目录赋给一个变量....麻雀虽小,五脏具全..并且支持带间隔的长名目录和中文!) 共大家参考,尤其是学习WBAT和GET的...相信会有很大帮助的!.. 
 
很满意! 再次感谢WILLSORT! 
 
简化了的WBAT如下:(DOS71下测试成功!) 要求: 加载DOSLFN,正确加载TW 
@echo off 
goto begin 
:dirbars "上一级—→"[x] 
[退  出] 
[预  选] 
[看文件] 
[看目录] 
: 
:filebars "   上一级—→"[x] 
[退  出] 
[运行批处理文件] 
[运行可执行文件] 
[编辑文本文件] 
[查看文件信息] 
: 
: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.nst goto init1 
find /i "%wbat%" notready.nst>nul 
if errorlevel 1 goto init1 
wbat box "您还没有在%wbat%盘放入盘片!" 重试 
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 @echo off>nestvar.bat 
echo dir "%%dir%get%%%" /b/ad/one>>nestvar.bat 
command /c call nestvar>put.nst 
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 @echo off>nestvar.bat 
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 @echo off>nestvar.bat 
echo dir "%%dir%get%%%" /b/a-d/one>>nestvar.bat 
command /c call nestvar>put.nst 
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 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 @echo off>nestvar.bat 
echo dir "%%dir%get%%%\%wbat%" /a>>nestvar.bat 
command /c call nestvar>putfile.nst 
wbat list putfile.nst 
goto fileb 
:text 
echo @echo off>nestvar.bat 
echo edit "%%dir%get%%%\%wbat%">>nestvar.bat 
call nestvar 
goto fileb 
:exec-bat 
echo @echo off>nestvar.bat 
echo "%%dir%get%%%\%wbat%">>nestvar.bat 
call nestvar 
goto fileb 
:pick 
echo @echo off>nestvar.bat 
echo set gamesave=%%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 
 |   
 
 
 
 |