home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1991 / number4 / litquiz.pas < prev    next >
Pascal/Delphi Source File  |  1991-07-29  |  2KB  |  69 lines

  1. { This program is intended as an example only; }
  2. { it will not compile without the data units.  }
  3.  
  4. PROGRAM LitQuiz;
  5.  
  6. USES Crt, Dos, Easy, Med, Hard; {the last 3 contain only data}
  7.  
  8. TYPE
  9.   AQuestionPtr = ^AQuestion;
  10.   AQuestion    = record
  11.     QuestLine1 : string[66];
  12.     QuestLIne2 : string[66];
  13.     Choice1    : string[31];
  14.     Choice2    : string[31];
  15.     Choice3    : string[31];
  16.     Choice4    : string[31];
  17.     Comment1   : string[66];
  18.     Comment2   : string[66];
  19.     Answer     : byte;
  20.   END;
  21.   AQuestionArray = array[1..3,1..165] OF AQuestionPtr;
  22.  
  23. VAR
  24.   QuestPointer    : AQuestionArray;
  25.   Level           : byte;
  26.   QuestionNumber  : byte;
  27.   {-- more variables --}
  28.  
  29. {-------------- code start --------------}
  30. PROCEDURE Initialize;
  31. VAR
  32.   x, y : word;
  33.  
  34. BEGIN
  35.   x := 0;
  36.   FOR y := 1 TO 50 DO BEGIN
  37.     QuestPointer[1][y] :=
  38.     Ptr(Seg(EasyQuestions),Ofs(EasyQuestions)) + x;
  39.     Inc(x,397);          {size of AQuestion record}
  40.   END;
  41.   x := 0;
  42.   FOR y := 1 TO 163 DO BEGIN
  43.     QuestPointer[2][y] :=
  44.     Ptr(Seg(MedQuestions),Ofs(MedQuestions)) + x;
  45.     Inc(x,397);
  46.   END;
  47.   x := 0;
  48.   FOR y := 1 TO 137 DO BEGIN
  49.     QuestPointer[3][y] :=
  50.     Ptr(Seg(HardQuestions),Ofs(HardQuestions)) + x;
  51.     Inc(x,397);
  52.   END;
  53. END;
  54.  
  55. {----- main -----}
  56. BEGIN
  57.   Initialize;
  58.   {-- user selects Level from drop-down menu --}
  59.   {-- QuestionNumber is selected randomly --}
  60.  
  61.   WITH QuestPointer[Level][QuestionNumber]^ DO BEGIN
  62.     Writeln(QuestLine1);
  63.     Writeln(QuestLine2);
  64.     {and so on}
  65.   END;
  66.   {-- get answer --}
  67.   {-- rest of program --}
  68. END.
  69.