rem GENERALIZED LIST REVIEW PROGRAM--BY JACK BURKIG
rem WRITTEN IN HISOFT BASIC 9/18/89

defint a-z
library "gemaes"
dim data$(10)
dim e$(100),s$(100),a(100),b(100),c(100)
introduction:
cls
print "LIST REVIEW PROGRAM by JACK BURKIG. PRESS CONTROL C"
print "TO QUIT, ANY OTHER KEY TO CONTINUE. THEN CLICK ON SUBJECT"
print "TO REVIEW AND THEN ON LIST TO REVIEW"
pause

get_cat_data:
cls
fsel_input "A:\*.DAT",p$,ok 'call file selector subj.data
if ok=1 then 'conditional required for fsel to work
open "A:\"+ p$ for input as #2
input #2,k
j=1
while j<k+1
input #2, data$(j)
incr j
wend
close #2
end if
if ok=0 then goto introduction

main:
gosub getfile
if ok=0 then goto introduction
for j=1 to n : b(j)=1 : next j: rem all words on
cls
print "PRESS ANY KEY TO START REVIEW "
pause
cls : f=0 : rem randomize flag off
print "RANDOMIZE LIST? y,n  "

yesorno
if a$="y" then
f=1
gosub mixup
end if
scoreonoff:
cls
print "DO YOU WANT TO KEEP SCORE? y,n"
yesorno
if a$="y" then
scoreflag=1
end if
if scoreflag=1 then goto review1
if a$="n" then
scoreflag=0
end if
if scoreflag=0 then goto review1
if a$<>"y" or a$<>"n" then goto scoreonoff

review1:
cls
print "WHICH CATEGORY FIRST?"
print "TYPE 1 TO SELECT "; data$(1); " OR"
print "TYPE 2 TO SELECT "; data$(2)
input " ",order
if order=1 then
name1$=data$(1)
name2$=data$(2)
elseif order=2 then
name1$=data$(2)
name2$=data$(1)
else goto review1
end if
review2:
score=0 : active=n: rem initialize score and # of words
for j=1 to n
if b(j)=0  then active=active -1 
if b(j)= 0 then goto skipthis 
v=j : rem ordered presentation
if f=1 then v=c(j) 
if order=1 then
first$=e$(v)
second$=s$(v)
elseif order=2 then
first$=s$(v)
second$=e$(v)
end if
cls : gosub message
print name1$; " "; first$ : print
print "TYPE ";name2$
input " " , q$
if q$=second$ then score=score+1
if q$=second$ then
print "CORRECT!"
elseif q$<>second$ and scoreflag=1 then
print "WRONG!"
end if
print
 
print "THE ANSWER IS: ";second$
print
print "TO OMIT THIS ENTRY FROM REVIEW PRESS ESC"
print    "OTHERWISE PRESS RETURN"
pause
if a$=chr$(27) then b(j)=0
skipthis:
next j
beep: beep: beep
print "END OF LIST"
cls
if scoreflag=1 then gosub keepscore

print
print "MORE REVIEW OF SAME LIST? y,n"
yesorno
if a$="n" then goto shortlist
print "SAME ORDER? y,n"
yesorno
if a$="y" then goto scoreonoff
f=1 : gosub mixup
goto scoreonoff

shortlist:
setcount =0
for j=1 to n
if b(j)=1 then
incr setcount
end if
next j
if setcount <n then 
cls
color 2
print "SAVE THE SHORTENED LIST? y,n"
color 1
yesorno
end if
if a$="n" then goto anotherlist
gosub needreview
cls
goto anotherlist

anotherlist:
print "LOAD ANOTHER LIST? y,n"
yesorno
if a$="n" then goto fini
goto main

fini:
end

getfile:
cls
fsel_input "A:\*." + data$(7), n$, ok
if ok=1 then 'conditional reqd. for fsel to work
open "A:\"+ n$ for input as #1
input #1,n : rem compiler will not accept i-1 or (i-1)
redim e$(n),s$(n),a(n),b(n),c(n) 'a,b,c used to randomize indices
j=1
while j<n+1
input #1, e$(j)
incr j
wend
j=1
while j<n+1
input #1, s$(j)
incr j
wend
close #1:i=n
end if
return

message:
locate 15,1,1
print data$(3)
print data$(4)
print data$(5)
print data$(6)
locate 1,1,1
return

mixup:
for j=1 to n: a(j)=j
next j
cls
print "RANDOMIZING!!!"
m=n
cls
seed%=timer
randomize seed%
for j=1 to n 
q=int(rnd(seed%)*m)+1 
c(j)=a(q) 
rem assign random incices in order of presentation
if q=m then goto lastone
for r=q to m-1: a(r)=a(r+1) : next r 
rem take a(q) out of list
lastone:
m=m-1 : rem reduce range of random #
next j
return

sub pause
shared a$
rem the shared command required so a$ can be used outside subroutine
repeat wait
a$=inkey$
if a$<>"" then
exit wait
end if
end repeat wait
end sub

keepscore:
cls
pc=score*100/active rem percent score
print "SCORE= "; score; " OUT OF " ;active
print      "= ";pc;"%"
return

sub yesorno rem wait for y or n keystroke
shared a$
a$=""
do until a$="y" or a$="Y" or a$="n" or a$="N"
pause
loop
end sub

needreview: rem save shortened list
dim keep(n)
count=0  'initialize count
for j=1 to n  'routine to screen out deselected items
if b(j)=1 then
incr count
keep(count)=j
end if
next j

changename: 'PUT X IN AS 3'D CHAR OF FILENAME
l=len (n$) -3
n$=left$(n$,2) +"X" +right$(n$,l)

open "A:\" + n$ for output as #1
write #1,count 'length of shortened list
j=1  'initialize step thru
while j< count +1
write #1, e$(keep(j))
incr j
wend

j=1
while j<count+1
write #1, s$(keep(j))
incr j
wend
close #1
return
