home *** CD-ROM | disk | FTP | other *** search
- { This program is intended as an example only; }
- { it will not compile without the data units. }
-
- PROGRAM LitQuiz;
-
- USES Crt, Dos, Easy, Med, Hard; {the last 3 contain only data}
-
- TYPE
- AQuestionPtr = ^AQuestion;
- AQuestion = record
- QuestLine1 : string[66];
- QuestLIne2 : string[66];
- Choice1 : string[31];
- Choice2 : string[31];
- Choice3 : string[31];
- Choice4 : string[31];
- Comment1 : string[66];
- Comment2 : string[66];
- Answer : byte;
- END;
- AQuestionArray = array[1..3,1..165] OF AQuestionPtr;
-
- VAR
- QuestPointer : AQuestionArray;
- Level : byte;
- QuestionNumber : byte;
- {-- more variables --}
-
- {-------------- code start --------------}
- PROCEDURE Initialize;
- VAR
- x, y : word;
-
- BEGIN
- x := 0;
- FOR y := 1 TO 50 DO BEGIN
- QuestPointer[1][y] :=
- Ptr(Seg(EasyQuestions),Ofs(EasyQuestions)) + x;
- Inc(x,397); {size of AQuestion record}
- END;
- x := 0;
- FOR y := 1 TO 163 DO BEGIN
- QuestPointer[2][y] :=
- Ptr(Seg(MedQuestions),Ofs(MedQuestions)) + x;
- Inc(x,397);
- END;
- x := 0;
- FOR y := 1 TO 137 DO BEGIN
- QuestPointer[3][y] :=
- Ptr(Seg(HardQuestions),Ofs(HardQuestions)) + x;
- Inc(x,397);
- END;
- END;
-
- {----- main -----}
- BEGIN
- Initialize;
- {-- user selects Level from drop-down menu --}
- {-- QuestionNumber is selected randomly --}
-
- WITH QuestPointer[Level][QuestionNumber]^ DO BEGIN
- Writeln(QuestLine1);
- Writeln(QuestLine2);
- {and so on}
- END;
- {-- get answer --}
- {-- rest of program --}
- END.
-