DIM fins$(101), c$(17)
ON ERROR GOTO noco
x = SCREEN(1, 1, 1)
dfc = (x AND 128) \ 8 + (x AND 15)
dbc = (x AND 112) \ 16
COLOR dfc, dbc
renoco:
ON ERROR GOTO 0
CLS
OPEN "o", #1, "con"
LOCATE 1, 20: PRINT #1, " Trivia file maker     By Jim Kitchen"
d$ = LCASE$(DIR$("trvmaker.dat"))
IF d$ = "" THEN GOTO nodat
LOCATE 3, 1: PRINT #1, " checking directory for question and answer files please wait"
nof = 1
fins$(nof) = DIR$("*.ttf")
IF fins$(nof) = "" THEN GOTO gfn
DO
nof = nof + 1
fins$(nof) = DIR$
LOOP UNTIL fins$(nof) = ""
nof = nof - 1
IF nof = 1 THEN GOTO nosort1
FOR sort1 = 1 TO nof - 1
FOR sort2 = sort1 TO 1 STEP -1
IF fins$(sort2 + 1) < fins$(sort2) THEN SWAP fins$(sort2), fins$(sort2 + 1) ELSE EXIT FOR
NEXT sort2
NEXT sort1
nosort1:

b1:
GOSUB cl
LOCATE 3, 1: PRINT #1, " 1 = create a new question and answer file"
PRINT #1, " 2 = add to or convert an existing question and answer file"
LOCATE 6, 1: PRINT #1, " press the number of your choice";
GOSUB gkey
IF g = 1 THEN GOTO gfn
IF g <> 2 THEN GOTO b1
b2:
GOSUB cl
LOCATE 3, 1: PRINT #1, " 1 = convert a question and answer file"
PRINT #1, " 2 =  add to an existing question and answer file"
LOCATE 6, 1: PRINT #1, " press the number of your choice";
GOSUB gkey
action = g
IF (g <> 1 AND g <> 2) THEN GOTO b2
aaa:
GOSUB cl
LOCATE 3, 1: PRINT #1, " list of saved question and answer files"
GOSUB cl
x = 1: y = 5
FOR af = 1 TO nof
LOCATE y, x: PRINT #1, af;
p = LEN(fins$(af)) - 4
PRINT #1, "= " + LEFT$(fins$(af), p);
x = x + 15
IF x > 65 THEN x = 1: y = y + 1
NEXT af
LOCATE 3, 1: PRINT #1, " Please enter the number of the saved question and answer file to";
IF action = 1 THEN PRINT #1, " convert";  ELSE PRINT #1, " add to";
LOCATE 3, 75: LINE INPUT f$
f = VAL(f$)
IF f < 1 OR f > nof THEN GOTO aaa
flnm$ = fins$(f)
GOSUB cl
IF action = 1 THEN GOTO conv
GOTO gq
gfn:
GOSUB cl
LOCATE 3, 1: PRINT #1, " Enter a file name for the trivia file with no extension"
PRINT #1, " no more than 8 letters please"
LOCATE 5, 1
LINE INPUT flnm$
l = LEN(flnm$)
IF l = 0 THEN GOTO bfn1
IF l > 8 THEN GOTO bfn2
flnm$ = UCASE$(flnm$)
bad = 0
FOR ck = 1 TO l
IF (ASC(MID$(flnm$, ck, 1)) > 47 AND ASC(MID$(flnm$, ck, 1)) < 58) THEN GOTO skip1
IF ASC(MID$(flnm$, ck, 1)) < 65 THEN bad = 1
IF ASC(MID$(flnm$, ck, 1)) > 90 THEN bad = 1
skip1:
NEXT ck
IF bad = 1 THEN GOTO bfn3
flnm$ = flnm$ + ".TTF"
d$ = DIR$(flnm$)
IF d$ = flnm$ THEN GOTO bfn4
bfb1:
LOCATE 9, 1: PRINT #1, " Enter the title for the trivia file no more than 78 characters please"
LOCATE 10, 1
LINE INPUT t$
l = LEN(l$)
IF l > 78 THEN t$ = LEFT$(t$, 78)
t$ = "t>" + t$
LOCATE 17, 1: PRINT #1, " Enter your name no more than 78 characters please"
LOCATE 18, 1
LINE INPUT b$
l = LEN(b$)
IF l > 78 THEN b$ = LEFT$(b$, 78)
b$ = "b>" + b$
OPEN "o", #2, flnm$
PRINT #2, t$
PRINT #2, b$
CLOSE #2
CLS
gq:
LOCATE 25, 1: PRINT #1, " Enter a question no more than 78 characters per line please"
PRINT #1, " and no more than 9 lines"
PRINT #1, " press enter on a blank line to end question"
PRINT #1, " "
qlc = 0
gl:
qlc = qlc + 1
LOCATE 24, 1
LINE INPUT q$(qlc)
l = LEN(q$(qlc))
IF l > 78 THEN q$(qlc) = LEFT$(q$(qlc), 78)
IF qlc = 9 THEN PRINT #1, " ": GOTO q9
IF q$(qlc) <> "" THEN GOTO gl
qlc = qlc - 1
q9:
q$(1) = "q>" + q$(1)
ga2:
PRINT #1, " enter up to 9 possible single line answers"
PRINT #1, " no more than 77 characters per line please"
PRINT #1, " press enter on a blank line to end entering answers"
alc = 0
ga:
alc = alc + 1
PRINT #1, alc
LOCATE 24, 1: PRINT CHR$(alc + 48) + " ";
LOCATE 24, 3
LINE INPUT a$(alc)
l = LEN(a$(alc))
IF l > 77 THEN a$(alc) = LEFT$(a$(alc), 77)
a$(alc) = RIGHT$(CHR$(alc + 48), 1) + ">" + a$(alc)
IF alc = 9 THEN PRINT #1, " ": GOTO gcan
l = LEN(a$(alc))
IF l > 2 THEN GOTO ga
alc = alc - 1
IF alc < 2 THEN GOTO nea
gcan:
PRINT #1, " enter the number of the correct answer"
LOCATE 24, 41
LINE INPUT ca$
ca = VAL(ca$)
b4:
PRINT #1, " "
PRINT #1, " the correct answer number is";
PRINT #1, ca
PRINT #1, " is this correct Y or N"
GOSUB gkey
IF g$ = "n" THEN GOTO gcan
IF g$ <> "y" THEN GOTO b4
PRINT #1, " "
ca$ = "a>" + RIGHT$(CHR$(ca + 48), 1)
PRINT #1, " enter up to 16 comment lines no more than 78 characters per line please"
PRINT #1, " press enter on a blank line to finish entering comment lines"
PRINT #1, " "
clc = 0
gc:
clc = clc + 1
LOCATE 24, 1
LINE INPUT cl$(clc)
l = LEN(cl$(clc))
IF l > 78 THEN cl$(clc) = LEFT$(cl$(clc), 78)
IF clc = 16 THEN GOTO rev
IF cl$(clc) <> "" THEN GOTO gc
IF clc > 1 THEN clc = clc - 1
rev:
cl$(1) = "c>" + cl$(1)
CLS
PRINT #1, " question review"
PRINT #1, " "
ql = LEN(q$(1)) - 2
PRINT #1, " " + RIGHT$(q$(1), ql)
IF qlc = 1 THEN GOTO skip2
FOR pq = 2 TO qlc
PRINT #1, " " + q$(pq)
NEXT pq
skip2:
PRINT #1, " "
FOR pa = 1 TO alc
l = LEN(a$(pa))
PRINT #1, LEFT$(a$(pa), 1) + " " + RIGHT$(a$(pa), l - 2)
NEXT pa
PRINT #1, " "
PRINT #1, " the correct answer is number " + RIGHT$(ca$, 1)
PRINT #1, " "
PRINT #1, " please check the question and answers to see if you will later"
PRINT #1, " want to add them to the question and answer file"
PRINT #1, " press any key to continue when you have finished"
GOSUB gkey
PRINT #1, " "
PRINT #1, " comment review"
PRINT #1, " "
l = LEN(cl$(1))
IF l = 2 THEN GOTO noc
PRINT #1, " " + RIGHT$(cl$(1), l - 2)
IF clc = 1 THEN GOTO worn
FOR pc = 2 TO clc
PRINT #1, " " + cl$(pc)
NEXT pc
GOTO worn
noc:
PRINT #1, " there are no comment lines"
worn:
PRINT #1, " "
PRINT #1, " Do you want to write the question, answers and comment lines to the"
PRINT #1, " question and answer file Y or N"
PRINT #1, " if you don't it will be deleted"
GOSUB gkey
IF g$ = "n" THEN GOTO dowhat
IF g$ <> "y" THEN GOTO worn
OPEN "a", #2, flnm$
FOR p = 1 TO qlc
PRINT #2, q$(p)
NEXT p
FOR p = 1 TO alc
PRINT #2, a$(p)
NEXT p
PRINT #2, ca$
FOR p = 1 TO clc
PRINT #2, cl$(p)
NEXT p
CLOSE #2
PRINT #1, " "
PRINT #1, " the questions, answers and comment lines have been written to the " + flnm$ + " file"
dowhat:
PRINT #1, " "
PRINT #1, " a = add another question"
PRINT #1, " c = convert this file so that it is ready to be used with the trivia game"
PRINT #1, " e = exit program"
PRINT #1, " r = run this program from the start"
PRINT #1, " "
PRINT #1, " press the letter of your choice"
GOSUB gkey
IF g$ = "a" THEN GOTO gq
IF g$ = "c" THEN f = 1: fins$(1) = flnm$: CLS : GOTO conv
IF g$ = "e" THEN GOTO ext
IF g$ = "r" THEN RUN
GOTO dowhat
ext:
GOSUB ccr
CLS
SYSTEM
nea:
PRINT #1, " you will want to have at least two answers"
PRINT #1, " press any key to start entering the answers again"
GOSUB gkey
PRINT #1, " "
GOTO ga2
noco:
RESUME renoco
conv:
l = LEN(fins$(f))
flnm$ = LEFT$(fins$(f), l - 3) + "TRV"
d$ = DIR$(flnm$)
IF d$ <> flnm$ THEN GOTO ok1
LOCATE 3, 1: PRINT #1, " a " + flnm$ + " file already exists"
PRINT #1, " over write file Y or N"
GOSUB gkey
IF g$ = "y" THEN KILL flnm$: CLS : GOTO ok1
PRINT #1, " please rename or delete the " + flnm$ + " file"
PRINT #1, " before you try to convert the " + fins$(f) + " question and answer file"
PRINT #1, " if you have any trouble please write or call me"
PRINT #1, " jim.kitchen@pcohio.net"
PRINT #1, " 1-440-286-6920"
LOCATE 11, 1
SYSTEM
ok1:
LOCATE 3, 1: PRINT #1, " the " + fins$(f) + " file is being converted"
SHELL "copy " + fins$(f) + " trivia.q&a > nul"
NAME "trvmaker.dat" AS "zip.exe"
SHELL "zip -ex " + flnm$ + " trivia.q&a > nul"
NAME "zip.exe" AS "trvmaker.dat"
KILL "trivia.q&a"
d$ = DIR$(flnm$)
IF d$ <> flnm$ THEN GOTO badzip
b3:
LOCATE 5, 1: PRINT #1, " the " + fins$(f) + " file has been converted"
PRINT #1, " it is now usable with the trivia game."
PRINT #1, " also if you send it to me as an attached file at"
PRINT #1, " jim.kitchen@pcohio.net"
PRINT #1, " I would very much like to put it up on my web site"
PRINT #1, " you no longer need the " + fins$(f) + " file unless you want to work on it further"
PRINT #1, " would you like to delete it now Y or N"
GOSUB gkey
IF g$ = "y" THEN KILL fins$(f): PRINT #1, " " + fins$(f) + " file deleted"
GOSUB cl
LOCATE 3, 1: PRINT #1, " press E to exit program or any other key to continue"
GOSUB gkey
IF g$ = "e" THEN GOTO ext
RUN
badzip:
LOCATE 25, 1
PRINT #1, " for some reason the " + flnm$ + " file did not get converted"
PRINT #1, "to a file that can be used with the trivia game."
PRINT #1, " please write or call me and I will try to help you"
PRINT #1, " jim.kitchen@pcohio.net"
PRINT #1, " 1-440-286-6920"
PRINT #1, " "
LOCATE 25, 1
SYSTEM
nodat:
LOCATE 3, 1
PRINT #1, " sorry but I could not find the trvmaker.dat file"
PRINT #1, " this program can not convert your file"
PRINT #1, " to be usable with the trivia game without it"
PRINT #1, " you may want to down-load a new copy of the trivia.zip file from my web page"
PRINT #1, " at http://www.now-online.com/jkitchen"
PRINT #1, " write me at jim.kitchen@pcohio.net"
PRINT #1, " my phone number is 1-440-286-6920"
GOSUB ccr
LOCATE 11, 1
SYSTEM
ccr:
CLOSE
k$ = LCASE$(DIR$("zip.exe"))
IF k$ = "zip.exe" THEN NAME "zip.exe" AS "trvmaker.dat"
k$ = LCASE$(DIR$("trivia.tmp"))
IF k$ = "trivia.tmp" THEN KILL "trivia.tmp"
RETURN
gkey:
DO: LOOP UNTIL INKEY$ = ""
DO
g$ = INKEY$
LOOP UNTIL g$ <> ""
g = VAL(g$)
dd = ASC(RIGHT$(g$, 1))
g$ = LCASE$(g$)
IF dd = 27 THEN GOTO eorn
RETURN
eorn:
LOCATE 25, 1: PRINT #1, " do you realy want to exit the program Y or N";
GOSUB gkey
IF g$ = "y" THEN GOTO ext
IF g$ = "n" THEN LOCATE 25, 1: PRINT SPC(78); : RETURN
GOTO eorn
bfn1:
LOCATE 7, 1: PRINT #1, " Sorry that was an invalid file name"
PRINT #1, " because you didn't enter anything"
PRINT #1, " Please try again"
PRINT #1, " Press any key to continue"
GOSUB gkey
GOTO gfn
bfn2:
LOCATE 7, 1: PRINT #1, " Sorry that was an invalid file name"
PRINT #1, " because you entered more than 8 letters"
PRINT #1, " please try again"
PRINT #1, " press any key to continue"
GOSUB gkey
GOTO gfn
bfn3:
LOCATE 7, 1: PRINT #1, " Sorry that was an invalid file name"
PRINT #1, " because you entered something that was not a letter"
PRINT #1, " please try again"
PRINT #1, " press any key to continue"
GOSUB gkey
GOTO gfn
bfn4:
LOCATE 7, 1: PRINT #1, "A " + flnm$ + " file was found"
PRINT #1, " which is a trivia temperary question and answer file"
PRINT #1, " press y to over write file or n to rename the file that you want to work on"
GOSUB gkey
IF g$ = "y" THEN GOTO bfb1
IF g$ = "n" THEN GOTO gfn
GOTO bfn4
cl:
FOR cl = 2 TO 25
LOCATE cl, 1: PRINT SPC(79);
NEXT cl
RETURN

