436Views3Replies

Author Options:

Cool Batch applet Answered

Hey whats up the names Jason.

I am 13 and like to play with computers but not like Halo (although i am guilty of occasionally playing Halo) what interest me is computer logic and programming. So right now i am half-way decentish with Qbasic and consequently Visual Basic, but the language i am most fluent in is just plain old DOS scripting (batch files). My math teacher at the begging of the year my math teacher announced that once o twice a month we would have a pop quiz on square roots and squares of numbers 1-20. Now to say the least I am poor with memorization. So i tried flash cards and starin at a sheet with the squares and square roots on it. but I was pretty consistently getting 60s and 70s. Now being a pretty good student this upset me and my parents weren't exactly happy. So then i decided i would make a batch file to quiz me on this, my first one was on sqrts. writing this took forever so even still i made another for squares. These programs help me study immensely and i now get a perfect 100 every quiz.. i then started thinking that there must be a way to speed up the writing of a simaler quiz program. thats why i wrote this, and i know it is probably mediocre but i like it so be nice. (You can do whatever you want with this source code, and while not required i would prefer credit if you distribute a mod of this batch file.)

Here it is:
rem The purpose of this batch is to automate the process of making another batch that is used to quiz a person
@echo off
:start
cls
Echo Make a Quiz
echo.
echo.
rem this part creates a variabl that wil be used in creating the final batch file
echo enter the name of the file
echo .bat wil automaticaly be tacked ont to the end
Set /p filename=
echo.
echo.
rem This just creates a ariable that is the title of the the game to be created
echo now enter the title of the quiz
set/p title=
echo.
echo.
rem this is where the user inputs question part one and it becomes a variable
echo enter question part 1
Set /p quespt1=
echo.
echo.
rem this ask for the second part of the question
echo enter qeustion part 2
set /p quespt2=
echo.
echo.
Rem this declares some variables just for shorthand
set line=echo.
set ec=echo
Rem this creates a file that user named a while back and then fills it with some preliminary text
echo @echo off>%filename%.bat
echo :start>>%filename%.bat
echo cls>>%filename%.bat
echo echo %title%>>%filename%.bat
echo %line%>>%filename%.bat
echo %line%>>%filename%.bat
rem this part is called midstart because ideally later you can repeat this multiple times depending on how long your quiz is
set next=0
:midstart
set /a next=%next%+1
rem now we ask for the question of the question
echo now enter the question for the current question
Set /p questmp=
echo.
echo.
rem now we ask for the answer for that question
echo now the answer to that same question
Set /p anstmp=
rem More txt inserting (the %%answer%% is used so that in the batch file being created it shows up as %answer%)
echo echo %quespt1% %questmp% %quespt2%>>%filename%.bat
echo set /p answer=>>%filename%.bat
echo if %%answer%% == %anstmp% goto next%next%>>%filename%.bat
echo echo you lost>>%filename%.bat
echo pause>>%filename%.bat
echo goto start>>%filename%.bat
echo :next%next%>>%filename%.bat
echo echo You got it right>>%filename%.bat
echo %line%>>%filename%.bat
echo %line%>>%filename%.bat
echo you have asked %next% question(s)
echo.
echo.
echo If you would like to make a new question simply type "n" and press enter
echo However to input your last question type "l" and press enter
set /p endchoice=
if %endchoice% == l goto end
if %endchoice% == n goto restart
:restart
goto midstart
:end
set /a next=%next%+1
rem now we ask for the question of the question
echo now enter the question for the current question
Set /p questmp=
echo.
echo.
rem now we ask for the answer for that question
echo now the answer to that same question
Set /p anstmp=
rem More txt inserting (the %%answer%% is used so that in the batch file being created it shows up as %answer%)
echo echo %quespt1% %questmp% %quespt2%>>%filename%.bat
echo set /p answer=>>%filename%.bat
echo if %%answer%% == %anstmp% goto next%next%>>%filename%.bat
echo echo you lost>>%filename%.bat
echo pause>>%filename%.bat
echo goto start>>%filename%.bat
echo :next%next%>>%filename%.bat
echo echo you won>>%filename%.bat
echo echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>>%filename%.bat
echo %line%>>%filename%.bat
echo echo click to exit>>%filename%.bat
echo pause>>%filename%.bat
Echo And thats it your done
echo.
echo click to exit
set /p end=

And thats it so have fun and feel free to comment

3 Replies

user
NachoMahma (author)2008-03-19

. Lots of REMs. That's a good habit to have.

Select as Best AnswerUndo Best Answer

user
lemonshark10 (author)NachoMahma2008-03-19

Thanks at first i wasn't good about but when i took a step back i realized that in a matter of days i won't be able to make heads or tails of this complicated a program. So i went ahead and put in reminders for my self. next time i'll try to do that from the git go.

Select as Best AnswerUndo Best Answer

user
Goodhart (author)lemonshark102008-03-19

Documentation of any programs written, since they tend to get "out of hand in size", is a great habit to have, especially if you aspire in that direction. :-)

Select as Best AnswerUndo Best Answer