home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG121.ARC
/
FRENCH.ARK
/
FRENCH3.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-08-07
|
6KB
|
171 lines
begin (* givequiz *)
numwrong := 0;
writeln;
for k := 1 to numquizquestions do
begin
wrong[k] := false;
line := quizitems[order[k]];
decode(line,french,english,genderchar,error);
if error then
begin
writeln('FORMAT ERROR IN DATA:');
putstr(line,TRMOUT);
end
else
case quiz of
FRENCHTOENGLISH: begin
putstr(french,TRMOUT);
write('? ');
if getline(response,TRMIN,MAXSTR) then
begin
stripnl(response);
ucline(response);
answerok := match(response,english);
end
else answerok := false;
if not answerok then
begin
write(' NO ... '); putstr(english,TRMOUT);
writeln;
wrong[k] := true;
numwrong := numwrong + 1;
end
end;
ENGLISHTOFRENCH: begin
putstr(english,TRMOUT); write('? ');
if getline(response,TRMIN,MAXSTR) then
begin
stripnl(response);
ucline(response);
answerok := match(response,french);
end
else answerok := false;
if not answerok then
begin
write(' NO ... '); putstr(french,TRMOUT);
writeln;
wrong[k] := true;
numwrong := numwrong + 1;
end;
end;
GENDER: begin
putstr(french,TRMOUT); write('? ');
repeat
genderresponse := toupper(getc(c));
until genderresponse in [NEWLINE,ord('M'),ord('F')];
if genderresponse <> NEWLINE then writeln;
if genderresponse <> genderchar then
begin
if genderchar = ord('M') then
writeln(' NO ... MASCULIN')
else
writeln(' NO ... FEMININ');
wrong[k] := true;
numwrong := numwrong + 1;
end;
end;
end (* case *);
end (* for k *);
end (* givequiz *);
procedure givescore(numquestions,numwrong:integer);
begin
writeln;
writeln(numquestions,' ITEMS GIVEN, ',numwrong,' WRONG.');
if numquestions > 0 then
writeln('SCORE = ',(numquestions-numwrong)*100/numquestions:3:0,
' PERCENT.');
writeln;
end;
procedure getrepeatoption(var option:repeatoption);
var c :character;
j,k :integer;
begin
writeln('SELECT ONE:'); writeln;
writeln('1 - REPEAT WITH SAME WORD LIST');
writeln('2 - REPEAT ONLY MISSED ITEMS');
writeln('3 - NEW QUIZ');
writeln('4 - EXIT PROGRAM');
repeat
writeln;
write('? ');
c := getc(c);
until c in [ord('1')..ord('4')];
writeln;
option := SAMEWORDS;
j := c-ord('1');
for k := 1 to j do option := succ(option);
end;
procedure reinit(var option: repeatoption; wrong: booleanarray;
numwrong: integer; var numquizquestions: integer);
var
j,k :integer;
begin
if option = WRONGWORDS then
begin
j := 1;
for k:=1 to numquizquestions do
if wrong[k] then
begin
order[j] := order[k];
j := j + 1;
end;
numquizquestions := numwrong;
end
else if option = SAMEWORDS then
begin
numquizquestions := numquestions;
for k:=1 to numquestions do order[k] := k;
end;
if option in [WRONGWORDS,SAMEWORDS] then clrscr;
end;
begin (* main program *)
lowvideo; { Turbo intrinsic }
quit := false;
ioinit(2);
randomize; { Turbo intrinsic fn. }
while (not quit) do
begin
clrscr; { Turbo intrinsic fn. }
writeln('FRENCH VOCABULARY QUIZ PROGRAM');
writeln;
writeln('BY JON DART ... VERSION 1.9 (10-JUL-85)');
openfiles(nounfile,nonounfile);
getquiztype(quiz);
readsizes(numnouns,numnonouns);
if quiz = GENDER then
maxitems := numnouns
else
maxitems := numnouns + numnonouns;
getnumquestions(quiz,numquestions,maxitems);
if numquestions > 0 then
begin
fillarray(quiz,quizitems,numquestions,
numnouns,numnonouns,maxitems);
for k:=1 to numquestions do order[k] := k;
numquizquestions := numquestions;
repeat
scramble(order,numquizquestions);
givequiz(quiz,order,numquizquestions,quizitems,
wrong,numwrong);
givescore(numquizquestions,numwrong);
getrepeatoption(option);
reinit(option,wrong,numwrong,
numquizquestions);
until option in [NEWQUIZ,EXIT];
quit := option = EXIT;
end;
pclose(nounfile);
pclose(nonounfile);
end;
end.