DECLARE FUNCTION despace$ (str AS STRING) DECLARE SUB markstring (attempt AS STRING, answer AS STRING) DECLARE SUB VocabWrite (qarray() AS STRING, aarray() AS STRING, narray!, nans!, offset!) DECLARE SUB SentenceMatch () DECLARE FUNCTION KwaSentence$ (p!, t!, s!, v!) DECLARE FUNCTION EngSentence$ (p!, t!, s!, v!) DECLARE SUB transmenu () DECLARE SUB phrasemenu () DECLARE SUB VocabMatch (qarray() AS STRING, aarray() AS STRING, narray!, nans!, offset!) DECLARE SUB definition (array1() AS STRING, array2() AS STRING, term AS STRING, nterms) DECLARE SUB qmark (ans!, nans!) DECLARE SUB mark (choice!, ans!) DECLARE SUB question () DECLARE SUB pause () DECLARE SUB mainmenu () DECLARE SUB mainhelp () DECLARE SUB categorymenu () DECLARE SUB question () DECLARE SUB match (qarray() AS STRING, aarray() AS STRING, narray!, nans!) DECLARE FUNCTION irand! (i!) DIM SHARED correct, tries, nchoices nchoices = 4 DIM SHARED progname AS STRING progname = "Kwanyama Vocabulary Quiz" ' Question Categories DIM SHARED category, ncat ncat = 1 DIM SHARED catname(ncat) AS STRING DATA "Translation" FOR i = 1 TO ncat READ catname(i) NEXT i ' Options DIM SHARED trans trans = 0 DIM SHARED writeans writeans = -1 ' Read Data Files of Vocabulary and Phrases DIM SHARED nfiles nfiles = 27 DATA "kwap1.txt", "Introduction Phrases" DATA "kwap2.txt", "Classroom Phrases" DATA "kwap3.txt", "People Phrases" DATA "kwap4.txt", "Food Phrases" DATA "kwap5.txt", "Days Phrases" DATA "kwap6.txt", "Numbers Phrases" DATA "kwap7.txt", "Shopping Phrases" DATA "kwap8.txt", "Directions Phrases" DATA "kwap9.txt", "Health Phrases" DATA "kwap10.txt", "Animals Phrases" DATA "kwap11.txt", "Help Phrases" DATA "kwav1.txt", "Introduction Vocabulary" DATA "kwav2.txt", "Classroom Vocabulary" DATA "kwav3.txt", "People Vocabulary" DATA "kwav4.txt", "Food Vocabulary" DATA "kwav5.txt", "Days Vocabulary" DATA "kwav6.txt", "Numbers Vocabulary" DATA "kwav7.txt", "Shopping Vocabulary" DATA "kwav8.txt", "Places Vocabulary" DATA "kwav9.txt", "Health Vocabulary" DATA "kwav10.txt", "Animals Vocabulary" DATA "kwav11.txt", "Questions Vocabulary" DATA "kwav12.txt", "Climate Vocabulary" DATA "kwav13.txt", "Household Vocabulary" DATA "kwav14.txt", "Verbs Vocabulary" DATA "kwav15.txt", "Adjectives Vocabulary" DATA "kwav16.txt", "Locations Vocabulary" DIM SHARED pcategory pcategory = 0 maxphrases = 800 DIM SHARED English$(maxphrases), Kwanyama$(maxphrases), phrasecategory(maxphrases) DIM file$(nfiles) DIM SHARED nphrases(nfiles) DIM SHARED filedesc$(nfiles) fileloc$ = "c:\users\vogl\basic\kwanyama\" j = 0 FOR i = 1 TO nfiles READ file$(i), filedesc$(i) 'print file$(i) file$(i) = fileloc$ + file$(i) OPEN file$(i) FOR INPUT AS #1 k = 1 DO WHILE NOT EOF(1) INPUT #1, English$(j), Kwanyama$(j) 'IF LTRIM$(RTRIM$(English$(j))) = "" THEN EXIT DO phrasecategory(j) = i j = j + 1 k = k + 1 LOOP nphrases(i) = k - 1 CLOSE #1 NEXT i ' Main Loop DIM SHARED playsound playsound = 1 PLAY "l16" RANDOMIZE TIMER DIM SHARED starttime starttime = TIMER CALL mainhelp DO CALL mainmenu LOOP SUB categorymenu CLS PRINT progname; " - Question Category" PRINT PRINT 0, "Random", IF category = 0 THEN PRINT "<----" ELSE PRINT FOR i = 1 TO ncat PRINT i, catname(i), IF i = category THEN PRINT "<----" ELSE PRINT NEXT i PRINT INPUT "Enter the number of a category"; category DO WHILE category < 0 OR category > ncat PRINT "Please enter a number from 0 to"; ncat INPUT category LOOP END SUB SUB definition (array1() AS STRING, array2() AS STRING, term AS STRING, nterms) END SUB FUNCTION despace$ (str AS STRING) d$ = "" FOR i = 1 TO LEN(str) c$ = MID$(str, i, 1) IF c$ <> " " AND c$ <> CHR$(9) THEN d$ = d$ + c$ NEXT i despace$ = d$ END FUNCTION FUNCTION irand (i) irand = INT(RND * i) + 1 END FUNCTION SUB mainhelp CLS PRINT progname PRINT PRINT "This program tests your knowledge of Oshikwanyama (and English)." PRINT "It was written with the help of Dennis Shikwambi and Eino Heelu." PRINT CALL pause END SUB SUB mainmenu CLS PRINT progname; " - Main Menu" PRINT IF tries = 0 THEN score = 0 ELSE score = INT(correct / tries * 100) PRINT "Correct Answers: "; correct PRINT "Questions Tried: "; tries PRINT "Percent Score: "; score; "%" IF correct > 0 THEN PRINT "Average Time per Correct Answer:"; INT((TIMER - starttime) / correct); "seconds" PRINT PRINT "Question Category: "; IF category = 0 THEN PRINT " 0 (Random)" ELSE PRINT category; "("; catname(category); ")" END IF PRINT "Multiple Choice Options: "; nchoices PRINT "Sound: "; IF playsound > 0 THEN PRINT "On" ELSE PRINT "Off" PRINT PRINT "Press Enter to try the next question." PRINT "Press R to reset the score to zero." PRINT "Press Q to change the question category." PRINT "Press P to change the phrase category." PRINT "Press T to change the translation mode." PRINT "Press M to change the number of multiple choice options." PRINT "Press S to turn sounds on or off." PRINT "Press I to display information about this program." PRINT "Press Esc to exit this program." DO a$ = INKEY$ LOOP WHILE a$ = "" SELECT CASE a$ CASE CHR$(13) 'enter CALL question CASE "r" correct = 0 tries = 0 starttime = TIMER CASE "q" CALL categorymenu CASE "p" CALL phrasemenu CASE "t" CALL transmenu CASE "m" CLS DO PRINT "Enter the number of choices for multiple choice questions (2 to 9)" INPUT nchoices IF nchoices < 2 OR nchoices > 9 THEN PRINT "You must enter a number from 2 to 9." LOOP WHILE nchoices < 2 OR nchoices > 9 CASE "s" playsound = -playsound PRINT "sound is"; IF playsound = 1 THEN PRINT "on" ELSE PRINT "off" SLEEP 1 CASE "c" writeans = -writeans PRINT "answers are "; IF writeans = 1 THEN PRINT "written" ELSE PRINT "multiple choice" SLEEP 1 CASE "i" CALL mainhelp CASE CHR$(27) 'esc SYSTEM 'CLS 'PRINT "You have exited the program." 'PRINT "To return to Windows, press Alt, press F, and press X." 'END 'CHAIN "c:\users\vogl\basic\exit.bas" CASE ELSE PRINT PRINT "Sorry, you have made an invalid choice." CALL pause END SELECT END SUB SUB mark (choice, ans) IF choice = ans THEN IF playsound > 0 THEN PLAY "CF" PRINT "Correct!" correct = correct + 1 ELSE IF playsound > 0 THEN PLAY "FDD" PRINT "Incorrect. The correct answer is:" PRINT ans END IF tries = tries + 1 PRINT END SUB SUB markstring (attempt AS STRING, answer AS STRING) IF LCASE$(despace$(attempt)) = LCASE$(despace$(answer)) THEN IF playsound > 0 THEN PLAY "CF" PRINT "Correct!" correct = correct + 1 ELSE IF playsound > 0 THEN PLAY "FDD" PRINT "Incorrect. The correct answer is:" PRINT answer END IF tries = tries + 1 PRINT END SUB SUB match (qarray() AS STRING, aarray() AS STRING, narray, nans) DIM temp(nans) AS STRING na = nans IF narray < na THEN na = narray ' to avoid infinite loops DO ques = irand(narray) LOOP WHILE qarray(ques) = "" OR aarray(ques) = "" ans = irand(na) PRINT qarray(ques) PRINT FOR i = 1 TO na IF ans = i THEN j = ques ELSE DO j = irand(narray) flag = 0 FOR k = 1 TO i - 1 IF temp(k) = aarray(j) THEN flag = 1 NEXT k LOOP WHILE j = ques OR qarray(j) = "" OR aarray(j) = "" OR flag = 1 END IF temp(i) = aarray(j) PRINT i; temp(i) NEXT i CALL qmark(ans, na) END SUB SUB pause ' PRINT "Press any key to continue." PRINT "Press Enter to continue." DO a$ = INKEY$ ' LOOP WHILE a$ = "" LOOP WHILE a$ <> CHR$(13) 'Enter END SUB SUB phrasemenu CLS PRINT progname; " - Phrase Category" PRINT PRINT 0; "Random", IF pcategory = 0 THEN PRINT "<----" ELSE PRINT FOR i = 1 TO nfiles PRINT i; filedesc$(i), IF i = pcategory THEN PRINT "<----"; IF i MOD 2 = 0 THEN PRINT NEXT i PRINT INPUT "Enter the number of a phrase category"; pcategory DO WHILE pcategory < 0 OR pcategory > nfiles PRINT "Please enter a number from 0 to"; nfiles INPUT pcategory LOOP END SUB SUB qmark (ans, nans) PRINT PRINT "Press a number from 1 to"; nans; "." DO a$ = INKEY$ IF a$ <> "" THEN choice = ASC(a$) - ASC("0") LOOP WHILE a$ = "" OR choice < 1 OR choice > nans PRINT choice PRINT CALL mark(choice, ans) END SUB SUB question CLS PRINT progname; PRINT cat = category IF category = 0 THEN cat = irand(ncat) PRINT "Question Category: "; cat; "("; catname(cat); ")" PRINT SELECT CASE cat CASE 1 t = trans r = RND IF t = 0 THEN IF r > .5 THEN t = 1 ELSE t = 2 END IF pcat = pcategory IF pcat = 0 THEN pcat = INT(RND * nfiles) + 1 offset = 0 FOR i = 1 TO pcat - 1 offset = offset + nphrases(i) NEXT i PRINT "Category", filedesc$(pcat) IF t = 1 THEN PRINT "What is the Kwanyama translation of this English word or phrase?" IF writeans = 1 THEN CALL VocabWrite(English$(), Kwanyama$(), nphrases(pcat), nchoices, offset) ELSE CALL VocabMatch(English$(), Kwanyama$(), nphrases(pcat), nchoices, offset) END IF ELSEIF t = 2 THEN PRINT "What is the English translation of this Kwanyama word or phrase?" IF writeans = 1 THEN CALL VocabWrite(Kwanyama$(), English$(), nphrases(pcat), nchoices, offset) ELSE CALL VocabMatch(Kwanyama$(), English$(), nphrases(pcat), nchoices, offset) END IF END IF CASE ELSE PRINT "This question category does not exist yet." END SELECT CALL pause END SUB SUB transmenu CLS PRINT progname; " - Translation Mode" PRINT PRINT 0, "Random", IF category = 0 THEN PRINT "<----" ELSE PRINT PRINT 1, "English to Kwanyama", IF category = 1 THEN PRINT "<----" ELSE PRINT PRINT 2, "Kwanyama to English", IF category = 2 THEN PRINT "<----" ELSE PRINT PRINT INPUT "Enter the translation mode"; trans DO WHILE trans < 0 OR trans > 2 PRINT "Please enter a number from 0 to 2." INPUT trans LOOP END SUB SUB VocabMatch (qarray() AS STRING, aarray() AS STRING, narray, nans, offset) DIM temp(nans) AS STRING na = nans IF narray < na THEN na = narray DO ques = irand(narray) + offset LOOP WHILE qarray(ques) = "" OR aarray(ques) = "" ans = irand(na) PRINT qarray(ques) PRINT FOR i = 1 TO na IF ans = i THEN j = ques ELSE DO j = irand(narray) + offset flag = 0 FOR k = 1 TO i - 1 IF aarray(j) = temp(k) THEN flag = 1 NEXT k LOOP WHILE j = ques OR qarray(j) = "" OR aarray(j) = "" OR flag = 1 END IF temp(i) = aarray(j) PRINT i; temp(i) NEXT i CALL qmark(ans, na) END SUB SUB VocabWrite (qarray() AS STRING, aarray() AS STRING, narray, nans, offset) DIM attempt AS STRING DO ques = irand(narray) + offset LOOP WHILE qarray(ques) = "" OR aarray(ques) = "" PRINT qarray(ques) PRINT INPUT attempt CALL markstring(attempt, aarray(ques)) END SUB