home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / MISC / NERVES.ZIP / NO87 / NSMENU.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-12  |  17.2 KB  |  826 lines

  1. #include "defn.h"
  2. #include "nsdata.c"
  3. #include "proto.h"
  4. #include "lsin.c"
  5. #include "lcos.c"
  6.  
  7. void nsmenu(void)
  8.  { /* main menu */
  9.   int i,j,k,m,done,msg;
  10.   enum asc_val asc;
  11.   char str[41];
  12.   char *p;
  13.   FILE *file;
  14.   struct neuron *np;
  15.   struct con *cp;
  16.   struct Iint *ip;
  17.   float f;
  18.  
  19.   msg = FALSE;
  20. display: /* display menu */
  21.   clrscr();
  22.   if (msg)
  23.    {
  24.     gotoxy(1,1);
  25.     cputs("Recording path not found, Press P to change");
  26.     msg = FALSE;
  27.    }
  28.   gotoxy(5,8);
  29.   textattr(WHITE);
  30.   cputs("R");
  31.   textattr(LIGHTGRAY);
  32.   cputs("ead files");
  33.   gotoxy(5,10);
  34.   textattr(WHITE);
  35.   cputs("W");
  36.   textattr(LIGHTGRAY);
  37.   cputs("rite files");
  38.   gotoxy(5,12);
  39.   textattr(WHITE);
  40.   cputs("N");
  41.   textattr(LIGHTGRAY);
  42.   cputs("euron data modification");
  43.   gotoxy(5,14);
  44.   textattr(WHITE);
  45.   cputs("E");
  46.   textattr(LIGHTGRAY);
  47.   cputs("nvironment specification");
  48.   gotoxy(5,16);
  49.   textattr(WHITE);
  50.   cputs("I");
  51.   textattr(LIGHTGRAY);
  52.   cputs("nitialize conditions");
  53.   gotoxy(5,18);
  54.   textattr(WHITE);
  55.   cputs("G");
  56.   textattr(LIGHTGRAY);
  57.   cputs("raph specification");
  58.   gotoxy(5,20);
  59.   textattr(WHITE);
  60.   cputs("P");
  61.   textattr(LIGHTGRAY);
  62.   cputs("ath specification for recording");
  63.   gotoxy(5,22);
  64.   textattr(WHITE);
  65.   cputs("S");
  66.   textattr(LIGHTGRAY);
  67.   cputs("imulate");
  68.   gotoxy(5,24);
  69.   textattr(WHITE);
  70.   cputs("Q");
  71.   textattr(LIGHTGRAY);
  72.   cputs("uit");
  73.   gotoxy(37,8);
  74.   if (neurfname[0])
  75.    cprintf("Neuron file: %s",neurfname);
  76.   gotoxy(37,9);
  77.   if (envfname[0])
  78.    cprintf("Environment file: %s",envfname);
  79.   gotoxy(37,10);
  80.   if (recpath[0])
  81.    cprintf("Recording path: %s",recpath);
  82.   erasecursor();
  83.  
  84.   /* get choice */
  85.   done = FALSE;
  86.   while (!done)
  87.    {
  88.     i = toupper(bioskey(0) & 0xff);
  89.     switch (i)
  90.      {
  91.       case 'R': /* read files */
  92. start: /* get the neuron filespec & read in */
  93.        gotoxy(1,1);
  94.        cputs("Enter neuron file spec:                                       ");
  95.        gotoxy(25,1);
  96.        j = 0;
  97.        while (!j)
  98.     j = bioskey(1);
  99.        asc = j & 0xff;
  100.        if (asc == ESC)
  101.     {
  102.      bioskey(0);
  103.      goto display;
  104.     }
  105.        else
  106.     if (asc == CR)
  107.      {
  108.       bioskey(0);
  109.       goto envfile;
  110.      }
  111.        str[0] = 25;
  112.        p = cgets(str);
  113.        file = fopen(p,"rb");
  114.        if (file == NULL)
  115.     goto start;
  116.        else
  117.     { /* read in file */
  118.      fread(&nn,2,1,file);
  119.      for (np=ns, j=0; j<nn; np++, j++)
  120.       {
  121.        fread(np,sizeof(struct neuron)-22,1,file);
  122.        np->iGmem = np->Gmem * 1e8 + .5;
  123.        np->iCmem = np->Cmem * 1e11 + .5;
  124.        np->iVt = np->Vt * 1e6 + fsgn(np->Vt)*.5;
  125.        np->iFmin = np->Fmin * 10000 + .5;
  126.        np->iGain = np->Gain * 1e-2 + .5;
  127.        np->ipI[0] = np->pI[0] * 1e13 + fsgn(np->pI[0])*.5;
  128.        np->ipI[1] = np->pI[1] * 1e13 + fsgn(np->pI[1])*.5;
  129.        np->imconst = np->mconst * 1e1 + fsgn(np->mconst)*.5;
  130.       }
  131.      fread(&ni,2,1,file);
  132.      for (ip=Iinta, j=0; j<ni; ip++, j++)
  133.       {
  134.        fread(ip,40,1,file);
  135.        ip->iIL = ip->IL * 1e11 + fsgn(ip->IL)*.5;
  136.        if (ip->type == 0)
  137.         ip->ipL[0] = ip->pL[0] * 1e6 + fsgn(ip->pL[0])*.5;
  138.        else
  139.         ip->ipL[0] = ip->pL[0] * 1e3 + .5;
  140.        ip->ipL[1] = ip->pL[1] * 1e3 + .5;
  141.        ip->ipL[2] = ip->pL[2] * 1e2 + .5;
  142.        ip->iIH = ip->IH * 1e11 + fsgn(ip->IH)*.5;
  143.        ip->ipH[0] = ip->pH[0] * 1e3 + .5;
  144.        ip->ipH[1] = ip->pH[1] * 1e3 + .5;
  145.       }
  146.      fread(&nc,2,1,file);
  147.      for (cp=cona, j=0; j<nc; cp++, j++)
  148.       {
  149.        fread(cp,sizeof(struct con)-4,1,file);
  150.        cp->iIsr = cp->Isr * 1e10 + fsgn(cp->Isr)*.5;
  151.        cp->iIcr = cp->Icr * 1e10 + fsgn(cp->Icr)*.5;
  152.       }
  153.      fclose(file);
  154.      /* change pointers */
  155.      for (j=0, np=ns; j<nn; j++, np++)
  156.       {
  157.        if (np->Iint != NULL)
  158.         np->Iint = Iinta + ((int)np->Iint - 1)/40;
  159.        if (np->con != NULL)
  160.         np->con = cona + ((int)np->con - 1)/32;
  161.       }
  162.      for (j=0, cp=cona; j<nc; j++, cp++)
  163.       {
  164.        if (cp->next != NULL)
  165.         cp->next = cona + ((int)cp->next - 1)/32;
  166.       }
  167.      strcpy(neurfname,p);
  168.      gotoxy(37,8);
  169.      cprintf("Neuron file: %s                                ",neurfname);
  170.     }
  171. envfile:
  172.        gotoxy(1,1);
  173.        cputs("Enter environment file spec:                                       ");
  174.        gotoxy(30,1);
  175.        j = 0;
  176.        while (!j)
  177.     j = bioskey(1);
  178.        asc = j & 0xff;
  179.        if (asc == ESC || asc == CR)
  180.     {
  181.      bioskey(0);
  182.      goto display;
  183.     }
  184.        str[0] = 25;
  185.        p = cgets(str);
  186.        file = fopen(p,"rb");
  187.        if (file == NULL)
  188.     goto envfile;
  189.        else
  190.     { /* read in file */
  191.      fread(&f,sizeof(float),1,file);
  192.      bug.x = f*1000. + .5;
  193.      fread(&f,sizeof(float),1,file);
  194.      bug.y = f*1000. + .5;
  195.      fread(&f,sizeof(float),1,file);
  196.      bug.ang = f*100000. + .5;
  197.      fread(&nfood,2,1,file);
  198.      fread(foodx,2,NFOOD,file);
  199.      fread(foody,2,NFOOD,file);
  200.      for (k=0; k<NFOOD; k++)
  201.       {
  202.        fread(&j,2,1,file);
  203.        foodsize[k] = (long)j * 10000L;
  204.       }
  205.      fread(&nblock,2,1,file);
  206.      fread(blockx,2,NBLOCK,file);
  207.      fread(blocky,2,NBLOCK,file);
  208.      fread(gr,sizeof(struct graph),5,file);
  209.      fclose(file);
  210.      strcpy(envfname,p);
  211.     }
  212.        goto display;
  213.       case 'W': /* write files */
  214.        gotoxy(1,1);
  215.        cputs("Write neuron file? ");
  216.        if (toupper(bioskey(0) & 0xff) != 'Y')
  217.     goto wenvfile;
  218.        /* write neuron file */
  219.        /* count neurons */
  220.        for (i=0, j=0, np=ns; i<nn; i++, np++)
  221.     if (np->name[0])
  222.      j++;
  223.        gotoxy(1,1);
  224.        if (neurfname[0])
  225.     {
  226.      cprintf("Save neurons to %s? ",neurfname);
  227.      i = toupper(bioskey(0) & 0xff);
  228.     }
  229.        if (!neurfname[0] || i != 'Y')
  230.     {
  231.      gotoxy(1,1);
  232.      cputs("Enter file spec:                                      ");
  233.      gotoxy(18,1);
  234.      str[0] = 38;
  235.      p = cgets(str);
  236.      strcpy(neurfname,p);
  237.     }
  238.        file = fopen(neurfname,"wb");
  239.        fwrite(&j,2,1,file);
  240.        for (i=0, np=ns; i<nn; i++, np++)
  241.     if (np->name[0])
  242.      {
  243.       fwrite(np,27,1,file);
  244.       if (np->Iint)
  245.        j = (int)np->Iint - (int)Iinta + 1;
  246.       else
  247.        j = 0;
  248.       fwrite(&j,2,1,file);
  249.       fwrite(&(np->Isens),18,1,file);
  250.       if (np->con)
  251.        j = (int)np->con - (int)cona + 1;
  252.       else
  253.        j = 0;
  254.       fwrite(&j,2,1,file);
  255.      }
  256.        fwrite(&ni,2,1,file);
  257.        for (i=0; i<ni; i++)
  258.     fwrite(Iinta+i,19,1,file);
  259.        fwrite(&nc,2,1,file);
  260.        for (i=0, cp=cona; i<nc; i++, cp++)
  261.     {
  262.      fwrite(cp,sizeof(struct con)-6,1,file);
  263.      if (cp->next)
  264.       j = (int)cp->next - (int)cona + 1;
  265.      else
  266.       j = 0;
  267.      fwrite(&j,2,1,file);
  268.     }
  269.        fclose(file);
  270. wenvfile: /* write environment file */
  271.        gotoxy(1,1);
  272.        cputs("Write environment file?                                    ");
  273.        gotoxy(1,25);
  274.        if (toupper(bioskey(0) & 0xff) != 'Y')
  275.     goto display;
  276.        gotoxy(1,1);
  277.        if (envfname[0])
  278.     {
  279.      cprintf("Save environment to %s? ",envfname);
  280.      j = toupper(bioskey(0) & 0xff);
  281.     }
  282.        if (!envfname[0] || j != 'Y')
  283.     {
  284.      gotoxy(1,1);
  285.      cputs("Enter file spec:                                      ");
  286.      gotoxy(18,1);
  287.      str[0] = 38;
  288.      p = cgets(str);
  289.      strcpy(envfname,p);
  290.     }
  291.        file = fopen(envfname,"wb");
  292.        f = (double)bug.x/1000.;
  293.        fwrite(&f,sizeof(float),1,file);
  294.        f = (double)bug.y/1000.;
  295.        fwrite(&f,sizeof(float),1,file);
  296.        f = (float)bug.ang/100000.;
  297.        fwrite(&f,sizeof(float),1,file);
  298.        fwrite(&nfood,2,1,file);
  299.        fwrite(foodx,2,NFOOD,file);
  300.        fwrite(foody,2,NFOOD,file);
  301.        for (k=0; k<NFOOD; k++)
  302.     {
  303.      j = foodsize[k]/10000L;
  304.      fwrite(&j,2,1,file);
  305.     }
  306.        fwrite(&nblock,2,1,file);
  307.        fwrite(blockx,2,NBLOCK,file);
  308.        fwrite(blocky,2,NBLOCK,file);
  309.        fwrite(gr,sizeof(struct graph),5,file);
  310.        fclose(file);
  311.        goto display;
  312.       case 'N': /* neuron data modification */
  313.        datamod();
  314.        goto display;
  315.       case 'E': /* environment set up */
  316. pent:  gotoxy(1,1);
  317.        cprintf("Enter number of food patches (0 - %d): %d   ",NFOOD,nfood);
  318.        gotoxy(39,1);
  319.        j = 0;
  320.        while (!j)
  321.     j = bioskey(1);
  322.        asc = j & 0xff;
  323.        if (asc == CR)
  324.     {
  325.      bioskey(0);
  326.      goto pdat;
  327.     }
  328.        else
  329.     if (asc == ESC)
  330.      {
  331.       bioskey(0);
  332.       goto display;
  333.      }
  334.        gotoxy(39,1);
  335.        cputs("   ");
  336.        gotoxy(39,1);
  337.        str[0] = 3;
  338.        p = cgets(str);
  339.        j = atoi(p);
  340.        if (j < 0 || j > NFOOD)
  341.     goto pent;
  342.        nfood = j;
  343. pdat:  clrline(1);
  344.        for (k=0; k<nfood; k++)
  345.     {
  346.      gotoxy(1,1);
  347.      cprintf("Food patch #%d",k+1);
  348. xpat:     gotoxy(1,2);
  349.      cprintf("Enter patch's x coordinate (0 - 956): %d   ",foodx[k]);
  350.      gotoxy(39,2);
  351.      j = 0;
  352.      while (!j)
  353.       j = bioskey(1);
  354.      asc = j & 0xff;
  355.      if (asc == CR)
  356.       {
  357.        bioskey(0);
  358.        goto ypat;
  359.       }
  360.      else
  361.       if (asc == ESC)
  362.        {
  363.         bioskey(0);
  364.         goto display;
  365.        }
  366.      gotoxy(39,2);
  367.      cputs("     ");
  368.      gotoxy(39,2);
  369.      str[0] = 4;
  370.      p = cgets(str);
  371.      j = atoi(p);
  372.      if (j < MINY || j > MAXX)
  373.       goto xpat;
  374.      foodx[k] = j;
  375.      gotoxy(39,2);
  376.      cprintf("%d",foodx[k]);
  377. ypat:     gotoxy(1,3);
  378.      cprintf("Enter patch's y coordinate (0 - 902): %d   ",foody[k]);
  379.      gotoxy(39,3);
  380.      j = 0;
  381.      while (!j)
  382.       j = bioskey(1);
  383.      asc = j & 0xff;
  384.      if (asc == CR)
  385.       {
  386.        bioskey(0);
  387.        goto patsiz;
  388.       }
  389.      else
  390.       if (asc == ESC)
  391.        {
  392.         bioskey(0);
  393.         goto display;
  394.        }
  395.      gotoxy(39,3);
  396.      cputs("     ");
  397.      gotoxy(39,3);
  398.      str[0] = 4;
  399.      p = cgets(str);
  400.      j = atoi(p);
  401.      if (j < MINY || j > MAXY)
  402.       goto ypat;
  403.      foody[k] = j;
  404.      gotoxy(39,3);
  405.      cprintf("%d",foody[k]);
  406. patsiz:     gotoxy(1,4);
  407.      cprintf("Enter size of patch (0 - 5000): %d   ",
  408.                  (int)(foodsize[k]/10000L));
  409.      gotoxy(33,4);
  410.      j = 0;
  411.      while (!j)
  412.       j = bioskey(1);
  413.      asc = j & 0xff;
  414.      if (asc == CR)
  415.       {
  416.        bioskey(0);
  417.        goto patdone;
  418.       }
  419.      else
  420.       if (asc == ESC)
  421.        {
  422.         bioskey(0);
  423.         goto display;
  424.        }
  425.      gotoxy(33,4);
  426.      cputs("     ");
  427.      gotoxy(33,4);
  428.      str[0] = 5;
  429.      p = cgets(str);
  430.      j = atoi(p);
  431.      if (j < 0 || j > 5000)
  432.       goto patsiz;
  433.      foodsize[k] = (long)j*10000L;
  434.      gotoxy(33,4);
  435.      cprintf("%d",j);
  436. patdone: clrline(1);
  437.      clrline(2);
  438.      clrline(3);
  439.      clrline(4);
  440.     }
  441. bent:  clrline(1);
  442.        gotoxy(1,1);
  443.        cprintf("Enter number of blocks (0 - %d): %d   ",NBLOCK,nblock);
  444.        gotoxy(33,1);
  445.        j = 0;
  446.        while (!j)
  447.     j = bioskey(1);
  448.        asc = j & 0xff;
  449.        if (asc == CR)
  450.     {
  451.      bioskey(0);
  452.      goto bdat;
  453.     }
  454.        else
  455.     if (asc == ESC)
  456.      {
  457.       bioskey(0);
  458.       goto display;
  459.      }
  460.        gotoxy(33,1);
  461.        cputs("   ");
  462.        gotoxy(33,1);
  463.        str[0] = 3;
  464.        p = cgets(str);
  465.        nblock = atoi(p);
  466.        if (nblock < 0 || nblock > NBLOCK)
  467.     goto bent;
  468. bdat:  clrline(1);
  469.        for (k=0; k<nblock; k++)
  470.     {
  471.      gotoxy(1,1);
  472.      cprintf("Block #%d",k+1);
  473. xblk:     gotoxy(1,2);
  474.      cprintf("Enter block's x coordinate (0 - 760): %d   ",blockx[k]);
  475.      gotoxy(39,2);
  476.      j = 0;
  477.      while (!j)
  478.       j = bioskey(1);
  479.      asc = j & 0xff;
  480.      if (asc == CR)
  481.       {
  482.        bioskey(0);
  483.        goto yblk;
  484.       }
  485.      else
  486.       if (asc == ESC)
  487.        {
  488.         bioskey(0);
  489.         goto display;
  490.        }
  491.      gotoxy(39,2);
  492.      cputs("     ");
  493.      gotoxy(39,2);
  494.      str[0] = 4;
  495.      p = cgets(str);
  496.      j = atoi(p);
  497.      if (j < 0 || j > 760)
  498.       goto xblk;
  499.      blockx[k] = j;
  500.      gotoxy(39,2);
  501.      cprintf("%d",blockx[k]);
  502. yblk:     gotoxy(1,3);
  503.      cprintf("Enter block's y coordinate (0 - 805): %d   ",blocky[k]);
  504.      gotoxy(39,3);
  505.      j = 0;
  506.      while (!j)
  507.       j = bioskey(1);
  508.      asc = j & 0xff;
  509.      if (asc == CR)
  510.       {
  511.        bioskey(0);
  512.        goto blockdone;
  513.       }
  514.      else
  515.       if (asc == ESC)
  516.        {
  517.         bioskey(0);
  518.         goto display;
  519.        }
  520.      gotoxy(39,3);
  521.      cputs("     ");
  522.      gotoxy(39,3);
  523.      str[0] = 4;
  524.      p = cgets(str);
  525.      j = atoi(p);
  526.      if (j < 0 || j > 805)
  527.       goto yblk;
  528.      blocky[k] = j;
  529.      gotoxy(39,3);
  530.      cprintf("%d",blocky[k]);
  531. blockdone: clrline(1);
  532.      clrline(2);
  533.      clrline(3);
  534.     }
  535.        goto display;
  536.       case 'I': /* initial conditions */
  537. xent:  gotoxy(1,1);
  538.        cprintf("Enter x coordinate of bug (80 - 880): %d    ",(int)(bug.x/1000L));
  539.        gotoxy(39,1);
  540.        j = 0;
  541.        while (!j)
  542.     j = bioskey(1);
  543.        asc = j & 0xff;
  544.        if (asc == CR)
  545.     {
  546.      bioskey(0);
  547.      goto yent;
  548.     }
  549.        else
  550.     if (asc == ESC)
  551.      {
  552.       bioskey(0);
  553.       goto display;
  554.      }
  555.        gotoxy(39,1);
  556.        cputs("      ");
  557.        gotoxy(39,1);
  558.        str[0] = 4;
  559.        p = cgets(str);
  560.        j = atoi(p);
  561.        if (j < 80 || j > 880)
  562.     goto xent;
  563.        bug.x = j*1000L;
  564.        gotoxy(39,1);
  565.        cprintf("%d",j);
  566. yent:  gotoxy(1,2);
  567.        cprintf("Enter y coordinate of bug (80 - 820): %d    ",(int)(bug.y/1000L));
  568.        gotoxy(39,2);
  569.        j = 0;
  570.        while (!j)
  571.     j = bioskey(1);
  572.        asc = j & 0xff;
  573.        if (asc == CR)
  574.     {
  575.      bioskey(0);
  576.      goto aent;
  577.     }
  578.        else
  579.     if (asc == ESC)
  580.      {
  581.       bioskey(0);
  582.       goto display;
  583.      }
  584.        gotoxy(39,2);
  585.        cputs("      ");
  586.        gotoxy(39,2);
  587.        str[0] = 4;
  588.        p = cgets(str);
  589.        j = atoi(p);
  590.        if (j < 80 || j > 820)
  591.     goto yent;
  592.        bug.y = j*1000L;
  593.        gotoxy(39,2);
  594.        cprintf("%d",j);
  595. aent:  gotoxy(1,3);
  596.        cprintf("Enter bug angle (0 - 359): %d    ",(int)(180L*(bug.ang/100L)/PI));
  597.        gotoxy(28,3);
  598.        j = 0;
  599.        while (!j)
  600.     j = bioskey(1);
  601.        asc = j & 0xff;
  602.        if (asc == CR)
  603.     {
  604.      bioskey(0);
  605.      goto eent;
  606.     }
  607.        else
  608.     if (asc == ESC)
  609.      goto display;
  610.        gotoxy(28,3);
  611.        cputs("      ");
  612.        gotoxy(28,3);
  613.        str[0] = 4;
  614.        p = cgets(str);
  615.        j = atoi(p);
  616.        if (j < 0 || j > 359)
  617.     goto aent;
  618.        bug.ang = ((PI*(long)j)/180L)*100L;
  619.        gotoxy(28,3);
  620.        cprintf("%d",j);
  621. eent:  gotoxy(1,4);
  622.        cprintf("Enter energy (100 - 999): %d    ",(int)(energy/10000L));
  623.        gotoxy(27,4);
  624.        j = 0;
  625.        while (!j)
  626.     j = bioskey(1);
  627.        asc = j & 0xff;
  628.        if (asc == CR || asc == ESC)
  629.     {
  630.      bioskey(0);
  631.      goto display;
  632.     }
  633.        gotoxy(27,4);
  634.        cputs("      ");
  635.        gotoxy(27,4);
  636.        str[0] = 4;
  637.        p = cgets(str);
  638.        j = atoi(p);
  639.        if (j < 100 || j > 999)
  640.     goto eent;
  641.        energy = j*10000L;
  642.        gotoxy(27,4);
  643.        cprintf("%d",j);
  644.        goto display;
  645.       case 'G': /* graph specification */
  646.        for (k=0; k<5; k++)
  647.     {
  648.      gotoxy(1,1);
  649.      cprintf("Graph #%d",k+1);
  650. gtent:     gotoxy(1,2);
  651.      cprintf("Enter graph type (0=None, 1=Variable, 2=Gait): %d   ",gr[k].gtype);
  652.      gotoxy(48,2);
  653.      j = 0;
  654.      while (!j)
  655.       j = bioskey(1);
  656.      asc = j & 0xff;
  657.      if (asc == CR)
  658.       {
  659.        bioskey(0);
  660.        if (gr[k].gtype != 1)
  661.         goto grend;
  662.        goto gneur;
  663.       }
  664.      else
  665.       if (asc == ESC)
  666.        {
  667.         bioskey(0);
  668.         goto display;
  669.        }
  670.      gotoxy(48,2);
  671.      cputs("      ");
  672.      gotoxy(48,2);
  673.      str[0] = 2;
  674.      p = cgets(str);
  675.      j = atoi(p);
  676.      if (j < 0 || j > 2)
  677.       goto gtent;
  678.      gr[k].gtype = j;
  679.      gotoxy(48,2);
  680.      cprintf("%d",gr[k].gtype);
  681.      if (gr[k].gtype != 1)
  682.       goto grend;
  683. gneur:   gotoxy(1,3);
  684.      cprintf("Enter neuron name: %s       ",gr[k].gneur);
  685.      gotoxy(20,3);
  686.      j = 0;
  687.      while (!j)
  688.       j = bioskey(1);
  689.      asc = j & 0xff;
  690.      if (asc == CR)
  691.       {
  692.        bioskey(0);
  693.        goto gvar;
  694.       }
  695.      else
  696.       if (asc == ESC)
  697.        {
  698.         bioskey(0);
  699.         goto display;
  700.        }
  701.      gotoxy(20,3);
  702.      cputs("      ");
  703.      gotoxy(20,3);
  704.      str[0] = 7;
  705.      p = cgets(str);
  706.      strcpy(gr[k].gneur,p);
  707. gvar:    gotoxy(1,4);
  708.      cprintf("Enter variable (0=V [milliV], 1=F, 2=I [pA]): %d",gr[k].gvar);
  709.      gotoxy(47,4);
  710.      j = 0;
  711.      while (!j)
  712.       j = bioskey(1);
  713.      asc = j & 0xff;
  714.      if (asc == CR)
  715.       {
  716.        bioskey(0);
  717.        if (gr[k].gvar == 1)
  718.         goto grend;
  719.        goto gscale;
  720.       }
  721.      else
  722.       if (asc == ESC)
  723.        {
  724.         bioskey(0);
  725.         goto display;
  726.        }
  727.      gotoxy(47,4);
  728.      cputs("      ");
  729.      gotoxy(47,4);
  730.      str[0] = 2;
  731.      p = cgets(str);
  732.      j = atoi(p);
  733.      if (j < 0 || j > 2)
  734.       goto gvar;
  735.      gr[k].gvar = j;
  736.      gotoxy(47,4);
  737.      cprintf("%d",gr[k].gvar);
  738.      if (gr[k].gvar == 1)
  739.       goto grend;
  740. gscale:  gotoxy(1,5);
  741.      gr[k].gscale = 50;
  742.      cprintf("Enter scale (1 - 300): %d",gr[k].gscale);
  743.      gotoxy(24,5);
  744.      j = 0;
  745.      while (!j)
  746.       j = bioskey(1);
  747.      asc = j & 0xff;
  748.      if (asc == CR)
  749.       {
  750.        bioskey(0);
  751.        goto grend;
  752.       }
  753.      else
  754.       if (asc == ESC)
  755.        {
  756.         bioskey(0);
  757.         goto display;
  758.        }
  759.      gotoxy(24,5);
  760.      cputs("      ");
  761.      gotoxy(24,5);
  762.      str[0] = 10;
  763.      p = cgets(str);
  764.      m = atoi(p);
  765.      if (m < 1 || m > 300)
  766.       goto gscale;
  767.      gr[k].gscale = m;
  768.      gotoxy(24,5);
  769.      cprintf("%d",gr[k].gscale);
  770. grend:   clrline(1);
  771.      clrline(2);
  772.      clrline(3);
  773.      clrline(4);
  774.      clrline(5);
  775.     }
  776.        goto display;
  777.       case 'P': /* path for recording */
  778.        gotoxy(1,1);
  779.        cputs("Enter recording path:                                       ");
  780.        gotoxy(23,1);
  781.        j = 0;
  782.        while (!j)
  783.     j = bioskey(1);
  784.        asc = j & 0xff;
  785.        if (asc == ESC || asc == CR)
  786.     {
  787.      bioskey(0);
  788.      goto display;
  789.     }
  790.        str[0] = 25;
  791.        p = cgets(str);
  792.        strcpy(recpath,p);
  793.        i = strlen(recpath) - 1;
  794.        if (recpath[i] == '\\')
  795.     recpath[i] = 0; /* get rid of final \ */
  796.        goto display;
  797.       case 'S': /* simulate */
  798.        msg = initsim();
  799.        closegraph();
  800.        goto display;
  801.       case 'Q': /* quit */
  802.        done = TRUE;
  803.        break;
  804.       default:
  805.        break;
  806.      }
  807.    }
  808.  }
  809.  
  810. void erasecursor(void)
  811.  {
  812.   union REGS regs;
  813.  
  814.   regs.x.bx = 0;
  815.   regs.x.dx = 0x1900;
  816.   regs.x.ax = 0x200;
  817.   int86(0x10,®s,®s);
  818.  }
  819.  
  820. void clrline(int n)
  821.  {
  822.   gotoxy(1,n);
  823.   cputs("                                                              ");
  824.  }
  825.  
  826.