DECLARE FUNCTION despace$ (str AS STRING) DECLARE FUNCTION RandTense! () DECLARE FUNCTION KwaVerb$ (c!, num!, t!, s!, v!) DECLARE FUNCTION KwaComp$ (pcomp!, person!, possperson!, number!, tense!, sign!, noun!, verb!, adjective!, object!, location!) DECLARE FUNCTION Phrase$ (tm, ps, person, possperson, number, tense, sign, noun, verb, adjective, object, location) DECLARE FUNCTION EngLocNoun$ (n!, num!, l!) DECLARE FUNCTION KwaNounLoc$ (n!, num!, l!) DECLARE FUNCTION KwaPersPronVerbObj$ (p!, t!, s!, v!, o!) DECLARE FUNCTION EngPersPronVerbObj$ (p!, t!, s!, v!, o!) DECLARE FUNCTION EngNounOf$ (n!, num!) DECLARE FUNCTION KwaNounOf$ (n!, num!) DECLARE FUNCTION KwaNounVerb$ (n!, num!, t!, s!, v!) DECLARE FUNCTION EngNounVerb$ (n!, num!, t!, s!, v!) DECLARE FUNCTION EngAdjNoun$ (adj!, num!, n!) DECLARE FUNCTION KwaNounAdj$ (adj!, num!, n!) DECLARE FUNCTION KwaNounPoss$ (p!, num!, n!) DECLARE FUNCTION EngPossNoun$ (p!, num!, n!) DECLARE FUNCTION KwaAdj$ (adj!, n!, class!) DECLARE FUNCTION KwaThatFar$ (n!, c!) DECLARE FUNCTION KwaPoss$ (num!, c!, p!) DECLARE FUNCTION KwaNoun$ (n!, num!) DECLARE FUNCTION KwaPersPronVerb$ (p!, t!, s!, v!) DECLARE FUNCTION KwaPersVerb$ (p!, t!, s!, v!) DECLARE FUNCTION EngPersPronVerb$ (p!, t!, s!, v!) DECLARE FUNCTION irand! (i!) DECLARE SUB KwaWrite () DECLARE SUB PhraseWrite () DECLARE SUB VocabWrite (qarray() AS STRING, aarray() AS STRING, narray!, nans!, offset!) DECLARE SUB markstring (attempt AS STRING, answer AS STRING) DECLARE SUB KwaMatchMenu () DECLARE SUB KwaMatch () DECLARE SUB PhraseMatch () DECLARE SUB PhraseMenu () DECLARE SUB transmenu () DECLARE SUB vocabmenu () 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!) DIM SHARED correct, tries, nchoices nchoices = 4 DIM SHARED progname AS STRING progname = "Kwanyama Grammar Quiz" ' Languages DIM SHARED lang(2) AS STRING lang(1) = "English" lang(2) = "Kwanyama" ' Question Categories DIM SHARED category, ncat ncat = 3 DIM SHARED catname(ncat) AS STRING DATA "Vocabulary Translation", "Phrase Translation", "Kwanyama Phrase Component Matching" FOR i = 1 TO ncat READ catname(i) NEXT i ' Options DIM SHARED trans trans = 0 DIM SHARED showpronoun showpronoun = -1 DIM SHARED writeans writeans = -1 ' Read Data Files of Vocabulary and Sentences DIM SHARED nfiles, maxfiles maxfiles = 30 nfiles = 11 DATA "kwap1.txt", "Introduction Sentences" DATA "kwap2.txt", "Classroom Sentences" DATA "kwap3.txt", "People Sentences" DATA "kwap4.txt", "Food Sentences" DATA "kwap5.txt", "Days Sentences" DATA "kwap6.txt", "Numbers Sentences" DATA "kwap7.txt", "Shopping Sentences" DATA "kwap8.txt", "Directions Sentences" DATA "kwap9.txt", "Health Sentences" DATA "kwap10.txt", "Animals Sentences" DATA "kwap11.txt", "Help Sentences" '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 vcategory vcategory = 0 maxvocab = 300 DIM SHARED English$(maxvocab), Kwanyama$(maxvocab), vocabcategory(maxvocab) DIM file$(maxfiles) DIM SHARED nvocab(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 vocabcategory(j) = i j = j + 1 k = k + 1 LOOP nvocab(i) = k - 1 CLOSE #1 NEXT i ' Verb Conjugation DIM SHARED verb, nverb, maxverb maxverb = 51 DIM SHARED EngVerb$(maxverb), KwaVerbInf$(maxverb), KwaVerbConj$(maxverb), KwaVerbForm(maxverb) file$(1) = fileloc$ + "kwaverb.txt" OPEN file$(1) FOR INPUT AS #1 i = 0 DO WHILE NOT EOF(1) i = i + 1 INPUT #1, EngVerb$(i), KwaVerbInf$(i), KwaVerbConj$(i), KwaVerbForm(i) LOOP CLOSE #1 nverb = i DIM SHARED EngPersSubjPron$(6) DIM SHARED KwaPersSubjPron$(6) FOR i = 1 TO 6 READ EngPersSubjPron$(i), KwaPersSubjPron$(i) NEXT i DATA "I", "ame" DATA "you (one)", "ove" DATA "he", "ye" DATA "we", "fye" DATA "you (many)", "nye" DATA "they", "vo" DIM SHARED EngPersObjPron$(6) DIM SHARED KwaPersObjPron$(6) FOR i = 1 TO 6 READ EngPersObjPron$(i), KwaPersObjPron$(i) NEXT i DATA "me", "enge" DATA "you (one)", "ku" DATA "him", "mu" DATA "us", "tu" DATA "you (many)", "mu" DATA "them", "va" DIM SHARED person, tense, sign DIM SHARED KwaPersAux$(6, 4, 2) FOR tense = 1 TO 4 FOR sign = 1 TO 2 FOR person = 1 TO 6 READ KwaPersAux$(person, tense, sign) NEXT person NEXT sign NEXT tense DATA "ohandi", "oto", "ota", "ohatu", "otamu", "otava" DATA "itandi", "ito", "ita", "itatu", "itamu", "itava" DATA "ohandi", "oho", "oha", "ohatu", "ohamu", "ohava" DATA "ihandi", "iho", "iha", "ihatu", "ihamu", "ihava" DATA "onda", "owa", "okwa", "otwa", "omwa", "ova" DATA "inandi", "ino", "ina", "inatu", "inamu", "inava" DATA "ondi", "ou", "oku", "otu", "omu", "ove" DATA "kandi", "ku", "ke", "katu", "kamu", "kave" person = 1 tense = 1 sign = 1 verb = 1 ' Noun Classes DIM SHARED noun, nnoun, maxnoun maxnoun = 210 DIM SHARED EngNoun$(maxnoun), KwaNounStem$(maxnoun), KwaNounClass(maxnoun) i = 0 file$(1) = "kwanoun.txt" file$(2) = "kwanoun0.txt" file$(3) = "kwanoun3.txt" file$(4) = "kwanoun4.txt" file$(5) = "kwanoun5.txt" file$(6) = "kwanoun7.txt" file$(7) = "kwanoun8.txt" file$(8) = "kwanoun9.txt" FOR j = 1 TO 8 file$(j) = fileloc$ + file$(j) OPEN file$(j) FOR INPUT AS #1 DO WHILE NOT EOF(1) i = i + 1 INPUT #1, EngNoun$(i), KwaNounStem$(i), KwaNounClass(i) LOOP CLOSE #1 NEXT j nnoun = i 'PRINT nnoun 'SLEEP 'DATA "person", "nhu", 1 'DATA "tree", "ti", 2 'DATA "hand", "ke", 3 'DATA "table", "taafula", 4 'DATA "classroom", "ngulu", 5 'DATA "t-shirt", "mbidya", 6 'DATA "night", "ufiku", 7 'DATA "ear", "kutwi", 8 DIM SHARED adj, nadj nadj = 20 DIM SHARED EngAdj$(nadj), KwaAdjStem$(nadj) FOR adj = 1 TO nadj READ EngAdj$(adj), KwaAdjStem$(adj) NEXT adj DATA "tall", "le" DATA "short", "xupi" DATA "big", "nene" DATA "small", "shona" DATA "good", "wa" DATA "bad", "i" DATA "clean", "yela" DATA "dirty", "kaka" DATA "new", "pe" DATA "old", "kulu" DATA "hard", "kukutu" DATA "soft", "pu" DATA "heavy", "dyu" DATA "light", "pu" DATA "black", "laula" DATA "white", "toka" DATA "red", "tilyana" DATA "blue", "mbulau" DATA "yellow", "shunga" DATA "green", "twima" nKwaClass = 8 DIM SHARED EngLoc$(3, 2) FOR i = 1 TO 3 FOR j = 1 TO 2 READ EngLoc$(i, j) NEXT j NEXT i DATA "this", "these", "that (near)", "those (near)", "that (far)", "those (far)" DIM SHARED number, class, location DIM SHARED KwaNPre$(2, nKwaClass), KwaSPro$(2, nKwaClass), KwaOPro$(2, nKwaClass), KwaOf$(2, nKwaClass), KwaPossPre$(2, nKwaClass), KwaLoc$(2, nKwaClass, 3) FOR c = 1 TO nKwaClass FOR n = 1 TO 2 READ KwaNPre$(n, c), KwaSPro$(n, c), KwaOPro$(n, c), KwaOf$(n, c), KwaPossPre$(n, c), KwaLoc$(n, c, 1), KwaLoc$(n, c, 2), KwaLoc$(n, c, 3) KwaLoc$(n, c, 3) = KwaLoc$(n, c, 3) + "nya" NEXT n NEXT c DATA "omu", "ye", "mu", "wo", "w", "ou", "oo", "wi" DATA "ova", "vo", "va", "vo", "v", "ava", "ovo", "ve" DATA "omu", "wo", "u", "wo", "w", "ou", "oo", "wi" DATA "omi", "do", "di", "do", "d", "edi", "odo", "di" DATA "e", "lo", "li", "lo", "l", "eli", "olo", "li" DATA "oma", "o", "a", "o", "", "aa", "oo", "e" DATA "oshi", "sho", "shi", "sho", "sh", "eshi", "osho", "shi" DATA "oi", "yo", "i", "yo", "y", "ei", "oyo", "i" DATA "o", "yo", "i", "yo", "y", "ei", "oyo", "i" DATA "ee", "do", "di", "do", "d", "edi", "odo", "di" DATA "oka", "ko", "ka", "ko", "k", "aka", "oko", "ke" DATA "ou", "vo", "va", "vo", "v", "ava", "ovo", "ve" DATA "o", "wo", "u", "wo", "w", "ou", "oo", "wi" DATA "oma", "o", "a", "o", "", "aa", "oo", "e" DATA "o", "kwo", "ku", "kwo", "kw", "oku", "oku", "kwi" DATA "oma", "o", "a", "o", "", "aa", "oo", "e" DIM SHARED EngPoss$(6), KwaPossStem$(6) FOR i = 1 TO 6 READ EngPoss$(i), KwaPossStem$(i) NEXT i DATA "my", "ange" DATA "your (one)", "oye" DATA "his", "aye" DATA "our", "etu" DATA "your (many)", "avo (nye)" DATA "their", "avo (vo)" DIM SHARED KwaAux$(nKwaClass, 2, 4) FOR c = 1 TO nKwaClass FOR n = 1 TO 2 READ KwaAux$(c, n, 1) KwaAux$(c, n, 2) = "oha" + KwaAux$(c, n, 1) KwaAux$(c, n, 1) = "ota" + KwaAux$(c, n, 1) FOR t = 3 TO 4 READ KwaAux$(c, n, t) NEXT t NEXT n NEXT c DATA "", "okwa", "oku" DATA "va", "ova", "ove" DATA "u", "owa", "ou" DATA "di", "oda", "odi" DATA "li", "ola", "oli" DATA "a", "okwa", "oku" DATA "shi", "osha", "oshi" DATA "i", "oya", "oi" DATA "i", "oya", "oi" DATA "di", "oda", "odi" DATA "ka", "oka", "oke" DATA "va", "ova", "ove" DATA "u", "owa", "ou" DATA "a", "okwa", "oku" DATA "ku", "okwa", "oku" DATA "a", "okwa", "oku" ' Phrase Components DIM SHARED pcomp, npcomp npcomp = 11 DIM SHARED PCompDesc$(npcomp) FOR i = 1 TO npcomp READ PCompDesc$(i) NEXT i DATA "noun" DATA "subject pronoun" DATA "object pronoun" DATA "personal subject pronoun" DATA "personal object pronoun" DATA "'of'" DATA "possessive" DATA "adjective" DATA "verb" DATA "personal verb" DATA "location" ' Phrase Structures DIM SHARED pstruct, npstruct pstruct = 0 'random npstruct = 7 DIM SHARED PStructComp(npstruct, 3) DIM SHARED PStructDesc$(npstruct) FOR i = 1 TO npstruct READ PStructComp(i, 1) PStructDesc$(i) = PCompDesc$(PStructComp(i, 1)) FOR j = 2 TO 3 READ PStructComp(i, j) IF PStructComp(i, j) > 0 THEN PStructDesc$(i) = PStructDesc$(i) + ", " + PCompDesc$(PStructComp(i, j)) NEXT j NEXT i DATA 4, 10, 0 'psp,pv DATA 4, 10, 5 'psp,pv,pop DATA 1, 7, 0 'n,p DATA 1, 9, 0 'n,v DATA 1, 8, 0 'n,a DATA 1, 6, 0 'n,of DATA 1, 11, 0 'n,l 'Matching Components DIM SHARED matchcomp, nmatchcomp matchcomp = 0 nmatchcomp = 15 DIM SHARED MatchCompPair(nmatchcomp, 2) FOR i = 1 TO nmatchcomp FOR j = 1 TO 2 READ MatchCompPair(i, j) NEXT j NEXT i DATA 1, 2, 1, 3, 1, 6, 1, 7, 1, 8, 1, 9, 1, 11 DATA 2, 3, 2, 7, 2, 8, 2, 9, 2, 11 DATA 4, 5, 4, 7, 4, 10 'DATA 6, 7, 6, 8 'DATA 7, 8 ' 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 Menu" 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 EngAdjNoun$ (adj, num, n) ean$ = EngAdj$(adj) + " " + EngNoun$(n) IF num = 2 THEN ean$ = ean$ + "s" EngAdjNoun$ = ean$ END FUNCTION FUNCTION EngLocNoun$ (n, num, l) en$ = EngNoun$(n) IF num = 2 THEN en$ = en$ + "s" EngLocNoun$ = EngLoc$(l, num) + " " + en$ END FUNCTION FUNCTION EngNounOf$ (n, num) en$ = EngNoun$(n) IF num = 2 THEN en$ = en$ + "s" EngNounOf$ = en$ + " of" END FUNCTION FUNCTION EngNounVerb$ (n, num, t, s, v) env$ = "the " 'person env$ = env$ + EngNoun$(n) IF num = 2 THEN env$ = env$ + "s" env$ = env$ + " " 'tense (auxiliary) SELECT CASE t CASE 1 'present SELECT CASE num CASE 1 et$ = "is" CASE ELSE et$ = "are" END SELECT CASE 2 'habitual IF num = 1 THEN et$ = "does" ELSE et$ = "do" CASE 3 'past et$ = "did" CASE 4 'future et$ = "will" END SELECT env$ = env$ + et$ + " " 'sign (assume positive) 'IF s = 2 THEN env$ = env$ + "not " 'verb env$ = env$ + EngVerb$(v) IF t = 1 THEN 'remove final e of verbs before adding ing IF MID$(env$, LEN(env$), 1) = "e" THEN env$ = LEFT$(env$, LEN(env$) - 1) env$ = env$ + "ing" END IF EngNounVerb$ = env$ END FUNCTION FUNCTION EngPersPronVerb$ (p, t, s, v) es$ = "" 'person ep$ = EngPersSubjPron$(p) IF p = 3 THEN IF irand(2) = 1 THEN ep$ = "she" END IF es$ = es$ + ep$ + " " 'tense (auxiliary) SELECT CASE t CASE 1 'present SELECT CASE p CASE 1 et$ = "am" CASE 3 et$ = "is" CASE ELSE et$ = "are" END SELECT CASE 2 'habitual IF p = 3 THEN et$ = "does" ELSE et$ = "do" CASE 3 'past et$ = "did" CASE 4 'future et$ = "will" END SELECT es$ = es$ + et$ + " " 'sign IF s = 2 THEN es$ = es$ + "not " 'verb es$ = es$ + EngVerb$(v) IF t = 1 THEN 'remove final e of verbs before adding ing IF MID$(es$, LEN(es$), 1) = "e" THEN es$ = LEFT$(es$, LEN(es$) - 1) es$ = es$ + "ing" END IF EngPersPronVerb$ = es$ END FUNCTION FUNCTION EngPersPronVerbObj$ (p, t, s, v, o) EngPersPronVerbObj$ = EngPersPronVerb$(p, t, s, v) + " " + EngPersObjPron$(o) END FUNCTION FUNCTION EngPossNoun$ (p, num, n) po$ = EngPoss$(p) IF p = 3 AND irand(2) = 1 THEN po$ = "her" epn$ = po$ + " " + EngNoun$(n) IF num = 2 THEN epn$ = epn$ + "s" EngPossNoun$ = epn$ END FUNCTION FUNCTION irand (i) irand = INT(RND * i) + 1 END FUNCTION FUNCTION KwaAdj$ (adj, n, class) KwaAdj$ = KwaOPro$(n, class) + KwaAdjStem$(adj) END FUNCTION FUNCTION KwaComp$ (pcomp, person, possperson, number, tense, sign, noun, verb, adjective, object, location) class = KwaNounClass(noun) SELECT CASE pcomp CASE 1 kc$ = KwaNoun$(noun, number) CASE 2 kc$ = KwaSPro$(number, class) CASE 3 kc$ = KwaOPro$(number, class) CASE 4 kc$ = KwaPersSubjPron$(person) CASE 5 kc$ = KwaPersObjPron$(person) CASE 6 kc$ = KwaOf$(number, class) CASE 7 kc$ = KwaPoss$(number, class, person) CASE 8 kc$ = KwaAdj$(adjective, number, class) CASE 9 kc$ = KwaVerb$(class, number, tense, sign, verb) CASE 10 kc$ = KwaPersVerb$(person, tense, sign, verb) CASE 11 kc$ = KwaLoc$(number, class, location) CASE ELSE PRINT "Error: Kwanyama Phrase Component unknown" END SELECT KwaComp$ = kc$ END FUNCTION SUB KwaMatch DIM AnsSentence$(nchoices), ques AS STRING, answer AS STRING person = irand(6) possperson = irand(6) number = INT((person - 1) / 3) + 1 tense = RandTense sign = irand(2) noun = irand(nnoun) verb = irand(nverb) adjective = irand(nadj) object = irand(6) location = irand(3) mc = matchcomp IF mc = 0 THEN mc = irand(nmatchcomp) flipflop = irand(2) qcomp = MatchCompPair(mc, flipflop) acomp = MatchCompPair(mc, 3 - flipflop) ques = KwaComp$(qcomp, person, possperson, number, tense, sign, noun, verb, adjective, object, location) answer = KwaComp$(acomp, person, possperson, number, tense, sign, noun, verb, adjective, object, location) PRINT "What is the Kwanyama "; PCompDesc$(acomp); " that matches this Kwanyama "; PCompDesc$(qcomp); "?" PRINT ques PRINT ans = irand(nchoices) FOR i = 1 TO nchoices IF i = ans THEN PRINT i; answer ELSE DO flag = 0 IF irand(3) = 1 THEN p = irand(6) ELSE p = person IF irand(3) = 1 THEN pp = irand(6) ELSE pp = possperson num = INT((p - 1) / 3) + 1 IF irand(3) = 1 THEN t = RandTense ELSE t = tense IF irand(3) = 1 THEN s = irand(2) ELSE s = sign IF irand(3) = 1 THEN n = irand(nnoun) ELSE n = noun IF irand(3) = 1 THEN v = irand(nverb) ELSE v = verb IF irand(3) = 1 THEN a = irand(nadj) ELSE a = adjective IF irand(3) = 1 THEN o = irand(6) ELSE o = object IF irand(3) = 1 THEN l = irand(3) ELSE l = location AnsSentence$(i) = KwaComp$(acomp, p, pp, num, t, s, n, v, a, o, l) IF AnsSentence$(i) = answer THEN flag = 1 ELSE FOR j = 1 TO i - 1 IF AnsSentence$(i) = AnsSentence$(j) THEN flag = 1 NEXT j END IF LOOP WHILE flag = 1 PRINT i; AnsSentence$(i) END IF NEXT i CALL qmark(ans, nchoices) END SUB SUB KwaMatchMenu CLS PRINT progname; " - Kwanyama Phrase Components Menu" PRINT FOR i = 0 TO nmatchcomp PRINT i; IF i = 0 THEN PRINT "Random", ELSE PRINT PCompDesc$(MatchCompPair(i, 1)); " and "; PCompDesc$(MatchCompPair(i, 2)); IF i = matchcomp THEN PRINT "<----" ELSE PRINT NEXT i PRINT INPUT "Enter the number of a phrase component"; matchcomp DO WHILE matchcomp < 0 OR matchcomp > nmatchcomp PRINT "Please enter a number from 0 to"; nmatchcomp INPUT matchcomp LOOP END SUB FUNCTION KwaNoun$ (n, num) KwaNoun$ = KwaNPre$(num, KwaNounClass(n)) + KwaNounStem$(n) END FUNCTION FUNCTION KwaNounAdj$ (adj, num, n) KwaNounAdj$ = KwaNoun$(n, num) + " " + KwaAdj$(adj, num, KwaNounClass(n)) END FUNCTION FUNCTION KwaNounLoc$ (n, num, l) KwaNounLoc$ = KwaNoun$(n, num) + " " + KwaLoc$(num, KwaNounClass(n), l) END FUNCTION FUNCTION KwaNounOf$ (n, num) KwaNounOf$ = KwaNoun$(n, num) + " " + KwaOf$(num, KwaNounClass(n)) END FUNCTION FUNCTION KwaNounPoss$ (p, num, n) KwaNounPoss$ = KwaNoun$(n, num) + " " + KwaPoss$(num, KwaNounClass(n), p) END FUNCTION FUNCTION KwaNounVerb$ (n, num, t, s, v) knv$ = "" 'noun knv$ = knv$ + KwaNoun$(n, num) + " " 'verb knv$ = knv$ + KwaVerb$(KwaNounClass(n), num, t, s, v) KwaNounVerb$ = knv$ END FUNCTION FUNCTION KwaPersPronVerb$ (p, t, s, v) 'person ks$ = "" IF showpronoun = 1 THEN ks$ = ks$ + "(" + KwaPersSubjPron$(p) + ")" + " " END IF 'verb kv$ = KwaPersVerb$(p, t, s, v) KwaPersPronVerb$ = ks$ + kv$ END FUNCTION FUNCTION KwaPersPronVerbObj$ (p, t, s, v, o) ks$ = "" 'person IF showpronoun = 1 THEN ks$ = ks$ + "(" + KwaPersSubjPron$(p) + ")" + " " END IF 'tense and subject t2 = t IF (t = 1 OR t = 2) AND KwaVerbForm(v) = 3 THEN t2 = 4 IF (t = 1 OR t = 2) AND KwaVerbForm(v) = 2 THEN t2 = 3 IF t = 4 THEN t2 = 1 ks$ = ks$ + KwaPersAux$(p, t2, s) + " " IF t = 4 THEN ks$ = ks$ + "ka " 'object IF o <> 1 THEN ks$ = ks$ + KwaPersObjPron$(o) 'verb IF t = 3 OR t = 4 OR KwaVerbConj$(v) = "" THEN kv$ = KwaVerbInf$(v) ELSE kv$ = KwaVerbConj$(v) ks$ = ks$ + kv$ IF o = 1 THEN ks$ = LEFT$(ks$, LEN(ks$) - 1) 'chop off final vowel ks$ = ks$ + KwaPersObjPron$(o) END IF KwaPersPronVerbObj$ = ks$ END FUNCTION FUNCTION KwaPersVerb$ (p, t, s, v) ks$ = "" 'tense and subject t2 = t IF (t = 1 OR t = 2) AND KwaVerbForm(v) = 3 THEN t2 = 4 IF (t = 1 OR t = 2) AND KwaVerbForm(v) = 2 THEN t2 = 3 IF t = 4 THEN t2 = 1 ks$ = ks$ + KwaPersAux$(p, t2, s) + " " 'verb IF t = 4 THEN ks$ = ks$ + "ka " IF t = 3 OR t = 4 OR KwaVerbConj$(v) = "" THEN kv$ = KwaVerbInf$(v) ELSE kv$ = KwaVerbConj$(v) ks$ = ks$ + kv$ KwaPersVerb$ = ks$ END FUNCTION FUNCTION KwaPoss$ (num, c, p) KwaPoss$ = KwaPossPre$(num, c) + KwaPossStem$(p) END FUNCTION FUNCTION KwaVerb$ (c, num, t, s, v) 'tense and subject (assume sign is affirmative) t2 = t IF (t = 1 OR t = 2) AND KwaVerbForm(v) = 3 THEN t2 = 4 IF (t = 1 OR t = 2) AND KwaVerbForm(v) = 2 THEN t2 = 3 IF t = 4 THEN t2 = 1 kv$ = KwaAux$(c, num, t2) + " " 'verb IF t = 4 THEN kv$ = kv$ + "ka " IF t = 3 OR t = 4 OR KwaVerbConj$(v) = "" THEN kv$ = kv$ + KwaVerbInf$(v) ELSE kv$ = kv$ + KwaVerbConj$(v) KwaVerb$ = kv$ END FUNCTION SUB KwaWrite person = irand(6) possperson = irand(6) number = INT((person - 1) / 3) + 1 tense = RandTense sign = irand(2) noun = irand(nnoun) verb = irand(nverb) adjective = irand(nadj) object = irand(6) location = irand(3) mc = matchcomp IF mc = 0 THEN mc = irand(nmatchcomp) flipflop = irand(2) qcomp = MatchCompPair(mc, flipflop) acomp = MatchCompPair(mc, 3 - flipflop) ques$ = KwaComp$(qcomp, person, possperson, number, tense, sign, noun, verb, adjective, object, location) answer$ = KwaComp$(acomp, person, possperson, number, tense, sign, noun, verb, adjective, object, location) PRINT "What is the Kwanyama "; PCompDesc$(acomp); " that matches this Kwanyama "; PCompDesc$(qcomp); "?" PRINT ques$ PRINT INPUT attempt$ CALL markstring(attempt$, answer$) END SUB SUB mainhelp CLS PRINT progname PRINT PRINT "This program tests your knowledge of Oshikwanyama (and English) grammar." PRINT "It was written by Greg Vogl in July 1996." PRINT "Thanks go to Dennis Shikwambi and Eino Heelu for Kwanyama lessons and help." PRINT "This program contains many mistakes and should not be considered an authority." 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." IF category = 1 THEN PRINT "Press P to change the vocabulary category. (question category 1)" IF category = 2 THEN PRINT "Press U to change the phrase structure. (question category 2)" IF category = 3 THEN PRINT "Press K to change the phrase component matching. (question category 3)" IF category <> 3 THEN 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." IF category = 2 THEN PRINT "press H to hide or show subject pronouns." PRINT "Press C to change between multiple choice and written answers." 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 vocabmenu CASE "t" CALL transmenu CASE "u" CALL PhraseMenu CASE "k" CALL KwaMatchMenu 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 "h" showpronoun = -showpronoun PRINT "pronouns are "; IF showpronoun = 1 THEN PRINT "shown" ELSE PRINT "hidden" 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 FUNCTION Phrase$ (tm, ps, person, possperson, number, tense, sign, noun, verb, adjective, object, location) SELECT CASE ps CASE 1 ep$ = EngPersPronVerb$(person, tense, sign, verb) kp$ = KwaPersPronVerb$(person, tense, sign, verb) CASE 2 ep$ = EngPersPronVerbObj$(person, tense, sign, verb, object) kp$ = KwaPersPronVerbObj$(person, tense, sign, verb, object) CASE 3 ep$ = EngPossNoun$(possperson, number, noun) kp$ = KwaNounPoss$(possperson, number, noun) CASE 4 'sign = 1 'only because I do not have data for negatives ep$ = EngNounVerb$(noun, number, tense, sign, verb) kp$ = KwaNounVerb$(noun, number, tense, sign, verb) CASE 5 ep$ = EngAdjNoun(adjective, number, noun) kp$ = KwaNounAdj(adjective, number, noun) CASE 6 ep$ = EngNounOf(noun, number) kp$ = KwaNounOf(noun, number) CASE 7 ep$ = EngLocNoun$(noun, number, location) kp$ = KwaNounLoc$(noun, number, location) CASE ELSE PRINT "Error: This phrase structure is not implemented." END SELECT IF tm = 1 THEN Phrase$ = ep$ ELSE Phrase$ = kp$ END FUNCTION SUB PhraseMatch DIM AnsSentence$(nchoices), ques AS STRING, answer AS STRING, temp AS STRING person = irand(6) possperson = irand(6) number = INT((person - 1) / 3) + 1 tense = RandTense sign = irand(2) noun = irand(nnoun) verb = irand(nverb) adjective = irand(nadj) object = irand(6) location = irand(3) ps = pstruct IF ps = 0 THEN ps = irand(npstruct) PRINT "Phrase Structure: "; ps; " ("; PStructDesc$(ps); ")" tm = trans IF trans = 0 THEN tm = irand(2) PRINT "What is the "; lang(3 - tm); " translation of this "; lang(tm); " phrase?" ques = Phrase$(tm, ps, person, possperson, number, tense, sign, noun, verb, adjective, object, location) answer = Phrase$(3 - tm, ps, person, possperson, number, tense, sign, noun, verb, adjective, object, location) PRINT ques PRINT ans = irand(nchoices) FOR i = 1 TO nchoices IF i = ans THEN PRINT i; answer ELSE DO flag = 0 IF irand(3) = 1 THEN p = irand(6) ELSE p = person IF irand(3) = 1 THEN pp = irand(6) ELSE pp = possperson num = INT((p - 1) / 3) + 1 IF irand(3) = 1 THEN t = RandTense ELSE t = tense IF irand(3) = 1 THEN s = irand(2) ELSE s = sign IF irand(3) = 1 THEN n = irand(nnoun) ELSE n = noun IF irand(3) = 1 THEN v = irand(nverb) ELSE v = verb IF irand(3) = 1 THEN a = irand(nadj) ELSE a = adjective IF irand(3) = 1 THEN o = irand(6) ELSE o = object IF irand(3) = 1 THEN l = irand(3) ELSE l = location AnsSentence$(i) = Phrase$(3 - tm, ps, p, pp, num, t, s, n, v, a, o, l) IF AnsSentence$(i) = answer THEN flag = 1 ELSE FOR j = 1 TO i - 1 IF AnsSentence$(i) = AnsSentence$(j) THEN flag = 1 NEXT j END IF LOOP WHILE flag = 1 PRINT i; AnsSentence$(i) END IF NEXT i CALL qmark(ans, nchoices) END SUB SUB PhraseMenu CLS PRINT progname; " - Phrase Structure Menu" PRINT FOR i = 0 TO npstruct PRINT i; IF i = 0 THEN PRINT "Random", ELSE PRINT PStructDesc$(i); IF i = pstruct THEN PRINT "<----" ELSE PRINT NEXT i PRINT INPUT "Enter the number of a phrase structure"; pstruct DO WHILE pstruct < 0 OR pstruct > npstruct PRINT "Please enter a number from 0 to"; npstruct INPUT pstruct LOOP END SUB SUB PhraseWrite DIM AnsSentence$(nchoices), ques AS STRING, answer AS STRING, temp AS STRING person = irand(6) possperson = irand(6) number = INT((person - 1) / 3) + 1 tense = RandTense sign = irand(2) noun = irand(nnoun) verb = irand(nverb) adjective = irand(nadj) object = irand(6) location = irand(3) ps = pstruct IF ps = 0 THEN ps = irand(npstruct) PRINT "Phrase Structure: "; ps; " ("; PStructDesc$(ps); ")" tm = trans IF trans = 0 THEN tm = irand(2) PRINT "What is the "; lang(3 - tm); " translation of this "; lang(tm); " phrase?" ques = Phrase$(tm, ps, person, possperson, number, tense, sign, noun, verb, adjective, object, location) answer = Phrase$(3 - tm, ps, person, possperson, number, tense, sign, noun, verb, adjective, object, location) PRINT ques PRINT INPUT attempt$ CALL markstring(attempt$, answer) 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 IF t = 0 THEN t = irand(2) vcat = vcategory IF vcat = 0 THEN vcat = irand(nfiles) offset = 0 FOR i = 1 TO vcat - 1 offset = offset + nvocab(i) NEXT i PRINT "Category", filedesc$(vcat) IF t = 1 THEN PRINT "What is the Kwanyama translation of this English word or phrase?" IF writeans = 1 THEN CALL VocabWrite(English$(), Kwanyama$(), nvocab(vcat), nchoices, offset) ELSE CALL VocabMatch(English$(), Kwanyama$(), nvocab(vcat), 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$(), nvocab(vcat), nchoices, offset) ELSE CALL VocabMatch(Kwanyama$(), English$(), nvocab(vcat), nchoices, offset) END IF END IF CASE 2 IF writeans = 1 THEN CALL PhraseWrite ELSE CALL PhraseMatch CASE 3 'IF writeans = 1 THEN CALL KwaWrite ELSE CALL KwaMatch CASE ELSE PRINT "This question category does not exist yet." END SELECT CALL pause END SUB FUNCTION RandTense r = irand(6) IF r > 4 THEN r = 1 RandTense = r END FUNCTION SUB transmenu CLS PRINT progname; " - Translation Mode Menu" PRINT PRINT 0, "Random", IF trans = 0 THEN PRINT "<----" ELSE PRINT PRINT 1, "English to Kwanyama", IF trans = 1 THEN PRINT "<----" ELSE PRINT PRINT 2, "Kwanyama to English", IF trans = 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 vocabmenu CLS PRINT progname; " - Vocabulary Category Menu" PRINT PRINT 0; "Random", IF vcategory = 0 THEN PRINT "<----" ELSE PRINT FOR i = 1 TO nfiles PRINT i; filedesc$(i), IF i = vcategory THEN PRINT "<----"; IF i MOD 2 = 0 THEN PRINT NEXT i PRINT INPUT "Enter the number of a vocabulary category"; vcategory DO WHILE vcategory < 0 OR vcategory > nfiles PRINT "Please enter a number from 0 to"; nfiles INPUT vcategory LOOP 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