![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-13 00:24 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS学习入门 & 精彩文章 (教学室) » 请问怎样接受键盘输入的字符串?急急急!!! |
| 可打印版本 865 / 10 |
| 第1楼 lifeng5115 | 发表于 2003-08-08 00:00 |
| 中级用户 发帖 39 积分 283 | |
|
请问怎样接受键盘输入的字符串?急急急!!! 我想让DOS提示叫我输入字符串:
我输入字符后回车,所输入的字符就会保存在一个文件中。 like this 屏幕显示 please in put string: 我输入 ddddd 之后,我就可以在某个。txt文件中得到ddddd 然后在确认输入: please put string again 如果这是输入和第一次不一样,就报错。 谢谢,恳请大家帮忙 |
|
| 第2楼 cn_archer | 发表于 2003-08-08 00:00 |
| 元老会员 发帖 991 积分 2,903 来自 福建省 | |
|
我想这个要通过编程来解决了……
大体的思路是这样,先设置一个循环,然后在屏幕上输出 “Please input string:”,把用户输入的字串保存在变量中,然后再在屏幕上输出“Please put string again:”要求用户重新输入一次,将该数据和前面那个变量相比较,如果一致则保存到某个.txt文件中,如果不一致则报错。 只是一个简要的思路,用编程语言应该能很轻松的实现。 |
|
| 第3楼 lifeng5115 | 发表于 2003-08-08 00:00 |
| 中级用户 发帖 39 积分 283 | |
|
关键是怎么把输入在屏幕上的字符存在变量里 关键是怎么把输入在屏幕上的字符存在变量里!!!!!!
要怎么set? 请给出程序好吗? |
|
| 第4楼 cn_archer | 发表于 2003-08-08 00:00 |
| 元老会员 发帖 991 积分 2,903 来自 福建省 | |
|
呵呵,这一步很简单啊。
C语言或者其它的编程语言我记得不太清楚了,用数据库语言来试着描述一下吧。 store space(6) to x //这个6主要指他占多少位,可以自行设定 @10,10 say“Please input string:” get x picture "XXXXXX" read 这样就可以了,好象在C语言里input等也都可以实现啊,不过具体的命令我记不太清了,所以只能讲个大略,:) |
|
| 第5楼 hzy | 发表于 2003-08-08 00:00 |
| 高级用户 发帖 135 积分 578 | |
以下是引用lifeng5115在2003-8-8 12:29:47的发言: 用get加s 如: get s "please in put string:" 这样,下一行命令中的 %get% 就是你刚才输入的字符串了! |
|
| 第6楼 lifeng5115 | 发表于 2003-08-11 00:00 |
| 中级用户 发帖 39 积分 283 | |
|
请问,get在批处理文件中可以使用吗???
我所说的接受输入是指在DOS下 |
|
| 第7楼 jeffyy | 发表于 2003-08-12 00:00 |
| 初级用户 发帖 23 积分 219 | |
|
好难!
看来我要多学学啊! |
|
| 第8楼 Roy | 发表于 2003-08-12 00:00 |
| 管理员 发帖 1,633 积分 4,869 | |
以下是引用lifeng5115在2003-8-8 11:16:52的发言: :: Get user input - includes error check @echo off set secondpass= echo e100'set input='>%temp%.\temp.dat echo w>>%temp%.\temp.dat echo q>>%temp%.\temp.dat :input echo. if not %secondpass%.==1. echo Type in input if %secondpass%.==1. echo Type in input again echo.>%temp%.\temp.bat FC con nul /lb1 /n |FIND.exe "1:" >> %temp%.\temp.bat :: Error checking begins here FIND "|" %temp%.\temp.bat > nul if not errorlevel=1 goto error FIND "=" %temp%.\temp.bat > nul if not errorlevel=1 goto error FIND " nul if not errorlevel=1 goto error FIND ">" %temp%.\temp.bat > nul if not errorlevel=1 goto error :: Error checking end DEBUG %temp%.\temp.bat nul call %temp%.\temp.bat if exist %temp%.\temp.?at del %temp%.\temp.?at rem echo INPUT=%INPUT% goto EOF :error echo. echo @PROMPT Error - invalid characters: $Q $L $G $B> %temp%.\temp.bat %comspec% /c %temp%.\temp.bat |FIND.exe "Error:" goto input :eof if not %secondpass%.=1. echo %INPUT%>1st.txt if not %secondpass%.=1. set secondpass=1 if %secondpass%.=1. type 1st.txt|find "%INPUT%">NUL if errorlevel 1 goto notmatch goto end :notmatch ECHO The input does not match! goto end :end |
|
| 第9楼 hzy | 发表于 2003-08-13 00:00 |
| 高级用户 发帖 135 积分 578 | |
|
不用这么复杂吧?
|
|
| 第10楼 lifeng5115 | 发表于 2003-08-13 00:00 |
| 中级用户 发帖 39 积分 283 | |
|
太复杂了^_^
我只要简单一点的。 |
|
| 第11楼 jhhjwok | 发表于 2003-10-16 00:00 |
| 中级用户 发帖 52 积分 278 | |
|
用INPUT可以了!
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |