![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-13 17:23 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS学习入门 & 精彩文章 (教学室) » 请教一个批处理[求助] |
| 可打印版本 1,603 / 5 |
| 第1楼 single_arche | 发表于 2004-05-17 00:00 |
| 初级用户 发帖 5 积分 123 | |
|
请教一个批处理[求助] 请教高手们:
如果我要求输入五个字符串 然后将这五个字符串附给变量 并将其打印出来.可以实现吗? 因为这台机子只有DOS和UCDOS其它任何可编程的东西都没有. |
|
| 第2楼 zhri | 发表于 2004-05-17 00:00 |
| 高级用户 发帖 153 积分 665 | |
|
办法倒是有。
不过,用.bat很麻烦。(.bat里是没有所谓的变量定义的,只能用想办法把你输入的东西保存成一个文本文件,用点欺骗的手法,copy con和crtl+z。最后type xx >prn......,并且把刚才的文件删掉......当然,如果直接接受字符并打印的话,就不需要中间文件了......比如:copy con prn......总之,因为.bat没有变量,所以非常麻烦......) DOS有Qbasic的。这个不是很简单吗?(c:\dos\qbasic.exe) |
|
| 第3楼 single_arche | 发表于 2004-05-17 00:00 |
| 初级用户 发帖 5 积分 123 | |
|
thank
|
|
| 第4楼 SagInvoker | 发表于 2004-05-21 00:00 |
| 初级用户 发帖 38 积分 257 | |
|
批处理是用来编程的吗??
就算没有QBIASC,也可以用DEBUG嘛,总之用批处理就算编出来了效果也会很不尽入人意的,我这里写了一个批处理,不是用楼上那个的欺骗手法,但是效果确实不怎么样,你看看吧 @echo off set vp=var echo Welcome to my test echo if you want to terminate input,write ! :loop set tempvar= set vp=%vp%# :begin choice /c:abcdefghijklmnopqrstuvwxyz! /n if errorlevel 27 goto end: if errorlevel 26 goto z: if errorlevel 25 goto y: if errorlevel 24 goto x: if errorlevel 23 goto w: if errorlevel 22 goto v: if errorlevel 21 goto u: if errorlevel 20 goto t: if errorlevel 19 goto s: if errorlevel 18 goto r: if errorlevel 17 goto q: if errorlevel 16 goto p: if errorlevel 15 goto o: if errorlevel 14 goto n: if errorlevel 13 goto m: if errorlevel 12 goto l: if errorlevel 11 goto k: if errorlevel 10 goto j: if errorlevel 9 goto i: if errorlevel 8 goto h: if errorlevel 7 goto g: if errorlevel 6 goto f: if errorlevel 5 goto e: if errorlevel 4 goto d: if errorlevel 3 goto c: if errorlevel 2 goto b: if errorlevel 1 goto a: :a set tempvar=%tempvar%a goto begin :b set tempvar=%tempvar%b goto begin :c set tempvar=%tempvar%c goto begin :d set tempvar=%tempvar%d goto begin :e set tempvar=%tempvar%e goto begin :f set tempvar=%tempvar%f goto begin :g set tempvar=%tempvar%g :h set tempvar=%tempvar%h goto begin :i set tempvar=%tempvar%i goto begin :j set tempvar=%tempvar%j goto begin :k set tempvar=%tempvar%k goto begin :l set tempvar=%tempvar%l goto begin :m set tempvar=%tempvar%m goto begin :n set tempvar=%tempvar%n goto begin :o set tempvar=%tempvar%o goto begin :p set tempvar=%tempvar%p goto begin :q set tempvar=%tempvar%q goto begin :r set tempvar=%tempvar%r goto begin :s set tempvar=%tempvar%s goto begin :t set tempvar=%tempvar%t goto begin :u set tempvar=%tempvar%u goto begin :v set tempvar=%tempvar%v goto begin :w set tempvar=%tempvar%w goto begin :x set tempvar=%tempvar%x goto begin :y set tempvar=%tempvar%y :z set tempvar=%tempvar%z goto begin :end set %vp%=%tempvar% if %vp%==var##### goto ok goto loop :ok echo what you input is: echo %var#% echo %var##% echo %var###% echo %var####% echo %var#####% :finish 附:其实我也很想知道怎么在一个没有编程环境的地方写点东西,所以很想学汇编,不过一个人看来看去总觉得很难,如果谁有兴趣学汇编,或者懂汇编,可以交个朋友吗,也指导一下吧,先谢了 我的QQ:105695504,Email-geniuscjy2163.com (加我QQ的时候随便打点什么话都行,我那个身份验证是防哪些滥发广告的) |
|
| 第5楼 SagInvoker | 发表于 2004-05-21 00:00 |
| 初级用户 发帖 38 积分 257 | |
|
更正一下,CHOICE后面应该重定向到NUL,打漏了,请原谅.
|
|
| 第6楼 SagInvoker | 发表于 2004-05-21 00:00 |
| 初级用户 发帖 38 积分 257 | |
|
不好意思,刚才看了这篇本站帖子
http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=12&ID=8905 真的觉得自己太菜了,简直象个白痴一样,收回上面所有发言 附上修改以后的代码,望请指点 @echo off if not == goto step2 echo e102''''''''set %%1=''''''''>cmd.dat echo w>>cmd.dat echo q>>cmd.dat echo Welcome to my test echo if you want to terminate input string,write ^Z for %%x in (var1 var2 var3 var4 var5) do call %0 %%x goto output :step2 echo please test your string: fc con nul /lb1 /n|FIND "1:" >%1.bat debug %1.bat nul call %1.bat %1 goto end :output echo yes,you''''''''ve write five string now ,they are: echo the firstis: %var1% echo the second: %var2% echo the third: %var3% echo the forth: %var4% echo the fifth: %var5% for %%x in (var1 var2 var3 var4 var5) do del %%x.bat :end |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |