$OPTION EXPLICIT
$INCLUDE "rapidq.inc"
DECLARE SUB bc
CONST gap = 10
CONST maxq = 50
CONST noc = 3
DIM form AS QFORM
DIM butt AS QBUTTON
DIM listbox AS QLISTBOX
DIM sentence(maxq) AS QLABEL
DIM pan(maxq) AS QPANEL
DIM rb(maxq * noc) AS QRADIOBUTTON
DIM file AS QFILESTREAM
DIM fname$ AS STRING
DIM tline$ AS STRING
DIM codeword$ AS STRING
DIM codechar$ AS STRING
DIM cryptchar$ AS STRING
DIM textline$ AS STRING
DIM textchar$ AS STRING
DIM qfname$(100) AS STRING
DIM fline$(100) AS STRING
DIM pline$(100) AS STRING
DIM temp$ AS STRING
DIM choice$(noc) AS STRING
DIM qcount AS INTEGER
DIM lc AS INTEGER
DIM cwl AS INTEGER
DIM b AS INTEGER
DIM i AS INTEGER
DIM a AS INTEGER
DIM os AS INTEGER
form.width = 800
form.height = 500
qcount = 0
codeword$ = "tigerlily"
listbox.PARENT = form
butt.PARENT = form
butt.top = 100
butt.onclick = bc
butt.CAPTION = "do quiz"
fname$ = DIR$("*.cde", 0)
WHILE fname$ <> ""
qcount = qcount + 1
qfname$(qcount) = fname$
file.OPEN(fname$, fmopenread)
tline$ = file.readline
file.CLOSE
listbox.additems tline$
fname$ = DIR$
WEND
form.center
form.SHOWMODAL
SUB bc
file.OPEN(qfname$(listbox.itemindex + 1), fmopenread)
lc = 0
FOR a = 1 TO 50
sentence(a).visible = false
pan(a).visible = false
NEXT a
WHILE NOT file.eof
lc = lc + 1
fline$(lc) = file.readline
textline$ = ""
IF lc = 1 THEN
textline$ = fline$(lc)
ELSE
FOR b = 1 TO LEN(fline$(lc))
cwl = b MOD LEN(codeword$)
IF cwl = 0 THEN
cwl = LEN(codeword$)
END IF
codechar$ = MID$(codeword$, cwl, 1)
cryptchar$ = MID$(fline$(lc), b, 1)
textchar$ = CHR$(40 + (ASC(cryptchar$) - 40) - (ASC(codechar$) - 40))
textline$ = textline$ + textchar$
NEXT b
textline$ = reverse$(textline$)
textline$ = LEFT$(textline$, INSTR(textline$, "#")-1)
pline$(lc) = textline$
END IF
WEND
FOR i = 2 TO lc
sentence(i).width = 300
sentence(i).height = 40
sentence(i).top = gap + (i-1)*(sentence(i).height + gap)
sentence(i).left = 150
sentence(i).PARENT = form
sentence(i).CAPTION = LEFT$(pline$(i), INSTR(pline$(i), ":")-1)
sentence(i).visible = true
temp$ = RIGHT$(pline$(i), LEN(pline$(i))-INSTR(pline$(i), ":"))
choice$(1)=LEFT$(temp$, INSTR(temp$, ":")-1)
temp$ = RIGHT$(temp$, LEN(temp$)-INSTR(temp$, ":"))
choice$(2)=LEFT$(temp$, INSTR(temp$, ":")-1)
choice$(3)=RIGHT$(temp$, LEN(temp$)-INSTR(temp$, ":"))
pan(i).height = 30
pan(i).width = 350
pan(i).top = sentence(i).top
pan(i).left = 400
pan(i).bevelwidth = 0
pan(i).visible = true
pan(i).PARENT = form
FOR a = 1 TO 3
rb((i-1)*3+a).PARENT = pan(i)
rb((i-1)*3+a).width = 100
rb((i-1)*3+a).height = pan(i).height - 2
rb((i-1)*3+a).top = 1
rb((i-1)*3+a).left = 10+(a-1)*rb(1).width
rb((i-1)*3+a).tag = 0
rb((i-1)*3+a).visible = true
NEXT a
os = (i-1)*3
SELECT CASE INT(RND*6)
CASE 0
rb(os + 1).CAPTION = choice$(1)
rb(os + 2).CAPTION = choice$(2)
rb(os + 3).CAPTION = choice$(3)
rb(os + 1).tag = 100
CASE 1
rb(os + 1).CAPTION = choice$(1)
rb(os + 2).CAPTION = choice$(3)
rb(os + 3).CAPTION = choice$(2)
rb(os + 1).tag = 100
CASE 2
rb(os + 1).CAPTION = choice$(2)
rb(os + 2).CAPTION = choice$(1)
rb(os + 3).CAPTION = choice$(3)
rb(os + 2).tag = 100
CASE 3
rb(os + 1).CAPTION = choice$(2)
rb(os + 2).CAPTION = choice$(3)
rb(os + 3).CAPTION = choice$(1)
rb(os + 3).tag = 100
CASE 4
rb(os + 1).CAPTION = choice$(3)
rb(os + 2).CAPTION = choice$(1)
rb(os + 3).CAPTION = choice$(2)
rb(os + 2).tag = 100
CASE 5
rb(os + 1).CAPTION = choice$(3)
rb(os + 2).CAPTION = choice$(2)
rb(os + 3).CAPTION = choice$(1)
rb(os + 3).tag = 100
END SELECT
NEXT i
END SUB
|