home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / EDUCATIO / STAGES12.ZIP / PRINTS2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-21  |  30.0 KB  |  1,088 lines

  1. #include "header.h"
  2. #include "file.h"
  3.  
  4. /************************************************************************/
  5. /**    print routines: part 2                           **/
  6. /************************************************************************/
  7. /* contains:    printusrcells
  8.            printresulthdr
  9.         printresults
  10.         prresF
  11.         prresB
  12.         printepi
  13.         getcellname
  14.         printexit
  15.         printHARDCOPY
  16.         printFILECOPY
  17.         printCycleTime
  18.         printline
  19.         printresHARD
  20. */
  21.  
  22. static int printresulthdr(int fileq);
  23. static int prresF(char *daystr, int *cell, int *len,
  24.           char *cellstr, int *ok, int okcell, int oknum,
  25.           int endspot, char *opstr1, char *opstr2);
  26. static int prresB(char *daystr, int *cell, int *len,
  27.           char *cellstr, int *ok, int okcell, int oknum,
  28.           int endspot, char *opstr1, char *opstr2);
  29. static int getcellname(int i, int *cell, char *cellname,
  30.                char dir, int endspot);
  31.  
  32.  
  33. /********************************/
  34. /*     function: printusrcells    */
  35. /********************************/
  36. /* prints out a list of the user-entered input cells
  37.    (interactive mode only) */
  38. printusrcells (cellstrs, trials)
  39.   char cellstrs[][MAXIPLEN];
  40.   int trials;
  41. {
  42.   int i;
  43. #if PC
  44.   int j;
  45. #endif
  46.  
  47.   if (! trials)
  48.     return(0);
  49.  
  50. #if PC
  51.   j = 1;
  52.   clrscr1(3);
  53.   gotoxy(4, j++);
  54.   cprintf("These are the input cells:");
  55.   gotoxy(6, j);
  56.   if (HARDCOPY) {
  57.     fprintf(stdprn, "\tThese are the input cells:");
  58.     fprintf(stdprn, "\n\t\t");
  59.   }
  60. #else
  61.   printf("\tThese are the input cells:\n\t\t");
  62. #endif
  63.   if (FILEq && FILECOPY)
  64.     fprintf(fpout, "\tThese are the input cells:\n\t\t");
  65.  
  66.   for ( i=0; i<trials; i++ ) {
  67. #if PC
  68.     if ((j >= MSGLNS) && (wherex() >= 65)) {
  69.       /* end of last line of window reached */
  70.       hitreturn(3);
  71.       clrscr1(3);
  72.       j = 1;
  73.       gotoxy(4, j++);
  74.       cprintf("These are the input cells:");
  75.       gotoxy(6, j);
  76.     } /* if j */
  77.  
  78.     if (i && (wherex() >= 65)) {  /* if xpos near eol, start new ln */
  79. #else
  80.     if (i && ((i % 5)==0)) {    /* after 5 cells, start new line */
  81. #endif
  82. #if PC
  83.       gotoxy(6, ++j);
  84.       if (HARDCOPY)
  85.     fprintf(stdprn, "\n\t\t");
  86. #else
  87.       printf("\n\t\t");
  88. #endif
  89.       if (FILEq && FILECOPY)
  90.     fprintf(fpout, "\n\t\t");
  91.     } /* if time for newline */
  92.  
  93. #if PC
  94.     cprintf("%s   ", cellstrs[i]);
  95.     if (HARDCOPY)
  96.       fprintf(stdprn, "%s   ", cellstrs[i]);
  97. #else
  98.     printf("%s   ", cellstrs[i]);
  99. #endif
  100.     if (FILEq && FILECOPY)
  101.       fprintf(fpout, "%s   ", cellstrs[i]);
  102.   } /* for */
  103.  
  104. #if PC
  105.   if (HARDCOPY)
  106.     fprintf(stdprn, "\n");
  107. #else
  108.   printf("\n");
  109. #endif
  110.   if (FILEq && FILECOPY)
  111.     fprintf(fpout, "\n");
  112.   return(0);
  113. } /* printusrcells */
  114.  
  115. /********************************/
  116. /*     function: printresulthdr    */
  117. /********************************/
  118. /* static means that this function is only used within this file
  119.    saves space in the executable file */
  120. static printresulthdr (fileq)
  121.   int fileq;
  122. {
  123. #if PC
  124.   clrscr1(3);
  125.   clrscr1(2);
  126.   clrscr1(1);
  127.   gotoxy(2, 1);
  128.   cprintf("Init cell     Days%s  1st third", tab);
  129.   cprintf("%s  2nd third%s  3rd third", tab, tab);
  130.   gotoxy(2, 2);
  131.   printline(0, LNWID, '=');
  132.   if (HARDCOPY) {
  133.     fprintf(stdprn, "\nInit cell     Days%s  1st third", tab);
  134.     fprintf(stdprn, "%s  2nd third%s  3rd third\n", tab, tab);
  135.     printline(2, LNWID, '=');
  136.   }
  137.   fprintf(tmpfp, "\nInit cell     Days%s  1st third", tab);
  138.   fprintf(tmpfp, "%s  2nd third%s  3rd third\n", tab, tab);
  139.   printline(5, LNWID, '=');
  140. #else
  141.   printf("\nInit cell     Days%s  1st third", tab);
  142.   printf("%s  2nd third%s  3rd third\n", tab, tab);
  143.   printline(0, LNWID, '=');
  144. #endif
  145.   if (FILEq && FILECOPY)
  146.     if (fileq) {
  147.       fprintf(fpout, "\nInit cell     Days%s  1st third", tab);
  148.       fprintf(fpout, "%s  2nd third%s  3rd third\n", tab, tab);
  149.       printline(1, LNWID, '=');
  150.     }
  151.   return(0);
  152. } /* printresulthdr */
  153.  
  154. /********************************/
  155. /*     function: printresults    */
  156. /********************************/
  157. /*  the functions printresults, prresF and prresB all use a temporary
  158.     output file into which they write their output.
  159.     then if the user decides to print the output on the printer,
  160.     we just dump the file to the printer. */
  161. printresults (dir, days, daystr, cell, cellstr, ok, okcell, oknum,
  162.           endspot, opstr, oncep, epip, opstr1, opstr2)
  163.   char dir;        /* direction: F or B        */
  164.   double days;        /* used if oknum=1        */
  165.   char *daystr;        /* used if oknum=0        */
  166.   int *cell;        /* used if okcell=1: cells reached */
  167.   char *cellstr;    /* used if okcell=0: init cell    */
  168.   int *ok;        /* move ok? from the 4 pts in init stage */
  169.   int okcell, oknum;    /* cell/days valid?        */
  170.   int endspot;        /* which 3d of stage did move end in? */
  171.   char *opstr;        /* err string if move went out of bounds */
  172.   int *oncep;        /* controls outputhdr printing    */
  173.   int *epip;        /* controls printepi printing    */
  174.   char *opstr1,
  175.        *opstr2;        /* strs for when cell ejac but still tracking stgs */
  176. {
  177.   int len[4];        /* CellName lengths    */
  178.   int i;        /* iteration var    */
  179. #if PC
  180.   static int j=1;       /* j = y-pos in the output window (STATIC VAR!) */
  181.   int lines;        /* # lines in output window this output will need */
  182. #endif
  183.  
  184. /* format:
  185. init cell<5>days<10>1st third<10>2nd third<10>3rd third
  186.         1  1    2       3    4       5    6       7
  187. 1    9   5  8    9       7    8       6    7       5   */
  188.   if (! *oncep) {
  189. #if PC
  190.     makedisplay();
  191.     topline(" Stages Output ");
  192.     clrscr1(3);
  193.     clrscr1(1);
  194.     j = 3;
  195. #endif
  196.     *oncep = 1;
  197.     printresulthdr(1);
  198.   } /* if ! oncep */
  199.  
  200. #if PC
  201.   /* determine how many output lines this cell/day input will require;
  202.      if cell ok, only need 2 o/p lines (1 for data, 1 for underline) */
  203.   if ((ok[0] != 1) || (ok[1] !=1 ) || (ok[2] !=1 ) || (ok[3] != 1)) {
  204.     /* final cell epididymis/pre-entry: need 3 extra lines */
  205.     lines = 5;
  206.   } else
  207.     lines = 2;
  208.  
  209.   if (j >= (OUTPUTLNS-lines)) {
  210.     hitreturn(1);
  211.     clrscr1(1);
  212.     printresulthdr(0);
  213.     j = 3;
  214.   }
  215.   outputwin();
  216.   gotoxy(2, j++);
  217. #endif
  218.  
  219.   if (oknum) {
  220. #if PC
  221.     cprintf(" %6s   %8.4lf", cellstr, days);
  222.     if (HARDCOPY)
  223.       fprintf(stdprn, " %6s   %8.4lf", cellstr, days);
  224.     fprintf(tmpfp, " %6s   %8.4lf", cellstr, days);
  225. #else
  226.     printf(" %6s   %8.4lf", cellstr, days);
  227. #endif
  228.     if (FILEq && FILECOPY)
  229.       fprintf(fpout, " %6s   %8.4lf", cellstr, days);
  230.   } else {    /* bad i/p num syntax */
  231. #if PC
  232.     cprintf(" %6s   %8s", cellstr, daystr);
  233.     if (HARDCOPY)
  234.       fprintf(stdprn, " %6s   %8s", cellstr, daystr);
  235.     fprintf(tmpfp, " %6s   %8s", cellstr, daystr);
  236. #else
  237.     printf(" %6s   %8s", cellstr, daystr);
  238. #endif
  239.     if (FILEq && FILECOPY)
  240.       fprintf(fpout, " %6s   %8s", cellstr, daystr);
  241.   } /* if oknum */
  242.  
  243.   for ( i=0; i<4; i++ ) {
  244.     if (ok[i]==1) {
  245.       len[i] = strlen(CellNames[cell[i]]);
  246.     } else {
  247.       /* this is because, if ok!=1, then cell[i] = stage reached */
  248.       if (cell[i] < 10)
  249.     /* 1-digit stage */
  250.     len[i] = 1;
  251.       else
  252.     /* 2-digit stage: don't expect to see > 100 stages in the cycle */
  253.     len[i] = 2;
  254.     }
  255.   } /* for */
  256.  
  257.   switch (dir) {
  258.   case 'F':
  259.     prresF(daystr, cell, len, cellstr, ok, okcell, oknum,
  260.        endspot, opstr1, opstr2);
  261.     break;
  262.   case 'B':
  263.     prresB(daystr, cell, len, cellstr, ok, okcell, oknum,
  264.        endspot, opstr1, opstr2);
  265.     break;
  266.   default:    /* shouldn't! */
  267. #if PC
  268.     clrscr1(1);
  269.     gotoxy(1, 5);
  270.     cprintf("%sprintresults: Internal error, dir=%d", tab2, dir);
  271.     gotoxy(1, 7);
  272.     cprintf("%s                Sorry, aborting.", tab2);
  273. #endif
  274.     printexit(21);
  275.     break;
  276.   } /* switch */
  277. #if PC
  278.   gotoxy(2, j++);
  279.   if (HARDCOPY)
  280.     fprintf(stdprn, "\n");
  281.   fprintf(tmpfp, "\n");
  282. #else
  283.   printf("\n");
  284. #endif
  285.   if (FILEq && FILECOPY)
  286.     fprintf(fpout, "\n");
  287.  
  288.   if ((ok[0] != 1) || (ok[1] !=1 ) || (ok[2] !=1 ) || (ok[3] != 1)) {
  289. #if PC
  290.     cprintf("  (%s)\n", opstr);
  291.     gotoxy(2, j++);
  292.     cprintf("%s", opstr1);
  293.     gotoxy(2, j++);
  294.     cprintf("%s", opstr2);
  295.     gotoxy(2, j++);
  296.     if (HARDCOPY) {
  297.       fprintf(stdprn, "  (%s)\n", opstr);
  298.       fprintf(stdprn, "%s\n", opstr1);
  299.       fprintf(stdprn, "%s\n", opstr2);
  300.     }
  301.     fprintf(tmpfp, " (%s)\n", opstr);
  302. #else
  303.     printf("  (%s)\n", opstr);
  304.     printf("%s\n", opstr1);
  305.     printf("%s\n", opstr2);
  306. #endif
  307.     if (FILEq && FILECOPY) {
  308.       fprintf(fpout, "  (%s)\n", opstr);
  309.       fprintf(fpout, "%s\n", opstr1);
  310.       fprintf(fpout, "%s\n", opstr2);
  311.     }
  312.   } /* if */
  313.  
  314.   /* set *epip if any cell went into epididymis */
  315.   if ((ok[0]==2) || (ok[1]==2) || (ok[2]==2) || (ok[3]==2))
  316.     *epip = 1;
  317.   return(0);
  318. } /* printresults */
  319.  
  320. /********************************/
  321. /*     function: prresF        */
  322. /********************************/
  323. /* static means that this function is only used within this file
  324.    saves space in the executable file */
  325. static prresF (daystr, cell, len, cellstr, ok, okcell, oknum,
  326.            endspot, opstr1, opstr2)
  327.   char *daystr;        /* used if oknum=0         */
  328.   int *cell;        /* cell seq #s of cells reached    */
  329.   int *len;        /* lengths of cellnames reached    */
  330.   char *cellstr;    /* name of initial cellname    */
  331.   int *ok;        /* move ok? from the 4 pts in init stage */
  332.   int okcell, oknum;    /* boolean: cell/days valid?    */
  333.   int endspot;        /* which 3rd of stage did move end in? */
  334.   /* strings used when cell has been ejact, but still want to track stages */
  335.   char *opstr1, *opstr2;
  336. {
  337.   int i, val, splen;
  338.   char spstr[MAXLEN];        /* unspec. space string    */
  339.   char opstr[MAXLEN];
  340.   char tmpstr[MAXLEN];        /* tmpstr & tmpstr1 used if case 11 if both */
  341.   char tmpstr1[MAXLEN];        /* cells reached are multicells */
  342.  
  343. #if (DEBUG > 4)
  344. #if PC
  345.   clrscr1(3);
  346.   gotoxy(1, 1);
  347.   cprintf("%sprresF:  entering", tab);
  348.   hitreturn(1);
  349. #else
  350.   printf("\tprresF:  entering\n");
  351. #endif
  352. #endif
  353.  
  354.   sprintf(opstr1, " After spermiation, younger cells would have ");
  355.   strcat(opstr1, "tracked through to the");
  356.   sprintf(opstr2, " following stages:");
  357.  
  358.   for ( i=0; i<3; i++ ) {    /* 3 fields to print out */
  359.  
  360.     if (! okcell) {        /* bad cellstr syntax */
  361.       sprintf(opstr, "       %s:  Invalid cell syntax <%s>",
  362.           ERRSTR, cellstr);
  363. #if PC
  364.       cprintf("%s", opstr);
  365.       if (HARDCOPY)
  366.     fprintf(stdprn, "%s", opstr);
  367.       fprintf(tmpfp, "%s", opstr);
  368. #else
  369.       printf("%s", opstr);
  370. #endif
  371.       if (FILEq && FILECOPY)
  372.     fprintf(fpout, "%s", opstr);
  373.       return(0);
  374.     } /* !okcell */
  375.  
  376.     if (! oknum) {        /* bad number syntax */
  377.       sprintf(opstr, "       %s:  Invalid days syntax <%s>",
  378.           ERRSTR, daystr);
  379. #if PC
  380.       cprintf("%s", opstr);
  381.       if (HARDCOPY)
  382.     fprintf(stdprn, "%s", opstr);
  383.       fprintf(tmpfp, "%s", opstr);
  384. #else
  385.       printf("%s", opstr);
  386. #endif
  387.       if (FILEq && FILECOPY)
  388.     fprintf(fpout, "%s", opstr);
  389.       return(0);
  390.     } /* if !oknum */
  391.  
  392.     val = (10 * ok[i]) + ok[i+1];
  393.     /* possible values for val: (since ok = 0:ejac  1:ok  2:epi)
  394.  
  395.         cell[i]    cell[i+1]    val
  396.        ==================================
  397.            ok       ok        11
  398.            ok      epi        12
  399.            ok    ejac        10
  400.            epi      epi        22
  401.            epi     ejac        20
  402.           ejac   ejac         0
  403.     */
  404.     switch (val) {
  405.  
  406.     case 0:    /* ejac */
  407.       /* 9 for "Ejaculate" */
  408.       splen = 19 - 9;
  409.       makespstr(spstr, splen);
  410. #if PC
  411.       cprintf("%sEjaculate", spstr);
  412.       if (HARDCOPY)
  413.     fprintf(stdprn, "%sEjaculate", spstr);
  414.       fprintf(tmpfp, "%sEjaculate", spstr);
  415. #else
  416.       printf("%sEjaculate", spstr);
  417. #endif
  418.       if (FILEq && FILECOPY)
  419.     fprintf(fpout, "%sEjaculate", spstr);
  420.  
  421.       if (cell[i] == cell[i+1]) {
  422.     splen = 19 - len[i];
  423.     makespstr(spstr, splen);
  424.     sprintf(tmpstr, "%s%d", spstr, cell[i]);
  425.     strcat(opstr2, tmpstr);
  426.       } else {
  427.     splen = 19 - (len[i] + len[i+1] + 1);    /* +1 for "/" */
  428.     makespstr(spstr, splen);
  429.     sprintf(tmpstr, "%s%d/%d", spstr, cell[i], cell[i+1]);
  430.     strcat(opstr2, tmpstr);
  431.       } /* if */
  432.       break;
  433.  
  434.     case 10:    /* ok ejac */
  435.       /* get correct cellname */
  436.       getcellname(i, cell, tmpstr, 'F', endspot);
  437.  
  438.       /* +5 for "Ejact"; +1 for '/' */
  439.       splen = 19 - (strlen(tmpstr) + 5 + 1);
  440.       makespstr(spstr, splen);
  441. #if PC
  442.       cprintf("%s%s/Ejact", spstr, tmpstr);
  443.       if (HARDCOPY)
  444.     fprintf(stdprn, "%s%s/Ejact", spstr, tmpstr);
  445.       fprintf(tmpfp, "%s%s/Ejact", spstr, tmpstr);
  446. #else
  447.       printf("%s%s/Ejact", spstr, tmpstr);
  448. #endif
  449.       if (FILEq && FILECOPY)
  450.     fprintf(fpout, "%s%s/Ejact", spstr, tmpstr);
  451.  
  452.       /* cell[i+1] has stage where younger cell would've ended */
  453.       splen = 19 - (len[i+1] + 1);    /* +1 for '/' */
  454.       makespstr(spstr, splen);
  455.       sprintf(tmpstr, "%s/%d", spstr, cell[i+1]);
  456.       strcat(opstr2, tmpstr);
  457.       break;
  458.  
  459.     case 11:    /* ok ok */
  460.       if (strcmp(CellNames[cell[i]], CellNames[cell[i+1]])==0) {
  461.     /* same cell reached from each end of third */
  462.     /* get correct cell name */
  463.     getcellname(i, cell, tmpstr, 'F', endspot);
  464. #if PC
  465.     cprintf("%s %10s", tab, tmpstr);
  466.     if (HARDCOPY)
  467.       fprintf(stdprn, "%s %10s", tab, tmpstr);
  468.     fprintf(tmpfp, "%s %10s", tab, tmpstr);
  469. #else
  470.     printf("%s %10s", tab, tmpstr);
  471. #endif
  472.     if (FILEq && FILECOPY)
  473.       fprintf(fpout, "%s %10s", tab, tmpstr);
  474.  
  475.       } else {
  476.     /* different cells reached from each end of third */
  477.     /* get correct cell names */
  478.     getcellname(i, cell, tmpstr, 'F', endspot);
  479.     getcellname(i+1, cell, tmpstr1, 'F', endspot);
  480.  
  481.     splen = 19 - (strlen(tmpstr) + strlen(tmpstr1) + 1);  /* +1 for '/' */
  482.     makespstr(spstr, splen);
  483. #if PC
  484.     cprintf("%s%s/%s", spstr, tmpstr, tmpstr1);
  485.     if (HARDCOPY)
  486.       fprintf(stdprn, "%s%s/%s", spstr, tmpstr, tmpstr1);
  487.     fprintf(tmpfp, "%s%s/%s", spstr, tmpstr, tmpstr1);
  488. #else
  489.     printf("%s%s/%s", spstr, tmpstr, tmpstr1);
  490. #endif
  491.     if (FILEq && FILECOPY)
  492.       fprintf(fpout, "%s%s/%s", spstr, tmpstr, tmpstr1);
  493.       } /* else */
  494.  
  495.       makespstr(spstr, 19);
  496.       strcat(opstr2, spstr);
  497.       break;
  498.  
  499.     case 12:    /* ok epi */
  500.       /* get correct cell name */
  501.       getcellname(i, cell, tmpstr, 'F', endspot);
  502.  
  503.       /* +10 for "Epididymis", +1 for "/" */
  504.       splen = 19 - (strlen(tmpstr) + 10 + 1);
  505.       makespstr(spstr, splen);
  506.  
  507. #if PC
  508.       cprintf("%s%s/Epididymis", spstr, tmpstr);
  509.       if (HARDCOPY)
  510.     fprintf(stdprn, "%s%s/Epididymis", spstr, tmpstr);
  511.       fprintf(tmpfp, "%s%s/Epididymis", spstr, tmpstr);
  512. #else
  513.       printf("%s%s/Epididymis", spstr, tmpstr);
  514. #endif
  515.       if (FILEq && FILECOPY)
  516.     fprintf(fpout, "%s%s/Epididymis", spstr, tmpstr);
  517.  
  518.       /* cell[i+1] has stage where younger cells would've ended */
  519.       splen = 19 - (len[i+1] + 1);        /* +1 for '/' */
  520.       makespstr(spstr, splen);
  521.       sprintf(tmpstr, "%s/%d", spstr, cell[i+1]);
  522.       strcat(opstr2, tmpstr);
  523.       break;
  524.  
  525.     case 20:    /* epi ejac */
  526.       /* 16 for "Epididymis/Ejact" */
  527.       splen = 19 - 16;
  528.       makespstr(spstr, splen);
  529. #if PC
  530.       cprintf("%sEpididymis/Ejact", spstr);
  531.       if (HARDCOPY)
  532.     fprintf(stdprn, "%sEpididymis/Ejact", spstr);
  533.       fprintf(tmpfp, "%sEpididymis/Ejact", spstr);
  534. #else
  535.       printf("%sEpididymis/Ejact", spstr);
  536. #endif
  537.       if (FILEq && FILECOPY)
  538.     fprintf(fpout, "%sEpididymis/Ejact", spstr);
  539.  
  540.       /* both cell[i] and cell[i+1] hold stages where younger cells would've
  541.      ended */
  542.       if (cell[i] == cell[i+1]) {
  543.     /* reached stages are the same */
  544.     splen = 19 - len[i];
  545.     makespstr(spstr, splen);
  546.     sprintf(tmpstr, "%s%d", spstr, cell[i]);
  547.     strcat(opstr2, tmpstr);
  548.       } else {
  549.     /* reached stages differ */
  550.     splen = 19 - (len[i] + len[i+1] + 1);    /* +1 for '/' */
  551.     makespstr(spstr, splen);
  552.     sprintf(tmpstr, "%s%d/%d", spstr, cell[i], cell[i+1]);
  553.     strcat(opstr2, tmpstr);
  554.       }
  555.       break;
  556.  
  557.     case 22:    /* epi */
  558.       /* 10 for "Epididymis" */
  559.       splen = 19 - 10;
  560.       makespstr(spstr, splen);
  561. #if PC
  562.       cprintf("%sEpididymis", spstr);
  563.       if (HARDCOPY)
  564.     fprintf(stdprn, "%sEpididymis", spstr);
  565.       fprintf(tmpfp, "%sEpididymis", spstr);
  566. #else
  567.       printf("%sEpididymis", spstr);
  568. #endif
  569.       if (FILEq && FILECOPY)
  570.     fprintf(fpout, "%sEpididymis", spstr);
  571.  
  572.       /* both cell[i] and cell[i+1] hold stages where younger cells
  573.      would've ended */
  574.       if (cell[i] == cell[i+1]) {
  575.     /* whole stage epididymised, but reached stages are the same */
  576.     splen = 19 - len[i];
  577.     makespstr(spstr, splen);
  578.     sprintf(tmpstr, "%s%d", spstr, cell[i]);
  579.     strcat(opstr2, tmpstr);
  580.       } else {
  581.     /* whole stage epididymised, but reached stages differ */
  582.     splen = 19 - (len[i] + len[i+1] + 1);    /* +1 for '/' */
  583.     makespstr(spstr, splen);
  584.     sprintf(tmpstr, "%s%d/%d", spstr, cell[i], cell[i+1]);
  585.     strcat(opstr2, tmpstr);
  586.       }
  587.       break;
  588.  
  589.     default:    /* shouldn't happen */
  590. #if PC
  591.       clrscr1(1);
  592.       gotoxy(1, 5);
  593.       cprintf("%s<prresF>: Internal error, val=%d", tab2, val);
  594.       gotoxy(1, 7);
  595.       cprintf("%s          Sorry, aborting.", tab2);
  596. #endif
  597.       printexit(19);
  598.       break;
  599.     } /* switch */
  600.   } /* for i */
  601. #if (DEBUG > 4)
  602. #if PC
  603.   clrscr1(3);
  604.   gotoxy(1, 1);
  605.   cprintf("%sprresF:  leaving prresF", tab);
  606.   hitreturn(1);
  607. #else
  608.   printf("\tprresF:  leaving prresF\n");
  609. #endif
  610. #endif
  611.   return(0);
  612. } /* prresF */
  613.  
  614. /********************************/
  615. /*     function: prresB        */
  616. /********************************/
  617. /* static means that this function is only used within this file
  618.    saves space in the executable file */
  619. static prresB (daystr, cell, len, cellstr, ok, okcell, oknum,
  620.            endspot, opstr1, opstr2)
  621.   char *daystr;        /* used if oknum=0         */
  622.   int *cell;        /* cell seq #s of cells reached    */
  623.   int *len;        /* lengths of cellnames reached    */
  624.   char *cellstr;    /* name of initial cellname    */
  625.   int *ok;        /* move ok? from the 4 pts in init stage */
  626.   int okcell, oknum;    /* boolean: cell/days valid?    */
  627.   int endspot;        /* which 3rd of stage did move end in? */
  628.   /* strings used when cell has been ejact, but still want to track stages */
  629.   char *opstr1, *opstr2;
  630. {
  631.   int i, val, splen;
  632.   char spstr[MAXLEN];        /* space string, unspec. len    */
  633.   char opstr[MAXLEN];
  634.   char tmpstr[MAXLEN];        /* tmpstr & tmpstr1 used if case 11 if both */
  635.   char tmpstr1[MAXLEN];        /* cells reached are multicells */
  636.   char tab7[8];            /* 7 spaces        */
  637.  
  638.   strcpy(tab7, "       ");
  639.   sprintf(opstr1, " Prior to entering spermatogenesis, cells would ");
  640.   strcat(opstr1, "have come from the");
  641.   sprintf(opstr2, " following stages:");
  642.  
  643.   for ( i=0; i<3; i++ ) {    /* 3 fields to print out */
  644.  
  645.    if (! okcell) {        /* bad cellstr syntax */
  646.       sprintf(opstr, "       %s:  Invalid cell syntax <%s>",
  647.           ERRSTR, cellstr);
  648. #if PC
  649.       cprintf("%s", opstr);
  650.       if (HARDCOPY)
  651.     fprintf(stdprn, "%s", opstr);
  652.       fprintf(tmpfp, "%s", opstr);
  653. #else
  654.       printf("%s", opstr);
  655. #endif
  656.       if (FILEq && FILECOPY)
  657.     fprintf(fpout, "%s", opstr);
  658.       return(0);
  659.     } /* !okcell */
  660.  
  661.     if (! oknum) {        /* bad number syntax */
  662.       sprintf(opstr, "       %s:  Invalid days syntax <%s>",
  663.           ERRSTR, daystr);
  664. #if PC
  665.       cprintf("%s", opstr);
  666.       if (HARDCOPY)
  667.     fprintf(stdprn, "%s", opstr);
  668.       fprintf(tmpfp, "%s", opstr);
  669. #else
  670.       printf("%s", opstr);
  671. #endif
  672.       if (FILEq && FILECOPY)
  673.     fprintf(fpout, "%s", opstr);
  674.       return(0);
  675.     } /* !oknum */
  676.  
  677.     val = (10 * ok[i]) + ok[i+1];
  678.     /* possible values for val: (since ok = 0:pre  1:ok)
  679.  
  680.         cell[i]    cell[i+1]    val
  681.        ==================================
  682.            ok       ok        11
  683.            pre       ok         1
  684.            pre    pre         0
  685.     */
  686.     switch (val) {
  687.  
  688.     case 0:    /* pre-entry from end of third */
  689. #if PC
  690.       cprintf("%s   Pre-Entry", tab7);
  691.       if (HARDCOPY)
  692.     fprintf(stdprn, "%s   Pre-Entry", tab7);
  693.       fprintf(tmpfp, "%s   Pre-Entry", tab7);
  694. #else
  695.       printf("%s   Pre-Entry", tab7);
  696. #endif
  697.       if (FILEq && FILECOPY)
  698.     fprintf(fpout, "%s   Pre-Entry", tab7);
  699.  
  700.       /* both cell[i] and cell[i+1] hold stages where cells could've
  701.      come from */
  702.       if (cell[i] == cell[i+1]) {
  703.     splen = 19 - len[i];
  704.     makespstr(spstr, splen);
  705.     sprintf(tmpstr, "%s%d", spstr, cell[i]);
  706.     strcat(opstr2, tmpstr);
  707.       } else {
  708.     splen = 19 - (len[i] + len[i+1] + 1);    /* +1 for "/" */
  709.     makespstr(spstr, splen);
  710.     sprintf(tmpstr, "%s%d/%d", spstr, cell[i], cell[i+1]);
  711.     strcat(opstr2, tmpstr);
  712.       } /* if */
  713.       break;
  714.  
  715.     case 1:    /* pre-entry from end of third */
  716.       /* get correct cellname */
  717.       getcellname(i+1, cell, tmpstr, 'B', endspot);
  718.  
  719.       /* +6 for "PreEnt"; +1 for '/' */
  720.       splen = 19 - (strlen(tmpstr) + 6 + 1);
  721.       makespstr(spstr, splen);
  722.  
  723. #if PC
  724.       cprintf("%sPreEnt/%s", spstr, tmpstr);
  725.       if (HARDCOPY)
  726.     fprintf(stdprn, "%sPreEnt/%s", spstr, tmpstr);
  727.       fprintf(tmpfp, "%sPreEnt/%s", spstr, tmpstr);
  728. #else
  729.       printf("%sPreEnt/%s", spstr, tmpstr);
  730. #endif
  731.       if (FILEq && FILECOPY)
  732.     fprintf(fpout, "%sPreEnt/%s", spstr, tmpstr);
  733.  
  734.       /* cell[i] holds stage where cells might've come from */
  735.       splen = 19 - (len[i] + 1);    /* +1 for '/' */
  736.       makespstr(spstr, splen);
  737.       sprintf(tmpstr, "%s%d/", spstr, cell[i]);
  738.       strcat(opstr2, tmpstr);
  739.       break;
  740.  
  741.     case 11:    /* reached valid cell */
  742.       if (strcmp(CellNames[cell[i]], CellNames[cell[i+1]])==0) {
  743.     /* same cell reached from each end of third */
  744.     /* get correct cell name */
  745.     getcellname(i, cell, tmpstr, 'B', endspot);
  746. #if PC
  747.     cprintf("%s %10s", tab, tmpstr);
  748.     if (HARDCOPY)
  749.       fprintf(stdprn, "%s %10s", tab, tmpstr);
  750.     fprintf(tmpfp, "%s %10s", tab, tmpstr);
  751. #else
  752.     printf("%s %10s", tab, tmpstr);
  753. #endif
  754.     if (FILEq && FILECOPY)
  755.       fprintf(fpout, "%s %10s", tab, tmpstr);
  756.       } else {
  757.     /* different cells reached from each end of third */
  758.     /* get correct cell names */
  759.     getcellname(i, cell, tmpstr, 'B', endspot);
  760.     getcellname(i+1, cell, tmpstr1, 'B', endspot);
  761.  
  762.     splen = 19 - (strlen(tmpstr) + strlen(tmpstr1) + 1); /* +1 for '/' */
  763.     makespstr(spstr, splen);
  764.  
  765. #if PC
  766.     cprintf("%s%s/%s", spstr, tmpstr, tmpstr1);
  767.     if (HARDCOPY)
  768.       fprintf(stdprn, "%s%s/%s", spstr, tmpstr, tmpstr1);
  769.     fprintf(tmpfp, "%s%s/%s", spstr, tmpstr, tmpstr1);
  770. #else
  771.     printf("%s%s/%s", spstr, tmpstr, tmpstr1);
  772. #endif
  773.     if (FILEq && FILECOPY)
  774.       fprintf(fpout, "%s%s/%s", spstr, tmpstr, tmpstr1);
  775.       } /* else */
  776.  
  777.       makespstr(spstr, 19);
  778.       strcat(opstr2, spstr);
  779.       break;
  780.  
  781.     default:    /* shouldn't! */
  782. #if PC
  783.       clrscr1(1);
  784.       gotoxy(1, 5);
  785.       cprintf("%s<prresB>: Internal error, val=%d", tab2, val);
  786.       gotoxy(1, 7);
  787.       cprintf("%s          Sorry, aborting.", tab2);
  788. #endif
  789.       printexit(20);
  790.       break;
  791.     } /* switch */
  792.   } /* for i */
  793.   return(0);
  794. } /* prresB */
  795.  
  796. /****************************************/
  797. /*     function: printepi        */
  798. /****************************************/
  799. /* prints out the disclaimer if any trial moves a cell
  800.    into the epididymides */
  801. printepi ()
  802. {
  803.   /* print epididymis times disclaimer */
  804. #if PC
  805.   clrscr1(3);
  806.   cprintf("  Note: The epididymis transit time is estimated at 10 days, but can vary");
  807.   gotoxy(1, 2);
  808.   cprintf("    depending on the sexual activity of the animal under study.  (Robaire");
  809.   gotoxy(1, 3);
  810.   cprintf("    & Hermo (1988) in: The Physiol. of Reprod., Knobil & Neill et al., eds.)", tab);
  811.   if (HARDCOPY) {
  812.     fprintf(stdprn, "\n  Note: The epididymis transit time is estimated at 10 days, but can vary\n");
  813.     fprintf(stdprn, "      depending on the sexual activity of the animal under study.  (Robaire\n");
  814.     fprintf(stdprn, "      & Hermo (1988) in: The Physiol. of Reprod., Knobil & Neill et al., eds.)\n");
  815.   }
  816.   fprintf(tmpfp, "\n  Note: The epididymis transit time is estimated at 10 days, but can vary\n");
  817.   fprintf(tmpfp, "      depending on the sexual activity of the animal under study.  (Robaire\n");
  818.   fprintf(tmpfp, "      & Hermo (1988) in: The Physiol. of Reprod., Knobil & Neill et al., eds.)\n");
  819. #else
  820.   printf("\n  Note: The epididymis transit time is estimated at 10 days, but can vary\n");
  821.   printf("      depending on the sexual activity of the animal under study.  (Robaire\n");
  822.   printf("      & Hermo (1988) in: The Physiol. of Reprod., Knobil & Neill et al., eds.)\n");
  823. #endif
  824.   if (FILEq && FILECOPY) {
  825.     fprintf(fpout, "\n  Note: The epididymis transit time is estimated at 10 days, but can vary\n");
  826.     fprintf(fpout, "      depending on the sexual activity of the animal under study.  (Robaire\n");
  827.     fprintf(fpout, "      & Hermo (1988) in: The Physiol. of Reprod., Knobil & Neill et al., eds.)\n");
  828.   }
  829.   return(0);
  830. } /* printepi */
  831.  
  832. /********************************/
  833. /*     function: getcellname    */
  834. /********************************/
  835. /* gets the correct cell name to print out, on the printresults output:
  836.    correct cell is either CellNames[cell[i]], or if cell[i] is a multicell,
  837.    then is MultiCellNames[j][i] where j is found by searching linearly
  838.    through the MultiCellNames array */
  839. static getcellname (i, cell, cellname, dir, endspot)
  840.   int i, *cell;
  841.   char *cellname;
  842.   char dir;        /* 'F' or 'B' */
  843.   int endspot;          /* which 3d of stage did move end in? */
  844. {
  845.   int j, go;
  846.   int k;                /* k=0 if dir=F, k=2 if dir=B    */
  847.   int multiflag;            /* =1 if cell[i] is a multicell */
  848.  
  849. #if (DEBUG > 4)
  850. #if PC
  851.   clrscr1(3);
  852.   gotoxy(1, 1);
  853.   cprintf("%sgetcellname:  entering", tab);
  854.   hitreturn(1);
  855. #else
  856.   printf("\tgetcellname:  entering\n");
  857. #endif
  858. #endif
  859.  
  860.   if (dir=='F') k = 0;
  861.   if (dir=='B') k = 2;
  862.   multiflag = 0;
  863.   go = 1;
  864.   j = 0;
  865.   while (go && j<NumMultiCells) {
  866.     /* compare w/MultiCellNames[j][0] when moving fwd, because
  867.        will get to 1st-third name (^) first -- when moving bwd,
  868.        use MultiCellNames[j][2], since get there first */
  869. #if (DEBUG > 4)
  870. #if PC
  871.     makeactivewin(1);
  872.     gotoxy(1, 5);
  873.     clreol1(1);
  874.     gotoxy(1, 5);
  875.     cprintf("%si=<%d>  cell[i]=<%d>  CellNames[cell[i]]=<%s>",
  876.          tab, i, cell[i], CellNames[cell[i]]);
  877.     gotoxy(1, 7);
  878.     clreol1(1);
  879.     gotoxy(1, 7);
  880.     cprintf("%sj=<%d>  k=<%d>  MultiCellNames[j][k]=<%s>",
  881.          tab, j, k, MultiCellNames[j][k]);
  882.     hitreturn(1);
  883. #else
  884.     printf("\tdebug stuff...\n");
  885. #endif
  886. #endif
  887.     if (strcmp(CellNames[cell[i]], MultiCellNames[j][k])==0) {
  888.       /* cell[i] is a multicell */
  889.       /* -1 from endspot since endspot is 1,2 or 3, and indices run 0,1,2 */
  890.       strcpy(cellname, MultiCellNames[j][endspot-1]);
  891.       go = 0;
  892.       multiflag = 1;
  893.     }
  894.     j++;
  895.   } /* for j */
  896.   if (! multiflag)
  897.     strcpy(cellname, CellNames[cell[i]]);
  898. #if (DEBUG > 4)
  899. #if PC
  900.   clrscr1(1);
  901.   gotoxy(1, 11);
  902.   cprintf("%sgetcellname:  multiflag=<%d>  cellname=<%s>  endspot=<%d>",
  903.        tab, multiflag, cellname, endspot);
  904.   hitreturn(1);
  905. #else
  906.   printf("\tgetcellname:  cellname=<%s>\n", cellname);
  907. #endif
  908. #endif
  909.   return(0);
  910. } /* getcellname */
  911.  
  912. /********************************/
  913. /*     function: printexit    */
  914. /********************************/
  915. printexit (exitnum)
  916.   int exitnum;
  917. {
  918. #if PC
  919.   if (exitnum != 0) {
  920.     clrscr1(3);
  921.     gotoxy(1, 2);
  922.     cprintf("%sExiting.", tab);
  923. #if (DEBUG)
  924.     gotoxy(1, 3);
  925.     cprintf("%sExit code = <%d>.", tab, exitnum);
  926. #endif
  927.     if (HARDCOPY)
  928.       fprintf(stdprn, "\tExiting.\n\n");
  929.   }
  930. /*  wholewin();
  931.   gotoxy(1, 25); */
  932. #else
  933.   printf("\tExiting.\n\n");
  934.   if (FILEq && FILECOPY) {
  935.     fprintf(fpout, "\tExiting.\n\n");
  936.     fclose(fpout);
  937.   }
  938. #endif
  939.   exit(exitnum);
  940.   return(0);        /* this is unreachable code */
  941. } /* printexit */
  942.  
  943. #if PC
  944. /********************************/
  945. /*     function: printHARDCOPY    */
  946. /********************************/
  947. printHARDCOPY ()
  948. /* the PRINT ON/OFF annunciator is on the botline window */
  949. {
  950.   botline();
  951.   return(0);
  952. } /* printHARDCOPY */
  953. #endif
  954.  
  955. /********************************/
  956. /*     function: printFILECOPY    */
  957. /********************************/
  958. printFILECOPY ()
  959. /* the PRINT ON/OFF annunciator is on the botline window */
  960. {
  961. #if PC
  962.   botline();
  963. #else
  964.   if (FILECOPY)
  965.     printf("\n\tFile output on.\n");
  966.   else
  967.     printf("\n\tFile output off.\n");
  968. #endif
  969.   return(0);
  970. } /* printFILECOPY */
  971.  
  972. #if PC
  973.  
  974. /********************************/
  975. /*     function: printCycleTime */
  976. /********************************/
  977. /* prints out CycleTime annunciator on screen: current value of CycleTime */
  978. printCycleTime ()
  979. {
  980.   sep1win();
  981.   return(0);
  982. } /* printCycleTime */
  983.  
  984. #endif
  985.  
  986. /********************************/
  987. /*     function: printline    */
  988. /********************************/
  989. /* prints line of num of char c's:
  990.    if fileq = 0, print to terminal
  991.    if fileq = 1, print to file
  992.    if fileq = 2, print to printer
  993.    if fileq = 3, print to all three
  994.    if fileq = 4, print to file and printer
  995.    if fileq = 5, print to temp file (output holder to dump) */
  996. printline (fileq, num, c)
  997.   int fileq, num;
  998.   char c;
  999. {
  1000.   int i;
  1001.  
  1002.   switch (fileq) {
  1003.   case 0: /* to terminal */
  1004.     for ( i=0; i<num; i++ )
  1005. #if PC
  1006.       putch(c);
  1007. #else
  1008.       printf("%c", c);
  1009.     printf("\n");
  1010. #endif
  1011.     break;
  1012.  
  1013.   case 1: /* to file */
  1014.     if (FILEq && FILECOPY) {
  1015.       for ( i=0; i<num; i++ )
  1016.     fprintf(fpout, "%c", c);
  1017.       fprintf(fpout, "\n");
  1018.     }
  1019.     break;
  1020.  
  1021. #if PC
  1022.   case 2: /* to printer */
  1023.     if (HARDCOPY) {
  1024.       for ( i=0; i<num; i++ )
  1025.     fprintf(stdprn, "%c", c);
  1026.       fprintf(stdprn, "\n");
  1027.     }
  1028.     break;
  1029. #endif
  1030.  
  1031.   case 3: /* all three */
  1032.     for ( i=0; i<num; i++ )
  1033. #if PC
  1034.       putch(c);
  1035. #else
  1036.       printf("%c", c);
  1037.     printf("\n");
  1038. #endif
  1039.     /* do not put a break here!! */
  1040.  
  1041.   case 4: /* just to file and printer */
  1042.     for ( i=0; i<num; i++ ) {
  1043.       if (FILEq && FILECOPY)
  1044.     fprintf(fpout, "%c", c);
  1045. #if PC
  1046.       if (HARDCOPY)
  1047.     fprintf(stdprn, "%c", c);
  1048. #endif
  1049.     } /* for */
  1050. #if PC
  1051.     if (HARDCOPY)
  1052.       fprintf(stdprn, "\n");
  1053. #endif
  1054.     if (FILEq && FILECOPY)
  1055.       fprintf(fpout, "\n");
  1056.     break;
  1057.   case 5:    /* to tmp file, to hold output */
  1058. #if PC
  1059.     for ( i=0; i<num; i++ )
  1060.       fprintf(tmpfp, "%c", c);
  1061.     fprintf(tmpfp, "\n");
  1062. #endif
  1063.     break;
  1064.  
  1065.   default: /* shouldn't! */
  1066.     printexit(14);
  1067.   } /* switch */
  1068.   return(0);
  1069. } /* printline */
  1070.  
  1071. #if PC
  1072. /********************************/
  1073. /*     function: printresHARD    */
  1074. /********************************/
  1075. printresHARD ()
  1076. {
  1077.   char c;
  1078.  
  1079.   fclose(tmpfp);
  1080.   tmpfp = fopen(TMPFIL, "r");
  1081.   while ((fscanf(tmpfp, "%c", &c)) != EOF)
  1082.     fprintf(stdprn, "%c", c);
  1083.   fclose(tmpfp);
  1084.   tmpfp = fopen(TMPFIL, "w");
  1085.   return(0);
  1086. } /* printresHARD */
  1087. #endif
  1088.