![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-13 03:04 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » Urgent: how do I accept a string entered from the keyboard?!!! |
| Printable Version 868 / 10 |
| Floor1 lifeng5115 | Posted 2003-08-08 00:00 |
| 中级用户 Posts 39 Credits 283 | |
|
I want DOS to prompt me to input a string:
After I enter characters and press Enter, the characters entered will be saved in a file. like this the screen displays please in put string: I enter ddddd After that, I can get ddddd in some .txt file Then ask for confirmation input: please put string again If this input is different from the first one, then report an error. Thanks, I sincerely ask everyone to help |
|
| Floor2 cn_archer | Posted 2003-08-08 00:00 |
| 元老会员 Posts 991 Credits 2,903 From 福建省 | |
|
I think this has to be solved through programming...
The general idea is like this: first set up a loop, then output “Please input string:” on the screen, save the string entered by the user in a variable, then output “Please put string again:” on the screen and ask the user to enter it again, compare that data with the previous variable, and if they are the same then save it to some .txt file; if they are different then report an error. This is only a brief idea. It should be very easy to do with a programming language. |
|
| Floor3 lifeng5115 | Posted 2003-08-08 00:00 |
| 中级用户 Posts 39 Credits 283 | |
|
The key is how to store the characters entered on the screen into a variable!!!!!!!!
How do I set it? Could you give the program? |
|
| Floor4 cn_archer | Posted 2003-08-08 00:00 |
| 元老会员 Posts 991 Credits 2,903 From 福建省 | |
|
Hehe, this step is very simple.
I don't remember C or other programming languages too clearly now, so let me try describing it using database language. store space(6) to x //this 6 mainly refers to how many positions it occupies; you can set it yourself @10,10 say“Please input string:” get x picture "XXXXXX" read That will do it. I think things like input in C can also achieve this, but I don't remember the exact commands too clearly, so I can only give a rough idea, :) |
|
| Floor5 hzy | Posted 2003-08-08 00:00 |
| 高级用户 Posts 135 Credits 578 | |
The following is a quote from lifeng5115 at 2003-8-8 12:29:47: Use get plus s For example: get s "please in put string:" This way, %get% in the next line of command is the string you just entered! |
|
| Floor6 lifeng5115 | Posted 2003-08-11 00:00 |
| 中级用户 Posts 39 Credits 283 | |
|
I'd like to ask, can get be used in a batch file???
By accepting input, I mean under DOS |
|
| Floor7 jeffyy | Posted 2003-08-12 00:00 |
| 初级用户 Posts 23 Credits 219 | |
|
So hard!
Looks like I need to study more! |
|
| Floor8 Roy | Posted 2003-08-12 00:00 |
| 管理员 Posts 1,633 Credits 4,869 | |
The following is a quote from lifeng5115 at 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 |
|
| Floor9 hzy | Posted 2003-08-13 00:00 |
| 高级用户 Posts 135 Credits 578 | |
|
No need to make it this complicated, right?
|
|
| Floor10 lifeng5115 | Posted 2003-08-13 00:00 |
| 中级用户 Posts 39 Credits 283 | |
|
Too complicated ^_^
I just want something a bit simpler. |
|
| Floor11 jhhjwok | Posted 2003-10-16 00:00 |
| 中级用户 Posts 52 Credits 278 | |
|
Just use INPUT!
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |