home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
SCIENCE
/
STAGES12.ZIP
/
PRINTS2.C
< prev
next >
Wrap
Text File
|
1991-04-21
|
31KB
|
1,088 lines
#include "header.h"
#include "file.h"
/************************************************************************/
/** print routines: part 2 **/
/************************************************************************/
/* contains: printusrcells
printresulthdr
printresults
prresF
prresB
printepi
getcellname
printexit
printHARDCOPY
printFILECOPY
printCycleTime
printline
printresHARD
*/
static int printresulthdr(int fileq);
static int prresF(char *daystr, int *cell, int *len,
char *cellstr, int *ok, int okcell, int oknum,
int endspot, char *opstr1, char *opstr2);
static int prresB(char *daystr, int *cell, int *len,
char *cellstr, int *ok, int okcell, int oknum,
int endspot, char *opstr1, char *opstr2);
static int getcellname(int i, int *cell, char *cellname,
char dir, int endspot);
/********************************/
/* function: printusrcells */
/********************************/
/* prints out a list of the user-entered input cells
(interactive mode only) */
printusrcells (cellstrs, trials)
char cellstrs[][MAXIPLEN];
int trials;
{
int i;
#if PC
int j;
#endif
if (! trials)
return(0);
#if PC
j = 1;
clrscr1(3);
gotoxy(4, j++);
cprintf("These are the input cells:");
gotoxy(6, j);
if (HARDCOPY) {
fprintf(stdprn, "\tThese are the input cells:");
fprintf(stdprn, "\n\t\t");
}
#else
printf("\tThese are the input cells:\n\t\t");
#endif
if (FILEq && FILECOPY)
fprintf(fpout, "\tThese are the input cells:\n\t\t");
for ( i=0; i<trials; i++ ) {
#if PC
if ((j >= MSGLNS) && (wherex() >= 65)) {
/* end of last line of window reached */
hitreturn(3);
clrscr1(3);
j = 1;
gotoxy(4, j++);
cprintf("These are the input cells:");
gotoxy(6, j);
} /* if j */
if (i && (wherex() >= 65)) { /* if xpos near eol, start new ln */
#else
if (i && ((i % 5)==0)) { /* after 5 cells, start new line */
#endif
#if PC
gotoxy(6, ++j);
if (HARDCOPY)
fprintf(stdprn, "\n\t\t");
#else
printf("\n\t\t");
#endif
if (FILEq && FILECOPY)
fprintf(fpout, "\n\t\t");
} /* if time for newline */
#if PC
cprintf("%s ", cellstrs[i]);
if (HARDCOPY)
fprintf(stdprn, "%s ", cellstrs[i]);
#else
printf("%s ", cellstrs[i]);
#endif
if (FILEq && FILECOPY)
fprintf(fpout, "%s ", cellstrs[i]);
} /* for */
#if PC
if (HARDCOPY)
fprintf(stdprn, "\n");
#else
printf("\n");
#endif
if (FILEq && FILECOPY)
fprintf(fpout, "\n");
return(0);
} /* printusrcells */
/********************************/
/* function: printresulthdr */
/********************************/
/* static means that this function is only used within this file
saves space in the executable file */
static printresulthdr (fileq)
int fileq;
{
#if PC
clrscr1(3);
clrscr1(2);
clrscr1(1);
gotoxy(2, 1);
cprintf("Init cell Days%s 1st third", tab);
cprintf("%s 2nd third%s 3rd third", tab, tab);
gotoxy(2, 2);
printline(0, LNWID, '=');
if (HARDCOPY) {
fprintf(stdprn, "\nInit cell Days%s 1st third", tab);
fprintf(stdprn, "%s 2nd third%s 3rd third\n", tab, tab);
printline(2, LNWID, '=');
}
fprintf(tmpfp, "\nInit cell Days%s 1st third", tab);
fprintf(tmpfp, "%s 2nd third%s 3rd third\n", tab, tab);
printline(5, LNWID, '=');
#else
printf("\nInit cell Days%s 1st third", tab);
printf("%s 2nd third%s 3rd third\n", tab, tab);
printline(0, LNWID, '=');
#endif
if (FILEq && FILECOPY)
if (fileq) {
fprintf(fpout, "\nInit cell Days%s 1st third", tab);
fprintf(fpout, "%s 2nd third%s 3rd third\n", tab, tab);
printline(1, LNWID, '=');
}
return(0);
} /* printresulthdr */
/********************************/
/* function: printresults */
/********************************/
/* the functions printresults, prresF and prresB all use a temporary
output file into which they write their output.
then if the user decides to print the output on the printer,
we just dump the file to the printer. */
printresults (dir, days, daystr, cell, cellstr, ok, okcell, oknum,
endspot, opstr, oncep, epip, opstr1, opstr2)
char dir; /* direction: F or B */
double days; /* used if oknum=1 */
char *daystr; /* used if oknum=0 */
int *cell; /* used if okcell=1: cells reached */
char *cellstr; /* used if okcell=0: init cell */
int *ok; /* move ok? from the 4 pts in init stage */
int okcell, oknum; /* cell/days valid? */
int endspot; /* which 3d of stage did move end in? */
char *opstr; /* err string if move went out of bounds */
int *oncep; /* controls outputhdr printing */
int *epip; /* controls printepi printing */
char *opstr1,
*opstr2; /* strs for when cell ejac but still tracking stgs */
{
int len[4]; /* CellName lengths */
int i; /* iteration var */
#if PC
static int j=1; /* j = y-pos in the output window (STATIC VAR!) */
int lines; /* # lines in output window this output will need */
#endif
/* format:
init cell<5>days<10>1st third<10>2nd third<10>3rd third
1 1 2 3 4 5 6 7
1 9 5 8 9 7 8 6 7 5 */
if (! *oncep) {
#if PC
makedisplay();
topline(" Stages Output ");
clrscr1(3);
clrscr1(1);
j = 3;
#endif
*oncep = 1;
printresulthdr(1);
} /* if ! oncep */
#if PC
/* determine how many output lines this cell/day input will require;
if cell ok, only need 2 o/p lines (1 for data, 1 for underline) */
if ((ok[0] != 1) || (ok[1] !=1 ) || (ok[2] !=1 ) || (ok[3] != 1)) {
/* final cell epididymis/pre-entry: need 3 extra lines */
lines = 5;
} else
lines = 2;
if (j >= (OUTPUTLNS-lines)) {
hitreturn(1);
clrscr1(1);
printresulthdr(0);
j = 3;
}
outputwin();
gotoxy(2, j++);
#endif
if (oknum) {
#if PC
cprintf(" %6s %8.4lf", cellstr, days);
if (HARDCOPY)
fprintf(stdprn, " %6s %8.4lf", cellstr, days);
fprintf(tmpfp, " %6s %8.4lf", cellstr, days);
#else
printf(" %6s %8.4lf", cellstr, days);
#endif
if (FILEq && FILECOPY)
fprintf(fpout, " %6s %8.4lf", cellstr, days);
} else { /* bad i/p num syntax */
#if PC
cprintf(" %6s %8s", cellstr, daystr);
if (HARDCOPY)
fprintf(stdprn, " %6s %8s", cellstr, daystr);
fprintf(tmpfp, " %6s %8s", cellstr, daystr);
#else
printf(" %6s %8s", cellstr, daystr);
#endif
if (FILEq && FILECOPY)
fprintf(fpout, " %6s %8s", cellstr, daystr);
} /* if oknum */
for ( i=0; i<4; i++ ) {
if (ok[i]==1) {
len[i] = strlen(CellNames[cell[i]]);
} else {
/* this is because, if ok!=1, then cell[i] = stage reached */
if (cell[i] < 10)
/* 1-digit stage */
len[i] = 1;
else
/* 2-digit stage: don't expect to see > 100 stages in the cycle */
len[i] = 2;
}
} /* for */
switch (dir) {
case 'F':
prresF(daystr, cell, len, cellstr, ok, okcell, oknum,
endspot, opstr1, opstr2);
break;
case 'B':
prresB(daystr, cell, len, cellstr, ok, okcell, oknum,
endspot, opstr1, opstr2);
break;
default: /* shouldn't! */
#if PC
clrscr1(1);
gotoxy(1, 5);
cprintf("%sprintresults: Internal error, dir=%d", tab2, dir);
gotoxy(1, 7);
cprintf("%s Sorry, aborting.", tab2);
#endif
printexit(21);
break;
} /* switch */
#if PC
gotoxy(2, j++);
if (HARDCOPY)
fprintf(stdprn, "\n");
fprintf(tmpfp, "\n");
#else
printf("\n");
#endif
if (FILEq && FILECOPY)
fprintf(fpout, "\n");
if ((ok[0] != 1) || (ok[1] !=1 ) || (ok[2] !=1 ) || (ok[3] != 1)) {
#if PC
cprintf(" (%s)\n", opstr);
gotoxy(2, j++);
cprintf("%s", opstr1);
gotoxy(2, j++);
cprintf("%s", opstr2);
gotoxy(2, j++);
if (HARDCOPY) {
fprintf(stdprn, " (%s)\n", opstr);