More Convenient code

Blitz3D Forums/Blitz3D Beginners Area/More Convenient code

Oiduts Studios(Posted 2008) [#1]
I made a practice test for my vocabulary for school. I have to remember the exact definitions. I have my code but it has many bugs. Every week i get new words to add to the list. Is there an easier way of typing this code? Also is there a better way to grade the test? Any help will be great since i will be using this code all year.

Graphics 1440,900
.main

;Words
w1$="Fore
w2$="De
w3$="Re
w4$="Mis
w5$="Un
w6$="Trans
w7$="Ambi
w8$="Poly
w9$="Auto
w10$="Super
w11$="Abhor"
w12$="Bi"
w13$="Syn"
w14$="For"
w15$="Com"

;Questions
d1$="earlier,before in time,place or order"
d2$="down,away,reversing the action of"
d3$="again,back"
d4$="bad,wrong"
d5$="not"
d6$="across,through,beyond,into another condition or place"
d7$="both,around"
d8$="many,more than one"
d9$="of oneself,by itself,same"
d10$="above,higher than"
d11$="from,away from,off"
d12$="twice,divide in two parts"
d13$="with,together,jointly"
d14$="away,opposite,completely"
d15$="with,together,all together"

While Not KeyHit(1)

font1=LoadFont("Earwig Factory",72,False,True,False)
font2=LoadFont("Rockwell",32,False,True,False)

SetFont font2

Cls:Locate 0,0

;Test

Print ""
Print "Type in exact definition for each root"
Text 500,100,"All definitions must be exactly correct!"
q1$=Input$("1. "+w1$+" : ")
q2$=Input$("2. "+w2$+" : ")
q3$=Input$("3. "+w3$+" : ")
q4$=Input$("4. "+w4$+" : ")
q5$=Input$("5. "+w5$+" : ")
q6$=Input$("6. "+w6$+" : ")
q7$=Input$("7. "+w7$+" : ")
q8$=Input$("8. "+w8$+" : ")
q9$=Input$("9. "+w9$+" : ")
q10$=Input$("10. "+w10$+" : ")
q11$=Input$("11. "+w11$+" : ")
q12$=Input$("12. "+w12$+" : ")
q13$=Input$("13. "+w13$+" : ")
q14$=Input$("14. "+w14$+" : ")
q15$=Input$("15. "+w15$+" : ")

;Binary effect

For x=1 To 100
Color 0,Rnd(255),0
a$=Rnd(1000000)
a1$=Rnd(1000000)
b$=Bin$(a$)
b1$=Bin$(a1$)
Print ""+b$
Print ""+b1$
Next

;Grading

If q1$="cheat":c#=6.6*15:Else:c#=c#:EndIf

If q1$=d1$:q1$="RIGHT":c#=c#+6.6:Else:c#=c#:q1$="WRONG!":EndIf

If q2$=d2$:q2$="RIGHT":c#=c#+6.6:Else:c#=c#:q2$="WRONG!":EndIf

If q3$=d3$:q3$="RIGHT":c#=c#+6.6:Else:c#=c#:q3$="WRONG!":EndIf

If q4$=d4$:q4$="RIGHT":c#=c#+6.6:Else:c#=c#:q4$="WRONG!":EndIf

If q5$=d5$:q5$="RIGHT":c#=c#+6.6:Else:c#=c#:q5$="WRONG!":EndIf

If q6$=d6$:q6$="RIGHT":c#=c#+6.6:Else:c#=c#:q6$="WRONG!":EndIf

If q7$=d7$:q7$="RIGHT":c#=c#+6.6:Else:c#=c#:q7$="WRONG!":EndIf

If q8$=d8$:q8$="RIGHT":c#=c#+6.6:Else:c#=c#:q8$="WRONG!":EndIf

If q9$=d9$:q9$="RIGHT":c#=c#+6.6:Else:c#=c#:q9$="WRONG!":EndIf

If q10$=d10$:q10$="RIGHT":c#=c#+6.6:Else:c#=c#:q10$="WRONG!":EndIf

If q11$=d11$:q11$="RIGHT":c#=c#+6.6:Else:c#=c#:q11$="WRONG!":EndIf

If q12$=d12$:q12$="RIGHT":c#=c#+6.6:Else:c#=c#:q12$="WRONG!":EndIf

If q13$=d13$:q13$="RIGHT":c#=c#+6.6:Else:c#=c#:q13$="WRONG!":EndIf

If q14$=d14$:q14$="RIGHT":c#=c#+6.6:Else:c#=c#:q14$="WRONG!":EndIf

If q15$=d15$:q15$="RIGHT":c#=c#+6.6:Else:c#=c#:q15$="WRONG!":EndIf

;Grading Scale

If c#<=100 Then grade$="Stop taking this test" 
If c#=<94 Then grade$="Aced"
If c#<90 Then grade$="Almost"
If c#<80 Then grade$="Why settle for this"
If c#<70 Then grade$="D for dummy"
If c#<60 Then grade$="FAIL"
If c#<50 Then grade$="Retard"
If c#<40 Then grade$="Loser
If c#<30 Then grade$="Stupid"
If c#<20 Then grade$="Why?"
If c#<=10 Then grade$="...
If c#<=0 Then grade$="Complete Idiot"
Color 255,255,255
SetFont font1

;Recieving Grade

Text 500,500,"Score : "+c#+"%"
Text 500,300,""+grade$+"

FreeFont font1
SetFont font2
Text 500,600,"To take test again press any key"
Text 500,700,"To exit test press the escape key"
WaitKey()
Cls
Text 500,600,"To take test again press any key"
Text 500,700,"To exit test press the escape key"

;What you missed
Locate 0,0
Print "1. "+w1$+" : "+q1$
Print "2. "+w2$+" : "+q2$
Print "3. "+w3$+" : "+q3$
Print "4. "+w4$+" : "+q4$
Print "5. "+w5$+" : "+q5$
Print "6. "+w6$+" : "+q6$
Print "7. "+w7$+" : "+q7$
Print "8. "+w8$+" : "+q8$
Print "9. "+w9$+" : "+q9$
Print "10. "+w10$+" : "+q10$
Print "11. "+w11$+" : "+q11$
Print "12. "+w12$+" : "+q12$
Print "13. "+w13$+" : "+q13$
Print "14. "+w14$+" : "+q14$
Print "15. "+w15$+" : "+q15$

WaitKey()
Wend
End



Stevie G(Posted 2008) [#2]
Use arrays, data statements etc.....

For example

Const Questions = 5

Dim Q$( Questions-1 )
dim W$( Questions-1 )

Restore QnA

For l = 0 To Questions-1
	Read Q$( l )
	Read W$( l )
Next

.QnA
Data "earlier,before in time,place or order", "not"
Data "down,away,reversing the action of", "Fore"
Data "again,back", "Re"
Data "bad,wrong", "Mis"
Data "not","Un"



They refer to the array to get the specific question and check it's answer ...

Score = 0
For l = 0 To Questions - 1
	Answer$=Input$( Str$(l+1)+". "+Q(l)+" : ")
	If Answer$ = W$(l) 
		Score = Score + 1
	EndIf
Next


I think you'll get the idea

Stevie


SLotman(Posted 2008) [#3]
Even better, read from a text file, this way, you won't need to recompile the program everytime you add or remove some word/meaning.


Stevie G(Posted 2008) [#4]

Even better, read from a text file, this way, you won't need to recompile the program everytime you add or remove some word/meaning.



Yes, using a text file would be a more elegant solution but judging by his code I think simplicity is key here.

Why would anyone care about having to recompile such a small program each time you add to it?


Oiduts Studios(Posted 2008) [#5]
Thank you for the help!