1: #include "stdio.h"
   2: #include "lrnref"
   3: 
   4: dounit()
   5: {
   6:     char tbuff[100];
   7: 
   8:     if (todo == 0)
   9:         return;
  10:     wrong = 0;
  11: retry:
  12:     start(todo);
  13:     sprintf(tbuff, "../../%s/L%s", sname, todo);    /* script = lesson */
  14:     scrin = fopen(tbuff, "r");
  15:     if (scrin == NULL) {
  16:         fprintf(stderr, "No script.\n");
  17:         wrapup(1);
  18:     }
  19: 
  20:     copy(0, scrin);
  21:     if (more == 0)
  22:         return;
  23:     copy(1, stdin);
  24:     if (more == 0)
  25:         return;
  26:     copy(0, scrin);
  27: 
  28:     if (comfile >= 0)
  29:         close(comfile);
  30:     wait(&didok);
  31:     didok = (status == 0);
  32:     if (!didok) {
  33:         wrong++;
  34:         printf("\nSorry, that's %snot right.  Do you want to try again?  ",
  35:             wrong > 1 ? "still " : "");
  36:         fflush(stdout);
  37:         for(;;) {
  38:             gets(tbuff);
  39:             if (tbuff[0] == 'y') {
  40:                 printf("Try the problem again.\n");
  41:                 fflush(stdout);
  42:                 goto retry;
  43:             } else if (strcmp(tbuff, "bye") == 0) {
  44:                 wrapup(1);
  45:             } else if (tbuff[0] == 'n') {
  46:                 wrong = 0;
  47:                 printf("\nOK.  Lesson %s (%d)\n", todo, speed);
  48:                 printf("Skipping to next lesson.\n\n");
  49:                 fflush(stdout);
  50:                 break;
  51:             } else {
  52:                 printf("Please type yes, no or bye:  ");
  53:                 fflush(stdout);
  54:             }
  55:         }
  56:     }
  57:     setdid(todo, sequence++);
  58: }

Defined functions

dounit defined in line 4; used 1 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 635
Valid CSS Valid XHTML 1.0 Strict