| 1. |
Solve : CHOICE vs. SET command? |
|
Answer» I want to use BATCH files to allow a Yes/no prompt e.g. "Do you wish to continue? (Y/N)" but I am having trouble. I saw the CHOICE command, and tried it, but since I am using Version 5.1, I can't use it. This site says the SET command can be used the same way, but I can't figure out how to use the SET command in the same way. It doesn't seem to fit what the CHOICE command is capable of. And I don't know how to write code like this: I'm not a genius PROGRAMMER! Can anyone please tell me how to use SET this way?Code: [Select] I apologize, but I haven't used DOS for 12 years. Quote My lack of understanding just might have something to do with the fact I'm 14 Huh?What I just said is that I am 14 years old. I'm young, and didn't use more that a little of DOS growing up, since Windows came out. At least, that's when I GOT it. Actually, I had one more question. In that example, what if someone types 5? That's not a choice, so it terminates the .BAT file. How do I get it to return to the beginning?That's one of the problems with set. Choice only allowed you to enter a defined response and otherwise beeped if you did not. Code: [Select] @echo off :start set /p var=Enter Option: if %var%==1 goto 1 if %var%==2 goto 2 if %var%==3 goto 3 if %var%==4 goto 4 goto start :1 echo 1 goto end :2 echo 2 goto end :3 echo 3 goto end :4 echo 4 :end Not nearly a clean as CHOICE, but it gets the JOB done. Thank you. I suppose that's it. I'll get back to learning some more advanced functions of DOS. Have a good day, Sidewinder. |
|