home *** CD-ROM | disk | FTP | other *** search
- #include "header.h"
- #if PC
- #include <bios.h>
- #endif
- #include "file.h"
-
- unsigned long coreleft(void);
-
- /* functions included:
- getipfile
- getstgdat
- getCyclelen
- getseqdat
- getmcldat
- getusrstr
- */
-
- /********************************/
- /* function: getipfile */
- /********************************/
- /* there are 2 times when getipfile is called:
- 1/ to open a batch i/p file
- 2/ to open animal data files.
- in case 1/, if file can't be found, do prompt for another file,
- but it isn't mandatory to have one (if none given, then interactive
- use assumed).
- in case 2/, don't ask user for new filename: just exit w/error msg.
- the user doesn't know anything about which files are correct to use.
-
- returns 0 if good file opened,
- else returns 1. */
- getipfile (ipfil, pfp, iptype, ftype)
- char *ipfil; /* the name of the file finally opened */
- FILE **pfp;
- char iptype; /* filename supplied (F) or entered */
- /* interactively (I) */
- char ftype; /* C=cycle stage dat
- I=input file (batch mode)
- S=cell sequence dat */
- {
- int go, help, mandatory;
- char fname[2*FILELEN];
- #if PC
- int val;
- #endif
-
- switch (ftype) {
- case 'I':
- mandatory = 0;
- break;
- case 'S':
- case 'C':
- mandatory = 1;
- break;
- default: /* shouldn't */
- #if PC
- clrscr1(1);
- gotoxy(1, 5);
- cprintf("%sgetipfile: Illegal ftype=<%c>", tab, ftype);
- gotoxy(1, 7);
- cprintf("%s Sorry, aborting.", tab);
- printexit(329);
- #else
- printf("\tgetipfile: Illegal ftype=<%c>\n", ftype);
- printf("\t Sorry, aborting.\n");
- #endif
- } /* switch */
-
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 5);
- cprintf("%sin getipfile:", tab);
- gotoxy(1, 7);
- cprintf("%sipfil=<%s>", tab2, ipfil);
- gotoxy(1, 8);
- cprintf("%siptype=<%c>", tab2, iptype);
- gotoxy(1, 9);
- cprintf("%sftype=<%c>", tab2, ftype);
- hitreturn(1);
- #endif
- #endif
- if (iptype == 'F')
- /* filename supplied in var ipfile */
- strcpy(fname, ipfil);
- else {
- /* get a filename interactively;
- user-friendly asking-message printed by calling function */
- #if PC
- val = getusrstr(fname);
- if (HARDCOPY)
- fprintf(stdprn, "%s\n", fname);
- if (val) return(val);
- #else
- getusrstr(fname);
- #endif
- if (FILEq && FILECOPY)
- fprintf(fpout, "%s\n", fname);
- }
-
- /* strip input string of leading/trailing whitespace */
- stripwhitesp(&fname[0]);
-
- go = 1;
- while (go && ((*pfp = fopen(fname, "r"))==NULL)) {
- if ((ftype=='C') || (ftype=='S')) {
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 5);
- cprintf("%sfile <%s> not opened", tab, fname);
- hitreturn(1);
- #else
- printf("\tfile <%s> not opened\n", fname);
- #endif
- #endif
- helpipfil(ftype);
- printexit(330);
- } else {
- if (fname[0]=='?') {
- help = 1;
- helpipfil1(ipfil);
- } else {
- help = 0;
- }
- }
-
- if (! mandatory) {
- #if PC
- clrscr1(3);
- gotoxy(1, 1);
- if (! help) {
- printf("%s%s: File ", tab, ERRSTR);
- printf("<%s> cannot be opened.", fname);
- gotoxy(1, 2);
- }
- cprintf("%sPlease enter a new filename, or", tab);
- gotoxy(1, 3);
- cprintf("%s type <Enter> if no file is desired.", tab);
- clrscr1(2);
- cprintf("%sNew filename:", tab);
- gotoxy(1, 2);
- highvideo();
- cprintf("%s%c%c%c ", tab2, HBAR, HBAR, RTRI);
- normvideo();
- val = getusrstr(fname);
- stripwhitesp(&fname[0]);
- if (HARDCOPY) {
- if (! help) {
- fprintf(stdprn, "\n\t%s: File ", ERRSTR);
- fprintf(stdprn, "<%s> cannot be opened.\n", fname);
- }
- fprintf(stdprn, "\tPlease enter a new filename, or\n");
- fprintf(stdprn, "\t type <Enter> if no file is desired.\n");
- fprintf(stdprn, "\t\t==> ");
- fprintf(stdprn, "%s\n", fname);
- }
- if (val) return(val);
- #else
- if (! help) {
- printf("\n\t%s: File ", ERRSTR);
- printf("<%s> cannot be opened.\n", fname);
- }
- printf("\tPlease enter a new filename, or\n");
- printf("\t type <Enter> if no file is desired.\n");
- printf("\t\t==> ");
- getusrstr(fname);
- stripwhitesp(&fname[0]);
- #endif
- if (FILEq && FILECOPY) {
- if (! help) {
- fprintf(fpout, "\n\t%s: File ", ERRSTR);
- fprintf(fpout, "<%s> cannot be opened.\n", fname);
- }
- fprintf(fpout, "\tPlease enter a new filename, or");
- fprintf(fpout, "\t type <Enter> if no file is desired.\n");
- fprintf(fpout, "\t\t==> ");
- fprintf(fpout, "%s\n", fname);
- }
- /* not mandatory: can enter no filename */
- if (strlen(fname)==0)
- go = 0;
-
- } else { /* mandatory: animal file: fail! */
- #if PC
- clrscr1(1);
- gotoxy(1, 5);
- cprintf("%sgetipfile: Internal error: File <%s> ", tab, fname);
- cprintf("cannot be opened.");
- gotoxy(1, 7);
- cprintf("%s Sorry, aborting.", tab);
- if (HARDCOPY) {
- fprintf(stdprn, "\t%s: Internal error: File <%s> ", ERRSTR, fname);
- fprintf(stdprn, "cannot be opened.\n\tSorry, aborting.\n\n");
- }
- #else
- printf("\t%s: Internal error: File <%s> ", ERRSTR, fname);
- printf("cannot be opened.\n\tSorry, aborting.\n\n");
- #endif
- if (FILEq && FILECOPY) {
- fprintf(fpout, "\t%s: Internal error: File <%s> ", ERRSTR, fname);
- fprintf(fpout, "cannot be opened.\n\tSorry, aborting.\n\n");
- }
- printexit(331);
- } /* if mandatory */
- } /* while */
-
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 5);
- cprintf("%sgetipfile: done with while loop", tab);
- hitreturn(1);
- #else
- printf("\tgetipfile: done with while loop\n");
- #endif
- #endif
-
- if (go==0) {
- /* no file necessary */
- #if PC
- clrscr1(3);
- cprintf("%sNo batch file opened; input must be entered interactively.", tab);
- if (HARDCOPY)
- fprintf(stdprn, "\n\tNo batch file opened; input must be entered interactively.\n");
- hitreturn(1);
- #else
- printf("\n\tNo batch file opened; input must be entered interactively.\n");
- #endif
- if (FILEq && FILECOPY)
- fprintf(fpout, "\n\tNo batch file opened; input must be entered interactively.\n");
-
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 5);
- cprintf("%sfile <%s> not opened", tab, fname);
- hitreturn(1);
- #else
- printf("\tfile <%s> not opened\n", fname);
- #endif
- #endif
- return(1);
- } else {
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 5);
- cprintf("%sfile <%s> opened", tab, fname);
- hitreturn(1);
- #else
- printf("\tfile <%s> opened\n", fname);
- #endif
- #endif
- return(0); /* good file opened */
- } /* *pfp != NULL */
- } /* getipfile */
-
- /********************************/
- /* function: getstgdat */
- /********************************/
- /* reads from the file xxx.stg to get the cycle stage data */
- getstgdat (stgfil, fpstg)
- char *stgfil;
- FILE *fpstg;
- {
- int i;
- static int once=0; /* =1 if malloc'd once already */
- #if (DEBUG > 4)
- long int j;
- #endif
-
- /* if gotstgdat at least once already, free up allo'c space */
- if (once) {
- free1((char *) stage);
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 3);
- cprintf("%sgetstgdat: free(stage)", tab);
- hitreturn(1);
- #else
- printf("\tgetstgdat: free(stage)\n");
- #endif
- } else {
- #if PC
- clrscr1(1);
- #else
- printf("\tgetstgdat: stage not freed\n");
- #endif
- #endif
- } /* else */
-
- /* read cycle time - this is in days */
- fscanf(fpstg, "%lf", &CycleTime);
- /* DefaultCycleTime is always that value read from the *.stg file */
- DefaultCycleTime = CycleTime;
- #if PC
- printCycleTime(); /* turn on Cycle Length annunciator */
- #endif
- OldCycleTime = CycleTime; /* initialize OldCycleTime */
- fscanf(fpstg, "%d", &NumStages);
- MaxStage = NumStages - 1;
-
- #if (PC && (DEBUG > 4))
- makeactivewin(1);
- gotoxy(1, 5);
- cprintf("%sgetstgdat: getting data from file <%s>", tab, stgfil);
- gotoxy(1, 6);
- cprintf("%s CycleTime = <%lf>", tab, CycleTime);
- gotoxy(1, 7);
- cprintf("%s NumStages = <%d>", tab, NumStages);
- gotoxy (1, 8);
- cprintf("%sgetstgdat: beg: core left = %lu", tab, coreleft());
- hitreturn(1);
- #endif
-
- /* allocate NumStages spaces for stage lengths */
- stage = (double *) malloc((unsigned) (NumStages * sizeof(double)));
- if (stage==NULL) {
- #if PC
- makeactivewin(1);
- gotoxy(1, 9);
- cprintf("%sgetstgdat: malloc returns NULL on stage", tab);
- #else
- printf("\tgetstgdat: malloc returns NULL on stage\n");
- #endif
- printexit(332);
- } /* if */
-
- #if (PC && (DEBUG > 4))
- makeactivewin(1);
- gotoxy(1, 9);
- cprintf("%sgetstgdat: mid: core left = %lu", tab, coreleft());
- hitreturn(1);
- #endif
-
- /* read stage lengths (these are in % of CycleTime) and convert to days */
- for ( i=0; i<NumStages; i++ ) {
- fscanf(fpstg, "%lf", &stage[i]);
- stage[i] = stage[i] * CycleTime / 100;
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 10);
- clreol1(1);
- gotoxy(1, 10);
- cprintf("%sgetstgdat: stage[%d]=<%lf>", tab, i, stage[i]);
- for ( j=0; j<TIME; j++);
- #else
- printf("\t : stage[%d]=<%lf>\n", i, stage[i]);
- #endif
- #endif
- } /* for i */
-
- /* read epididymis transit times (this is days) */
- fscanf(fpstg, "%lf", &EpiTime);
-
- #if (PC && (DEBUG > 4))
- makeactivewin(1);
- gotoxy(1, 11);
- cprintf("%sgetstgdat: EpiTime = <%lf>", tab, EpiTime);
- gotoxy(1, 12);
- cprintf("%sgetstgdat: end: core left = %lu", tab, coreleft());
- hitreturn(1);
- #endif
-
- once = 1;
- return(0);
- } /* getstgdat */
-
- /********************************/
- /* function: getCyclelen */
- /********************************/
- /* asks user to input new CycleTime, or use default */
- getCyclelen ()
- {
- char dummy[MAXLEN]; /* user input string */
- int i, val, ok;
-
- ok = 0;
- while (! ok) {
- #if PC
- clrscr1(2);
- cprintf("%sNew Cycle Length (in days):", tab);
- gotoxy(1, 2);
- highvideo();
- cprintf("%s%c%c%c ", tab2, HBAR, HBAR, RTRI);
- normvideo();
- val = getusrstr(dummy);
- if (HARDCOPY) {
- fprintf(stdprn, "\n\tNew Cycle Length (in days):\n");
- fprintf(stdprn, "\t\t==> %s\n\n", dummy);
- }
- if (val) return(val); /* keyboard accel pressed */
- #else
- printf("\n\tNew Cycle Length (in days):\n");
- printf("\t\t==> ");
- getusrstr(dummy);
- #endif
-
- if (FILEq && FILECOPY) {
- fprintf(fpout, "\n\tNew Cycle Length (in days):\n");
- fprintf(fpout, "\t\t==> %s\n\n", dummy);
- }
- switch (dummy[0]) {
- case '?':
- helpcyclelenip();
- break;
- default: /* it's a new Cycle length, if it's a valid # */
- if (! numstrq(dummy)) {
- #if PC
- clrscr1(3);
- cprintf("%s%s: Invalid number syntax <%s>", tab, ERRSTR, dummy);
- if (HARDCOPY) {
- fprintf(stdprn, "\t%s: Invalid number syntax <%s>.\n",
- ERRSTR, dummy);
- }
- #else
- printf("\t%s: Invalid number syntax <%s>.\n", ERRSTR, dummy);
- #endif
- if (FILEq && FILECOPY) {
- fprintf(fpout, "\t%s: Invalid number syntax <%s>.\n",
- ERRSTR, dummy);
- }
- } else { /* it's a valid number input */
- OldCycleTime = CycleTime;
- CycleTime = atof(dummy);
- ok = 1;
- NewCycleTime = 1; /* global var */
- /* set Cycle length annunciator */
- #if PC
- printCycleTime();
- #endif
- /* transform old stage[i] vals (days) to new ones */
- for ( i=0; i<NumStages; i++ )
- stage[i] = stage[i] * CycleTime / OldCycleTime;
- } /* if numstr) */
- } /* dummy != ? */
- } /* while ! ok */
- return(0);
- } /* getCyclelen */
-
- /********************************/
- /* function: getseqdat */
- /********************************/
- /* reads from the file xxx.seq to get the cell sequence data */
- getseqdat (seqfil, fpseq)
- char *seqfil;
- FILE *fpseq;
- {
- int i; /* char array indices */
- char temp[MAXLEN]; /* temp str: holds CellNames */
- static int once=0; /* =1 if gotseqdat once already */
- #if (DEBUG > 4)
- long int j;
- #endif
-
- /* if gotseqdat at least once already, free up alloc'd space */
- if (once) {
- /* free each CellNames[i], incl. CellNames[MaxCellSeq+1] =
- CellNames[NumCellSeq] = Epididymis */
- for ( i=0; i<=NumCellSeq; i++ ) {
- free1((char *) CellNames[i]);
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 2);
- clreol1(1);
- gotoxy(1, 2);
- cprintf("%sgetseqdat: free(CellNames[%d])", tab, i);
- for ( j=0; j<TIME; j++ );
- #else
- printf("\tgetseqdat: free(CellNames[%d])\n", i);
- #endif
- #endif
- } /* for i */
-
- /* free CellNames ptr itself */
- free1((char *) CellNames);
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 3);
- cprintf("%sgetseqdat: free(CellNames)", tab);
- #else
- printf("\tgetseqdat: free(CellNames)\n");
- #endif
- #endif
-
- } else {
- #if PC
- clrscr1(1);
- #else
- printf("\tgetseqdat: CellNames not freed\n");
- #endif
- } /* else */
-
- /* determine number of cells in cell sequence */
- NumCellSeq = 0;
- while (fscanf(fpseq, "%s", temp) != EOF)
- NumCellSeq++;
- /* subtract epididymis time and CycleStart: not part of the cycle */
- NumCellSeq -= 2;
- MaxCellIndex = NumCellSeq - 1;
-
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 4);
- cprintf("%sgetseqdat: getting data from file <%s>", tab, seqfil);
- gotoxy(1, 5);
- cprintf("%sgetseqdat: NumCellSeq=%d", tab, NumCellSeq);
- gotoxy(1, 6);
- cprintf("%s MaxCellIndex=%d", tab, MaxCellIndex);
- gotoxy(1, 7);
- cprintf("%sgetseqdat: beg: core left = %lu", tab, coreleft());
- hitreturn(1);
- #else
- printf("\tgetseqdat: NumCellSeq=%d\n", NumCellSeq);
- printf("\t MaxCellIndex=%d\n", MaxCellIndex);
- #endif
- #endif
-
- /* allocate NumCellSeq+1 spaces for cell names, "+1" for epididymis */
- CellNames = (char **) malloc((unsigned) ((NumCellSeq+1) * sizeof(char *)));
- if (CellNames==NULL) {
- #if PC
- makeactivewin(1);
- gotoxy(1, 8);
- cprintf("%sgetseqdat: malloc returns NULL on CellNames", tab);
- #else
- printf("\tgetseqdat: malloc returns NULL on CellNames\n");
- #endif
- printexit(333);
- } /* if */
-
- #if (PC && (DEBUG > 4))
- makeactivewin(1);
- gotoxy(1, 8);
- cprintf("%sgetseqdat: mid: core left = %lu", tab, coreleft());
- hitreturn(1);
- #endif
-
- /* read cell name strings from *.seq file, assign to CellNames[i] */
- rewind(fpseq);
- for ( i=0; i<NumCellSeq; i++ ) {
- fscanf(fpseq, "%s", temp);
- strupper(temp);
- CellNames[i] = strdup(temp); /* does AUTOmagic malloc */
- if (CellNames[i]==NULL) {
- #if PC
- makeactivewin(1);
- gotoxy(1, 9);
- clreol1(1);
- gotoxy(1, 9);
- cprintf("%sgetseqdat: strdup returns NULL on CellNames[%d]", tab, i);
- #else
- printf("\tgetseqdat: strdup returns NULL on CellNames[%d]\n", i);
- #endif
- printexit(334);
- } /* if */
-
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 9);
- clreol1(1);
- gotoxy(1, 9);
- cprintf("%sgetseqdat: temp=<%s>", tab, temp);
- gotoxy(1, 10);
- clreol1(1);
- gotoxy(1, 10);
- cprintf("%s CellNames[%2d]=<%s>", tab, i, CellNames[i]);
- for ( j=0; j<TIME; j++ );
- #else
- printf("\tgetseqdat: temp=<%s>\n", temp);
- printf("\t CellNames[%2d]=<%s>\n", i, CellNames[i]);
- #endif
- #endif
- } /* for i */
-
- /* get "epididymis" name string */
- fscanf(fpseq, "%s", temp);
- CellNames[MaxCellIndex+1] = strdup(temp); /* does AUTOmagic malloc */
- if (CellNames[MaxCellIndex+1]==NULL) {
- #if PC
- makeactivewin(1);
- gotoxy(1, 11);
- cprintf("%sgetseqdat: strdup returns NULL on CellNames[%d]",
- tab, MaxCellIndex+1);
- #else
- printf("\tgetseqdat: strdup returns NULL on CellNames[%d]\n",
- MaxCellIndex+1);
- #endif
- printexit(335);
- } /* if */
-
- /* get CycleStart cell # */
- fscanf(fpseq, "%d", &CycleStart);
-
- #if (PC && (DEBUG > 4))
- makeactivewin(1);
- gotoxy(1, 11);
- cprintf("%sgetseqdat: end: core left = %lu", tab, coreleft());
- hitreturn(1);
- #endif
-
- once = 1;
- return(0);
- } /* getseqdat */
-
- /********************************/
- /* function: getmcldat */
- /********************************/
- /* reads from file xxx.mcl to get data on stages which have
- >1 possible cell, depending on which third of the stage
- the movement ends up in */
- getmcldat (mclfil, fpmcl)
- char *mclfil;
- FILE *fpmcl;
- {
- int i, j;
- char temp[MAXLEN]; /* temp string for cellnames */
- static int once=0; /* =1 if malloc'd once already */
- #if (DEBUG > 4)
- long int k;
- #endif
-
- /* if gotmcldat at least once already, free up alloc'd space */
- if (once) {
- /* free up each MultiCellNames[i][j] */
- for ( i=0; i<NumMultiCells; i++ ) {
- for ( j=0; j<3; j++ ) {
- free1((char *) MultiCellNames[i][j]);
- #if (DEBUG > 4)
- #if PC
- clrscr1(1);
- gotoxy(1, 2);
- clreol1(1);
- gotoxy(1, 2);
- cprintf("%sgetmcldat: free(MultiCellNames[%d][%d])", tab, i, j);
- for ( k=0; k<TIME; k++ );
- #else
- printf("\tgetmcldat: free(MultiCellNames[%d][%d])\n", i, j);
- #endif
- #endif
- } /* for j */
- } /* for i */
-
- /* free each MultiCellNames[i] and MultiCellNames[i][j] */
- for ( i=0; i<NumMultiCells; i++ ) {
- free1((char *) MultiCellNames[i]);
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 3);
- clreol1(1);
- gotoxy(1, 3);
- cprintf("%sgetmcldat: free(MultiCellNames[%d])", tab, i);
- for ( k=0; k<TIME; k++ );
- #else
- printf("\tgetmcldat: free(MultiCellNames[%d])\n", i);
- #endif
- #endif
- } /* for i */
-
- /* free MultiCellNames itself */
- free1((char *) MultiCellNames);
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 4);
- cprintf("%sgetmcldat: free(MultiCellNames)", tab);
- #else
- printf("\tgetmcldat: free(MultiCellNames)\n");
- #endif
- #endif
-
- } else {
- #if PC
- clrscr1(1);
- #else
- printf("\tgetmcldat: MultiCellNames not freed\n");
- #endif
- } /* else */
-
- /* get new multicell data */
- fscanf(fpmcl, "%d", &NumMultiCells);
-
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 6);
- cprintf("%sgetmcldat: getting data from file <%s>", tab, mclfil);
- gotoxy(1, 7);
- cprintf("%sgetmcldat: NumMultiCells=%d", tab, NumMultiCells);
- gotoxy(1, 8);
- cprintf("%sgetmcldat: beg: core left = %lu", tab, coreleft());
- hitreturn(1);
- #else
- printf("\tgetmcldat: NumMultiCells=%d\n", NumMultiCells);
- #endif
- #endif
-
- /* allocate NumMultiCells spaces for cell names */
- MultiCellNames =
- (char ***) malloc((unsigned) (NumMultiCells * sizeof(char *)));
- if (MultiCellNames==NULL) {
- #if PC
- makeactivewin(1);
- gotoxy(1, 9);
- cprintf("%sgetmcldat: malloc returns NULL on MultiCellNames", tab);
- #else
- printf("\tgetmcldat: malloc returns NULL on MultiCellNames\n");
- #endif
- printexit(336);
- } /* if */
-
- for ( i=0; i<NumMultiCells; i++ ) {
- MultiCellNames[i] = (char **) malloc((unsigned) (3 * sizeof(char *)));
- /* 3 because there are 3 thirds in a stage, depending on where the
- movement ends in the stage, use MultiCellName[i][third] */
- if (MultiCellNames[i]==NULL) {
- #if PC
- makeactivewin(1);
- gotoxy(1, 9);
- cprintf("%sgetmcldat: malloc returns NULL on MultiCellNames[%d]",
- tab, i);
- #else
- printf("\tgetmcldat: malloc returns NULL on MultiCellNames[%d]\n", i);
- #endif
- printexit(337);
- } /* if */
- } /* for i */
-
- #if (PC && (DEBUG > 4))
- makeactivewin(1);
- gotoxy(1, 9);
- cprintf("%sgetmcldat: mid: core left = %lu", tab, coreleft());
- hitreturn(1);
- #endif
-
- for ( i=0; i<NumMultiCells; i++ ) {
- for ( j=0; j<3; j++ ) {
- fscanf(fpmcl, "%s", temp);
- strupper(temp);
- MultiCellNames[i][j] = strdup(temp); /* does AUTOmagic malloc */
- if (MultiCellNames[i][j]==NULL) {
- #if PC
- makeactivewin(1);
- gotoxy(1, 10);
- cprintf("%sgetmcldat: strdup returns NULL on MultiCellNames[%d][%d]",
- tab, i, j);
- #else
- printf("\tgetmcldat: strdup returns NULL on MultiCellNames[%d][%d]\n",
- i, j);
- #endif
- printexit(338);
- } /* if */
- #if (DEBUG > 4)
- #if PC
- makeactivewin(1);
- gotoxy(1, 10);
- clreol1(1);
- gotoxy(1, 10);
- cprintf("%sgetmcldat: temp=<%s>", tab, temp);
- gotoxy(1, 11);
- clreol1(1);
- gotoxy(1, 11);
- cprintf("%s MultiCellNames[%d][%d]=<%s>",
- tab, i, j, MultiCellNames[i][j]);
- for ( k=0; k<TIME; k++ );
- #else
- printf("\tgetmcldat: \n");
- #endif
- #endif
- } /* for j */
- } /* for i */
-
- #if (PC && (DEBUG > 4))
- makeactivewin(1);
- gotoxy(1, 12);
- cprintf("%sgetmcldat: end: core left = %lu", tab, coreleft());
- hitreturn(1);
- #endif
-
- once = 1;
- return(0);
- } /* getmcldat */
-
- #if PC
- /********************************/
- /* function: getusrstr */
- /********************************/
- /* gets one user input string: PC version
- checks to see if an F-key was typed
-
- bioskey() described in turbo c v2.0 ref guide
- bit manipulations from _the peter norton programmer's
- guide to the ibm pc_, pp127-135, microsoft press, 1985
-
- return 0 if string input
- return 100+k if F-k pressed */
- getusrstr (input)
- char *input; /* char str input if no F key */
- {
- int key; /* 32-bit val of key pressed */
- int keylo; /* key bits 0-7 */
- int keyhi; /* key bits 8-15 */
- int i, go, x, y;
-
- i = 0;
- go = 1;
- y = wherey();
- while (go) {
- while (bioskey(1)==0); /* sit & spin */
- x = wherex();
- key = bioskey(0);
- keylo = key & 0x000000FF;
- keyhi = (key & 0x0000FF00) >> 8; /* right shift 8 bits */
- switch (keylo) {
- case 0: /* Fkey? */
- switch (keyhi) {
- case 59: /* F1 */
- return(101);
- case 60: /* F2 */
- return(102);
- case 61: /* F3 */
- return(103);
- case 62: /* F4 */
- return(104);
- case 63: /* F5 */
- return(105);
- case 64: /* F6 */
- return(106);
- case 65: /* F7 */
- return(107);
- case 66: /* F8 */
- return(108);
- case 67: /* F9 */
- return(109);
- case 68: /* F10 */
- return(110);
- default: /* undefined special key */
- input[0] = '\0';
- return(200);
- } /* switch */
- case 8: /* backspace */
- if (i > 0) {
- i--;
- gotoxy(x-1, y);
- clreol1(2);
- gotoxy(x-1, y);
- }
- break;
- case 10:
- case 13: /* CR/LF = return */
- input[i] = '\0';
- return(0); /* success: got string */
- case 9:
- case 32: /* kill spaces and tabs: single string input */
- gotoxy(x, y);
- printf("%c", keylo);
- break;
- default: /* ASCII char */
- gotoxy(x, y);
- printf("%c", keylo);
- input[i++] = keylo;
- } /* switch keylo */
- } /* while */
- } /* getusrstr */
-
- #else
-
- /********************************/
- /* function: getusrstr */
- /********************************/
- /* gets one user input string */
- getusrstr (input)
- char *input;
- {
- int i;
- char c;
-
- i = 0;
- while ((c=getc(stdin)) != '\n')
- if (c != ' ')
- input[i++] = c;
- input[i] = '\0';
- } /* getusrstr */
- #endif