home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / menu / cmenu / menudrv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-01  |  27.2 KB  |  694 lines

  1. /* menudrv.c */
  2.  
  3.     /*-------------------------------------------------------------------+
  4.     | Program:      menudrv  (PC menu driver)                            |
  5.     | Programmer:   John Queern, CIS 250-1, Belleville Area College      |
  6.     | Purpose:      To provide a simple, user-adjustable menu system     |
  7.     |               for an IBM PC-compatible which will allow you to     |
  8.     |               select programs or groups of programs by simply      |
  9.     |               pressing a key from the menu.                        |
  10.     |                                                                    |
  11.     | Date written: Jan-Mar '89 (C version)                              |
  12.     | Last changed: 3/30/89                                              |
  13.     | Notes:        placed in the public domain                          |
  14.     |               to compile, use Turbo C, and menudrv.prj proj file   |
  15.     |                                                                    |
  16.     +-------------------------------------------------------------------*/
  17.  
  18. /* Important!: use a memory model which employs far data pointers, so that
  19.    the video memory may be accessed directly using library functions;
  20.    possible choices: compact, large, or huge (I recommend compact) */
  21.  
  22. /* This version does not include the alarm/reminder facility; it has
  23.    been kept as short and simple as possible for classroom/diskette use;
  24.    Note: to make the executable even shorter, comment out the definition
  25.    of "editable" in menudrv.h. This will produce a menu which will not
  26.    permit the user to edit menu items. Very useful for the classroom! */
  27.  
  28. #include "menudrv.h"
  29. #include <alloc.h>
  30. #include <conio.h>
  31. #include <ctype.h>
  32. #include <dos.h>
  33. #include <bios.h>
  34. #include <process.h>
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <string.h>
  38.  
  39. /*========================================================================*/
  40. /* declarations */
  41.  
  42. char    mname[13][12] = { "December",
  43.         "January", "February", "March", "April", "May", "June",
  44.         "July", "August", "September", "October", "November", "December"
  45.         };
  46. char    wdname[8][12] = {"Sunday",
  47.         "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
  48.         "Saturday", "Sunday"
  49.         };
  50. int     days[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  51.  
  52. string80 blank =
  53. "                                                                                ";
  54. menuptr item[maxitem];
  55. char    edscreen[22][82];
  56. int     items;
  57. char    inpline[132], otline[132];
  58. string80  temp, temp2, resp;
  59. int     lines;
  60. FILE    *datafile;
  61. FILE    *batfile;
  62. FILE    *parmfile;
  63. int     month, day, year, weekday, hour, min, sec, lastsec, lastmin, hun;
  64. char    cmenu;
  65. char    citem;
  66. string40 cdescription;
  67. char    ctomenu;
  68. int     done, good, initialized, gotchild, datachanged, parmchanged;
  69. int     x,y,i,j,k,n,p,t,r;
  70. int     col;
  71. char    *cptr;
  72. unsigned char b;
  73. char    ch, c2, firstpass;
  74. unsigned char retcd;
  75. lineptr cp, np, op;
  76. menuitem tempitem;
  77. int     bfore, bback;
  78. char    holiday[13][32];
  79. char    specialday[13][32];
  80. int     insert=0;
  81.  
  82. string14    fore1, back1;     /*date/time, message colors*/
  83. string14    fore2, back2;     /*calendar, alarm box colors*/
  84. string14    fore3, back3;     /*selection item colors*/
  85. string14    fore4, back4;     /*colors for alarm items*/
  86. string14    fore5, back5;     /*colors for ed screen*/
  87. string14    fore6, back6;     /*colors for ed help screen*/
  88.  
  89. vptr    sbuff[5];              /*screen buffers*/
  90. char    monochrome;            /*mono flag*/
  91.  
  92. /*========================================================================*/
  93.  
  94. char *strdel(char st[],int start,int count)
  95. /* delete <count> chars from string <st> starting at <start> */
  96. {
  97.    int i,l;
  98.  
  99.    l = strlen(st);
  100.    for (i=start;i<l;i++) st[i] = st[i+count];
  101.  
  102. }
  103.  
  104. int nonblank (char *st)
  105. /* check a string to see if it contains anything except blanks; return
  106.    1 (=TRUE) if the string contains something nonblank; 0 (=FALSE) otherwise */
  107. {
  108.    int flag;
  109.    flag = FALSE;  /* assume everything is blank */
  110.    while ((*st!=0) && (flag==FALSE)) {
  111.      flag=((*st!=' ') && (*st!=0));
  112.      st++;
  113.    }
  114.    return flag;
  115. }
  116.  
  117. /*========================================================================*/
  118. /* call "stub" for missing functions -- a programmer's convenience */
  119.  
  120. void stub(void)
  121. {
  122.   sound(400);
  123.   delay(250);
  124.   sound(200);
  125.   delay(250);
  126.   nosound();
  127. }
  128.  
  129. /*========================================================================*/
  130.  
  131. void init(int argv, char *argc[])
  132. {
  133.     int    i,j;
  134.     FILE   *datfile;
  135.  
  136.     if (argv>1) cmenu=toupper(*argc[1]);
  137.     else cmenu='M';  /* first menu */
  138.     done=FALSE;
  139.  
  140.     /* establish default colors (getdata will replace if parms found) */
  141.     strcpy(fore1,"yellow");  /*date/time, message colors*/
  142.     strcpy(back1,"black");
  143.     strcpy(fore2,"cyan");    /*calendar, alarm box colors*/
  144.     strcpy(back2,"black");
  145.     strcpy(fore3,"green");   /*selection item colors*/
  146.     strcpy(back3,"black");
  147.     strcpy(fore4,"cyan");    /*colors for alarm items*/
  148.     strcpy(back4,"black");
  149.     strcpy(fore5,"white");   /*colors for ed screen*/
  150.     strcpy(back5,"red");
  151.     strcpy(fore6,"white");   /*colors for ed help screen*/
  152.     strcpy(back6,"blue");
  153.  
  154.     for (i=1;i<5;i++) sbuff[i]=calloc(1,sizeof(*(sbuff[i])));
  155.     getsysdate();
  156.     getdata();
  157.     firstpass=TRUE;
  158.     lastmin=0;
  159.     for (i=1;i<13;i++)
  160.       for (j=1;j<32;j++) {
  161.         holiday[i][j]=FALSE;
  162.         specialday[i][j]=FALSE;
  163.     }
  164.     /* set up holidays based on data files */
  165.     datfile = fopen("year.hol","r");
  166.     if (datfile!=NULL) {
  167.         while (fscanf(datfile,"%d %d",i,j)>0)
  168.             if ((i>0) && (i<13) && (j>0) && (j<31)) holiday[i][j]=TRUE;
  169.         fclose(datfile);
  170.     }
  171.     datfile=fopen("year.spc","r");
  172.     if (datfile!=NULL) {
  173.         while(fscanf(datfile,"%d %d",i,j)>0)
  174.             if ((i>0) && (i<13) && (j>0) &&(j<31)) specialday[i][j]=TRUE;
  175.     }
  176.  
  177.    datachanged = FALSE;
  178.    parmchanged = FALSE;
  179.  
  180. }
  181.  
  182. /*========================================================================*/
  183.  
  184. void display_menu()
  185. {
  186.  
  187. /*create the menu screen*/
  188.    border(color(back1));
  189.    bfore = color(fore1);
  190.    bback = color(back1);
  191.    bclear(1);
  192.  
  193. /*clear screen buffer 1*/
  194.    bcalendar(50,3);
  195.    getsystime();
  196.    dispdate();
  197.    bwrite(1,1,24," Press the key corresponding to your desired function.    Press End to exit.");
  198.  
  199. #ifdef editable
  200.    bwrite(1,1,25," F1=add/edit item       F2=del item      F3=move item      F4=edit colors   ");
  201. #else
  202.    bwrite(1,1,25,"                                                           F4=edit colors   ");
  203. #endif
  204.  
  205.    bfore = color(fore3);
  206.    bback = color(back3);
  207.    bwrite(1,1,3,"The following selections are available:");
  208.    y = 5;
  209.    i = 1;
  210.    while ( (i < items) && (item[i]->id != cmenu) ) i++;
  211.    if ( item[i]->id != cmenu ) {
  212.       cprintf("%s%c%c\n", "Cannot find information for menu ", cmenu, '.');
  213.       cprintf("%c", '\x07');
  214.       if ( cmenu == 'M' ) {
  215.          cprintf("%s", "Press any key to continue...");
  216.          ch=getch();
  217.          clrscr();
  218.          exit(1);
  219.       }
  220.       else {
  221.          cmenu = 'M';
  222.       }
  223.    }
  224.    else {       /*got initial value*/
  225.       j = i;    /*i=first entry for this menu*/
  226.       while ( (item[j]->id == cmenu) && (j <= items) ) {
  227.          sprintf(temp,"%c %-40s",item[j]->prompt,item[j]->description);
  228.          bwrite(1,1,y,temp);
  229.          y++;
  230.          j++;
  231.       }
  232.       good = FALSE;
  233.       bfore = color(fore1);
  234.       bback = color(back1);
  235.       bwrite(1,1,22,"Selection?             ");
  236.       restorescreen(1);
  237.    }
  238. }
  239.  
  240. /*========================================================================*/
  241.  
  242. void main(int argv,char *argc[])
  243. {
  244.    init(argv,argc);
  245.    binit();
  246.    do {
  247.       display_menu();
  248.       if ( item[i]->id == cmenu ) {
  249.          while ( ! good ) {
  250. L10:
  251.             if ( color(back1) > 7 ) textcolor(color(fore1) + blink);
  252.             else textcolor(color(fore1));
  253.             textbackground(color(back1));
  254.             gotoxy(12,22);
  255.             lastsec = sec;
  256.             while (  ! (bioskey(1))) {    /* while not keypressed */
  257.                getsystime();
  258.                if ( sec != lastsec ) {
  259.                   gotoxy(60,1);
  260.                   disptime();
  261.                   gotoxy(12,22);
  262.                   lastsec = sec;
  263.                }
  264.             }
  265.             firstpass = FALSE;
  266.             if ( color(back3) > 7 ) textcolor(color(fore3) + blink);
  267.             else textcolor(color(fore3));
  268.             textbackground(color(back3));
  269.             ch=getch();
  270.             if ( ch == 0 ) {  /*handle End and Function keys*/
  271.                c2=getch();
  272.                switch ( c2 ) {
  273.                   case '\x4F':      /*End*/
  274.                   {
  275.                         batfile = fopen(bfname,"w");
  276.                         fclose(batfile);
  277.                         clrscr();
  278.                         done = TRUE;
  279.                         goto L90;
  280.                      }
  281. #ifdef editable
  282.                   case '\x3B':      /*F1-add or edit item*/
  283.                      {
  284.                         gotoxy(1,22);
  285.                         clreol();
  286.                         cprintf("%s", "Add/edit what item code? ");
  287.                         citem=getch();
  288.                         if ( citem < '\x21' ) {
  289.                            cprintf("%c", '\x07');
  290.                            restorescreen(1);
  291.                            goto L10;
  292.                         }
  293.                         citem = toupper(citem);
  294.                         cprintf("%c", citem);
  295.                         j = i;
  296.                         /*look for match*/
  297.                         while ( (item[j]->prompt != citem)
  298.                            && (j < items) && (item[j]->id == cmenu) ) j++;
  299.                         if ( (item[j]->prompt != citem)
  300.                             || (item[j]->id != cmenu) ) {
  301.                             /*this is a new item*/
  302.                             for ( n = 1; n <= 19; n++ ) {
  303.                               /* blank the buffer lines */
  304.                               edscreen[n][0]=0;
  305.                               pad(edscreen[n],77);
  306.                            }
  307.                            cdescription[0] = 0;
  308.                            gotoxy(1,22);
  309.                            clreol();
  310.                            cprintf("%s", "Which item should this one follow? ");
  311.                            ch=getch();
  312.                            ch = toupper(ch);
  313.                            if ( ch == '\x0D' ) {
  314.                               /*top of menu*/
  315.                               j = 1;
  316.                               while ( (item[j]->id != cmenu) ) j++;
  317.                            }
  318.                            else {
  319.                               j = i;
  320.                               /*look for match*/
  321.                               while ( (item[j]->prompt != ch) &&
  322.                                 (j < items) && (item[j]->id == cmenu) ) j++;
  323.                               if ( item[j]->prompt != ch ) {
  324.                                  cprintf("%c", '\x07');
  325.                                  restorescreen(1);
  326.                                  goto L10;
  327.                               }
  328.                               j++;   /*position for new item*/
  329.                            }
  330.                            item[items + 1] = (menuptr) calloc(1,sizeof(*item[items + 1]));
  331.                            for ( n = items + 1; n >= j + 1; --n ) {
  332.                               *item[n] = *item[n - 1];
  333.                            }
  334.                            items++;
  335.                               {
  336.                                  item[j]->id = cmenu;
  337.                                  item[j]->prompt = citem;
  338.                                  item[j]->description[0] = 0;
  339.                                  item[j]->tomenu = '*';
  340.                                  item[j]->firstline = NULL;
  341.                               }
  342.                            do {
  343.                               gotoxy(1,22);
  344.                               clreol();
  345.                               cprintf("%s", "Is this item another menu? ");
  346.                               ch=getch();
  347.                               ch = toupper(ch);
  348.                               if ( ! ((ch=='Y') || (ch=='N')) ) putch(7);
  349.                            } while ( ! ((ch=='Y') || (ch=='N')) );
  350.                            if ( ch == 'Y' ) {
  351.                               /*adding a submenu reference*/
  352.                               cdescription[0] = 0;
  353.                               ctomenu = ' ';
  354.                               editmenu();
  355.                               ctomenu = toupper(ctomenu);
  356.                               citem = toupper(citem);
  357.                                  {
  358.                                     item[j]->id = cmenu;
  359.                                     item[j]->prompt = citem;
  360.                                     strcpy(item[j]->description,cdescription);
  361.                                     item[j]->tomenu = ctomenu;
  362.                                     item[j]->firstline = NULL;
  363.                                  }
  364.                               /*check to see if target menu exists*/
  365.                               n = 1;
  366.                               while ( (item[n]->id != ctomenu)
  367.                                 && (n < items) ) n++;
  368.                               if ( item[n]->id != ctomenu ) {
  369.                                  /*add one item for the new menu*/
  370.                                  item[items + 1] =
  371.                                    (menuptr) calloc(1,sizeof(*item[items + 1]));
  372.                                  items++;
  373.                                     {
  374.                                        item[items]->id = ctomenu;
  375.                                        item[items]->tomenu = 'M';
  376.                                        item[items]->prompt = 'X';
  377.                                        strcpy(item[items]->description,
  378.                                          "Return to Main Menu");
  379.                                        item[items]->firstline = NULL;
  380.                                     }
  381.                               }
  382.                               datachanged = TRUE;
  383.                               goto L90;
  384.                            }  /*if new menu entry*/
  385.                         }
  386.                         else {  /*old item*/
  387.                            if ( item[j]->tomenu != '*' ) {
  388.                               strcpy(cdescription,item[j]->description);
  389.                               ctomenu = item[j]->tomenu;
  390.                               editmenu();  /* ** */
  391.                               strcpy(item[j]->description,cdescription);
  392.                               item[j]->tomenu = ctomenu;
  393.                               item[j]->prompt = citem;
  394.                               datachanged = TRUE;
  395.                               goto L90;
  396.                            }
  397.                            /*load the item's data*/
  398.                            for ( n = 1; n <= 19; n++ ) {
  399.                               edscreen[n][0]=0;
  400.                               pad(edscreen[n],77);
  401.                            }
  402.                            cp = item[j]->firstline;
  403.                            i = 1;
  404.                            while ( (cp != NULL) && (i <= 19) ) {
  405.                               strcpy(edscreen[i],cp->line);
  406.                               pad(edscreen[i],77);
  407.                               cp = cp->next;
  408.                               i++;
  409.                            }
  410.                            strcpy(cdescription,item[j]->description);
  411.                         }
  412.                         edit();
  413.                         /*save results*/
  414.                         strcpy(item[j]->description,cdescription);
  415.                         cp = item[j]->firstline;
  416.                         i = 1;
  417.                         op = NULL;  /* op holds last valid pointer */
  418.                         while ( (cp != NULL) && (i <= 19) ) {
  419.                            strcpy(cp->line,edscreen[i]);
  420.                            op = cp;
  421.                            cp = cp->next;
  422.                            i++;
  423.                         }
  424.                         cp = op; /*restore last pointer*/
  425.                         /*catch any added lines*/
  426.                         for ( n = i; n <= 19; n++ ) {
  427.                            if ( nonblank(edscreen[n]) ) {
  428.                               np = (lineptr) calloc(1,sizeof(*np));
  429.                               strcpy(np->line,edscreen[n]);
  430.                               if ( item[j]->firstline == NULL ) {
  431.                                  item[j]->firstline = np;
  432.                               }
  433.                               else {
  434.                                  cp->next = np;
  435.                               }
  436.                               np->next = NULL;
  437.                               cp = np;
  438.                            }
  439.                         }
  440.                         datachanged = TRUE;
  441.                         goto L90;
  442.                      }
  443.                   case '\x3C':      /*F2-delete item*/
  444.                      {
  445.                         gotoxy(1,22);
  446.                         clreol();
  447.                         cprintf("%s", "Delete which item? ");
  448.                         citem=getch();
  449.                         cprintf("%c", citem);
  450.                         citem = toupper(citem);
  451.                         j = i;
  452.                         /*look for match*/
  453.                         while ( (item[j]->prompt != citem) && (j < items)
  454.                            && (item[j]->id == cmenu) ) j++;
  455.                         if ( item[j]->prompt != citem ) {
  456.                            cprintf("%c", '\x07');
  457.                            restorescreen(1);
  458.                            goto L10;
  459.                         }
  460.                         gotoxy(1,22);
  461.                         clreol();
  462.                         cprintf("%s%s%s", "Delete ",
  463.                           item[j]->description, " (Y/N)? ");
  464.                         ch=getch();
  465.                         ch = toupper(ch);
  466.                         if ( ch == 'Y' ) {
  467.                            /* free storage for deleted item's lines */
  468.                            cp = item[j]->firstline;
  469.                            while (cp != NULL) {
  470.                              op=cp->next;
  471.                              free(cp);
  472.                              cp=op;
  473.                            }
  474.                            /* shift everything down 1 */
  475.                            for ( n = j; n < items; n++) {
  476.                               *item[n] = *item[n + 1];
  477.                            }
  478.                            /* free storage for previous last item */
  479.                            free(item[items]);
  480.                            item[items]=NULL;
  481.                            items--;
  482.                            datachanged = TRUE;
  483.                         }
  484.                         goto L90;
  485.                      }
  486.                   case '\x3D':      /*F3 - move item*/
  487.                      {
  488.                         gotoxy(1,22);
  489.                         clreol();
  490.                         cprintf("%s", "Move which item? ");
  491.                         citem=getch();
  492.                         cprintf("%c", citem);
  493.                         citem = toupper(citem);
  494.                         j = i;
  495.                         /*look for match*/
  496.                         while ( (item[j]->prompt != citem) && (j < items)
  497.                            && (item[j]->id == cmenu) ) {
  498.                            j = j + 1;
  499.                         }
  500.                         if ( item[j]->prompt != citem ) {
  501.                             /*item not found*/
  502.                            gotoxy(1,22);
  503.                            cprintf("%s%s", "Item not found. ",
  504.                              "Press a key to continue.");
  505.                            ch=getch();
  506.                            restorescreen(1);
  507.                            goto L10;
  508.                         }
  509.                         gotoxy(1,22);
  510.                         clreol();
  511.                         cprintf("%s",
  512.                           "Which item should this one follow? ");
  513.                         ch=getch();
  514.                         ch = toupper(ch);
  515.                         if ( ch == '\x0D' ) {
  516.                            /*top of menu*/
  517.                            n = 1;
  518.                            while ( (item[n]->id != cmenu) ) n++;
  519.                         }
  520.                         else {
  521.                            n = i;
  522.                             /*look for match*/
  523.                            while ( (item[n]->prompt != ch) && (n < items)
  524.                               && (item[n]->id == cmenu) ) n++;
  525.                            if ( item[n]->prompt != ch ) {
  526.                               cprintf("%c", '\x07');
  527.                               restorescreen(1);
  528.                               goto L10;
  529.                            }
  530.                            n++; /*position for new item*/
  531.                         }
  532.                           /*item being moved is item[j]; we are */
  533.                           /*           moving it to position [n]*/
  534.                         tempitem = *item[j];  /*save item*/
  535.                         if ( n < j ) {
  536.                            for ( k = j; k >= n + 1; --k ) {
  537.                               *item[k] = *item[k - 1];
  538.                            }
  539.                            *item[n] = tempitem;
  540.                         }
  541.                         else {
  542.                            if ( j < n ) {
  543.                               n--;
  544.                               for ( k = j; k <= n - 1; ++k ) {
  545.                                  *item[k] = *item[k + 1];
  546.                               }
  547.                               *item[n] = tempitem;
  548.                            }
  549.                         }
  550.                         goto L90;
  551.                      }
  552. #endif
  553.                   case '\x3E':      /*F4-edit colors*/
  554.                      {
  555.                         editcolor();  /* ** */
  556.                         parmchanged = TRUE;
  557.                         goto L90;
  558.                      }
  559.                   default:
  560.                      goto L10;
  561.                } /*case*/
  562.             }  /*if #0*/
  563.             cprintf("%c", ch);
  564.             ch = toupper(ch);
  565.             j = i;  /*look for match*/
  566.             while ( (item[j]->prompt != ch) && (j < items)
  567.                && (item[j]->id == cmenu) ) j++;
  568.             if ( (item[j]->prompt != ch) || (item[j]->id != cmenu) ) {
  569.                cprintf("%c", '\x07');
  570.             }
  571.             else {
  572.                good = TRUE;
  573.             }
  574.          }  /*while not good*/
  575.  
  576.          /*user has selected item[j]*/
  577.          if ( item[j]->tomenu != '*' ) cmenu = item[j]->tomenu;
  578.          else {       /*doing action for the '*' item*/
  579.             cp = item[j]->firstline;
  580.             /*determine whether background job requested or not*/
  581.             if ( cp->line[0] == '&' ) gotchild = TRUE;
  582.             else gotchild = FALSE;
  583.             if ( ! gotchild ) batfile = fopen(bfname,"w");
  584.             while ( cp != NULL ) {
  585.                if ( strstr(cp->line,"[") == NULL ) {
  586.                   if ( gotchild ) strcpy(temp2,cp->line);
  587.                   else fprintf(batfile,"%s\n", cp->line);
  588.                }
  589.                else {  /*handle [xx] parameter passing*/
  590.                   strcpy(temp, cp->line);
  591.                   otline[0] = 0;
  592.                   do {
  593.                      cptr = strstr(temp,"[");
  594.                      if ( cptr == NULL ) strcat(otline,temp);
  595.                      else {
  596.                         *cptr=0;
  597.                         strcat(otline,temp);
  598.                         *cptr=' ';
  599.                         strdel(temp,0,cptr-temp+1);
  600.                         gotoxy(1,22);
  601.                         clreol();
  602.                         cptr = strstr(temp,"]");
  603.                         *cptr=0;
  604.                         cprintf("%s%c", temp, ' ');
  605.                         *cptr=' ';
  606.                         resp[0]=0;
  607.                         col=1;
  608.                         getstring(wherex(),wherey(),&col,resp,78-wherex());
  609.                         trim(resp);
  610.                         strcat(otline,resp);
  611.                         strdel(temp,0,cptr-temp+1);
  612.                         cptr = strstr(temp,"[");
  613.                      }  /*else*/
  614.                   } while ( cptr != NULL );
  615.                   if ( gotchild ) strcpy(temp2,otline);
  616.                   else fprintf(batfile,"%s\n",otline);
  617.  
  618.                }  /*else*/
  619.                if ( gotchild ) {  /*performing as a child process*/
  620.                   if ( temp2[0] == '&' ) strdel(temp2,0,1);
  621.                   for ( r = 23; r <= 25; ++r ) {
  622.                      gotoxy(1,r);
  623.                      clreol();
  624.                   }
  625.                   gotoxy(1,23);
  626.                   r = system(temp2);
  627.                   switch ( r ) {
  628.                      case 0:
  629.                         break;  /*ok*/
  630.                      case 1:
  631.                         {
  632.                            cprintf("%s%c","Invalid function", '\x07');
  633.                            cprintf("%s", "..Press a key to continue..");
  634.                            ch=getch();
  635.                         }
  636.                         break;
  637.                      case 2:
  638.                         {
  639.                            cprintf("%s%c","File/path not found", '\x07');
  640.                            cprintf("%s", "..Press a key to continue..");
  641.                            ch=getch();
  642.                         }
  643.                         break;
  644.                      case 8:
  645.                         {
  646.                            cprintf("%s%c","Not enough memory to load program", '\x07');
  647.                            cprintf("%s", "..Press a key to continue..");
  648.                            ch=getch();
  649.                         }
  650.                         break;
  651.                      case 10:
  652.                         {
  653.                            cprintf("%s%c", "Bad environment (greater than 32K)", '\x07');
  654.                            cprintf("%s", "..Press a key to continue..");
  655.                            ch=getch();
  656.                         }
  657.                         break;
  658.                      case 11:
  659.                         {
  660.                            cprintf("%s%c", "Illegal .EXE file format", '\x07');
  661.                            cprintf("%s", "..Press a key to continue..");
  662.                            ch=getch();
  663.                         }
  664.                         break;
  665.                      default:
  666.                         cprintf("%c", '\x07');
  667.                         break;
  668.                   } /*case*/
  669.                }    /*if gotchild*/
  670.                cp = cp->next;  /*follow linked list*/
  671.             }  /*while*/
  672.             if ( ! gotchild ) {
  673.                fclose(batfile);
  674.                done = TRUE; /*exit and execute batch file*/
  675.             } /*if not gotchild*/
  676.          }   /*else doing action*/
  677.       }    /*else got good menu*/
  678. L90:
  679.       ;
  680.    } while ( ! (done) );
  681.  
  682.    if ( color(back3) > 7 ) {
  683.       textcolor(color(fore3) + blink);
  684.    }
  685.    else {
  686.       textcolor(color(fore3));
  687.    }
  688.    textbackground(color(back3));
  689.    border(color(back3));
  690.    clrscr();
  691.    if ( datachanged ) savemenu();
  692.    if ( parmchanged ) saveparm();
  693. }
  694.