home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / graphics / tcxl.arc / TCXLDEMO.C < prev    next >
C/C++ Source or Header  |  1988-05-12  |  23KB  |  609 lines

  1. /*
  2.  
  3.         TCXLDEMO.C  - A demonstration program of the TCXL function library.
  4.  
  5.                         (c) 1987, 1988  by Mike Smedley
  6.  
  7.         To compile:
  8.  
  9.             from the command line type:  tcc tcxldemo tcxl.lib
  10.                                               or:
  11.                                          make -ftcxldemo
  12.  
  13.                                     or:
  14.  
  15.             from the environment, specify 'TCXLDEMO.PRJ' as the Project Name
  16.  
  17. */
  18.  
  19. #include <conio.h>
  20. #include <dos.h>
  21. #include <process.h>
  22. #include <stdio.h>
  23. #include "tcxldef.h"
  24. #include "tcxlkey.h"
  25. #include "tcxlvid.h"
  26. #include "tcxlwin.h"
  27.  
  28. void interrupt exit_prog(void);
  29. void error_exit(void);
  30. void pulldown_demo(void);
  31.  
  32. int row,col,*sbuf1;                                    /*  global variables  */
  33.  
  34. main() 
  35. {
  36.     register int i,j;
  37.     int ch;
  38.     int whandle[10];
  39.     int *sbuf2;
  40.     char *fname="        ";
  41.     char *mi=" ";
  42.     char *lname="              ";
  43.     char *phone="          ";
  44.     char *pressakey="Press a key";
  45.     char *spaces=  "           ";
  46.  
  47.  
  48.     videoinit();                    /*  initialize video  */
  49.     sbuf1=ssave();                  /*  save current screen contents  */
  50.     if(!sbuf1) error_exit();
  51.     readcur(&row,&col);             /*  save current cursor position  */
  52.     setcursz(32,0);                 /*  turn off cursor  */
  53.     setvect(0x23,exit_prog);        /*  redirect Ctrl-Break interrupt  */
  54.     setcbrk(ON);                    /*  set Ctrl-Break checking on  */
  55.     for(;;) {
  56.  
  57.         /*  open up opening screen windows  */
  58.  
  59.         for(i=0;i<6;i++) {
  60.             whandle[i]=wopen(i,i+10,i+13,i+47,3,LCYAN|_BLUE);
  61.             if(!whandle[i]) error_exit();
  62.  
  63.             /*  sound tones of increasing pitch  */
  64.  
  65.             sound_(15000-((i+2)*1500),1);
  66.             sound_(12000-((i+1)*1500),1);
  67.         }
  68.  
  69.         wprints(0,16,LRED,"TCXL");
  70.         wprints(1,2,LGREEN,"An Extended Library of Functions");
  71.         wprints(2,12,LGREEN,"for Turbo C");
  72.         wprints(4,10,YELLOW,"by Mike Smedley");
  73.         wprints(6,0,LMAGENTA,"(c) 1987, 1988 - All Rights Reserved");
  74.         wprints(8,7,WHITE,"Demonstration Program");
  75.         wprints(10,7,LCYAN|_BLUE,"Press any key to begin");
  76.  
  77.         /*  change colors of prompt until a key is pressed  */
  78.  
  79.         i=LBLUE;
  80.         for(;;) {
  81.             gotoxy_(16,22);
  82.             setattr(i|_BLUE,23);
  83.             delay_(2);
  84.             if(kbhit()) {
  85.                 ch=getch();
  86.                 break;
  87.             }
  88.             i++;
  89.             if(i>WHITE) i=LBLUE;
  90.         }
  91.         if(ch==ESC) exit_prog();             /*  see if Esc key was pressed  */
  92.         wprints(10,7,_BLUE,"                       ");
  93.  
  94.         /*  scroll the window's text up and out of the window  */
  95.  
  96.         for(i=0;i<10;i++) {
  97.             wscroll(1,UP);
  98.             delay_(2);
  99.         }
  100.  
  101.         /*  close all open windows */
  102.  
  103.         for(i=5;i>=0;i--) {
  104.             wclose();
  105.             delay_(2);
  106.         }
  107.  
  108.  
  109.         /*  open demo window 0 and demonstrate text wraparound and
  110.             scrolling from within a window                          */
  111.  
  112.         whandle[0]=wopen(1,1,11,41,0,LMAGENTA|_RED);
  113.         if(!whandle[0]) error_exit();
  114.         wtextattr(LCYAN|_RED);
  115.         wprintf("\n TCXL's window display functions like"
  116.                 "\n wprintf() & wputs() allow wrap-around"
  117.                 "\n and scrolling from within windows.");
  118.         wprints(7,14,YELLOW|BLINK|_RED,pressakey);
  119.         if(waitkeyt(273)==ESC) exit_prog();
  120.         wprints(7,14,_RED,spaces);
  121.         wgotoxy(8,0);
  122.           for(i=0;i<15;i++) {
  123.             if(kbhit()) {
  124.                 if(getch()==ESC) exit_prog();
  125.                 break;
  126.             }
  127.             for(j=DGREY;j<=WHITE;j++) {
  128.                 wtextattr(j|_RED);
  129.                 wputs("TCXL   ");
  130.                 delay_(1);
  131.             }
  132.         }
  133.  
  134.  
  135.         /*  open demo window 1 and demonstrate changing of window attribute  */
  136.  
  137.         whandle[1]=wopen(14,35,23,65,2,YELLOW|_BLUE);
  138.         if(!whandle[1]) error_exit();
  139.         wtextattr(LCYAN|_BLUE);
  140.         wputs("\n  The wchgattr() function"
  141.               "\n  allows you to change the"
  142.               "\n  attribute of the active"
  143.               "\n  window.");
  144.         wprints(6,9,YELLOW|BLINK|_BLUE,pressakey);
  145.         if(waitkeyt(273)==ESC) exit_prog();
  146.         wprints(6,9,_BLUE,spaces);
  147.         wchgattr(WHITE|_GREEN);
  148.         delay_(12);
  149.         wchgattr(LMAGENTA|_RED);
  150.         delay_(12);
  151.         wchgattr(LCYAN|_BLUE);
  152.         if(kbhit()) {                               /*  check for keypress  */
  153.             if(getch()==ESC) exit_prog();
  154.         }
  155.         delay_(12);
  156.         wchgattr(YELLOW|_MAGENTA);
  157.         delay_(12);
  158.         wchgattr(WHITE|_LGREY);
  159.         delay_(12);
  160.  
  161.         /*  open demo window 2 and demonstrate window titles
  162.             and resizing of windows                           */
  163.  
  164.         whandle[2]=wopen(5,20,19,45,3,LCYAN|_GREEN);
  165.         if(!whandle[2]) error_exit();
  166.         wtextattr(WHITE|_GREEN);
  167.         wputs("\n  The wtitle() function"
  168.               "\n  allows you to give a"
  169.               "\n  window a title.");
  170.         wprints(5,6,YELLOW|BLINK|_GREEN,pressakey);
  171.         if(waitkeyt(273)==ESC) exit_prog();
  172.         wprints(5,6,_GREEN,spaces);
  173.         wtitle("[ My Title ]",TLEFT);
  174.         delay_(18);
  175.         wtitle("[ My Title ]",TRIGHT);
  176.         delay_(18);
  177.         wtitle("[ My Title ]",TCENTER);
  178.         wtextattr(LGREEN|_GREEN);
  179.         wputs("\n\n\n  The wsize() function"
  180.                   "\n  allows you to resize"
  181.                   "\n  the active window.");
  182.         wprints(10,6,YELLOW|BLINK|_GREEN,pressakey);
  183.         if(waitkeyt(273)==ESC) exit_prog();
  184.         wprints(10,6,_GREEN,spaces);
  185.         wsize(19,60);
  186.         delay_(12);;
  187.         wsize(19,75);
  188.         delay_(12);;
  189.         wsize(24,75);
  190.         delay_(12);;
  191.         wsize(24,60);
  192.         delay_(12);;
  193.         wsize(24,45);
  194.         delay_(12);;
  195.         wsize(19,45);
  196.         delay_(12);;
  197.  
  198.  
  199.         /*  open demo window 3 and demonstrate multi-field keyboard input  */
  200.  
  201.         whandle[3]=wopen(12,10,23,50,1,LCYAN|_BLUE);
  202.         if(!whandle[3]) error_exit();
  203.         wtextattr(LMAGENTA|_BLUE);
  204.         wputs("\n    The winpdef() and winpread()"
  205.               "\n    functions allow multi-field"
  206.               "\n    keyboard input.");
  207.         wprints(3,21,YELLOW|BLINK|_BLUE,pressakey);
  208.         if(waitkeyt(273)==ESC) exit_prog();
  209.         wprints(3,21,_BLUE,spaces);
  210.         wprints(5,2,LCYAN|_BLUE,"First name?");
  211.         if(winpdef(5,15,fname,'M',BLACK|_LGREY)) error_exit();
  212.         wprints(5,26,LCYAN|_BLUE,"MI?");
  213.         if(winpdef(5,31,mi,'U',BLACK|_LGREY)) error_exit();
  214.         wprints(7,2,LCYAN|_BLUE,"Last name?");
  215.         if(winpdef(7,15,lname,'M',BLACK|_LGREY)) error_exit();
  216.         wtextattr(LGREEN|_BLUE);
  217.         setcursz(6,7);                          /*  turn cursor on  */
  218.         i=winpread();
  219.         setcursz(32,0);                         /*  turn cursor back off  */
  220.         if(i) exit_prog();                      /*  check for Esc press  */
  221.  
  222.  
  223.         /*  open demo window 4 and demonstrate controlled keyboard input  */
  224.  
  225.         whandle[4]=wopen(8,41,16,78,3,WHITE|_MAGENTA);
  226.         if(!whandle[4]) error_exit();
  227.         wtextattr(LGREEN|_MAGENTA);
  228.         wputs("\n  For complete control of keyboard"
  229.               "\n  input, there is the winputsf()"
  230.               "\n  function.  ");
  231.         wprints(3,13,YELLOW|BLINK|_MAGENTA,pressakey);
  232.         if(waitkeyt(273)==ESC) exit_prog();
  233.         wprints(3,13,_MAGENTA,spaces);
  234.         wtextattr(WHITE|_MAGENTA);
  235.         setcursz(6,7);                                   /*  turn cursor on  */
  236.         i=winputsf(phone," '\n\n  Phone number?  ' !R-! "
  237.             " !-! '(' !+! ### !-! ') ' !+! ### !-! '-' !+! #### ");
  238.         setcursz(32,0);                            /*  turn cursor back off  */
  239.         if(i) exit_prog();                      /*  check for Esc press  */
  240.  
  241.         /*  clear window 4 and demonstrate text line drawing  */
  242.  
  243.         wclear();
  244.         wsize(22,78);
  245.         wtextattr(LGREEN|_MAGENTA);
  246.         wputs("\n The whline() & wvline() functions"
  247.               "\n are used for drawing 'smart' text"
  248.               "\n lines inside the active window.");
  249.         wprints(5,12,YELLOW|BLINK|_MAGENTA,pressakey);
  250.         if(waitkeyt(273)==ESC) exit_prog();
  251.         wprints(5,12,_MAGENTA,spaces);
  252.         wtextattr(LCYAN|_MAGENTA);
  253.         whline(6,2,23,3);
  254.         delay_(18);
  255.         wvline(5,5,7,3);
  256.         delay_(18);
  257.         whline(10,1,25,3);
  258.         delay_(18);
  259.         wtextattr(LBLUE|_MAGENTA);
  260.         if(kbhit()) {                               /*  check for keypress  */
  261.             if(getch()==ESC) exit_prog();
  262.         }
  263.         wvline(6,25,5,3);
  264.         delay_(18);
  265.         whline(8,5,21,3);
  266.         delay_(18);
  267.         wvline(5,16,6,3);
  268.         delay_(18);
  269.         wtextattr(LGREEN|_MAGENTA);
  270.         whline(7,2,15,3);
  271.         delay_(18);
  272.         whline(5,9,15,3);
  273.         if(waitkeyt(108)==ESC) exit_prog();
  274.  
  275.         /*  clear window 4 and demonstrate pull-down & bar-selection menus  */
  276.  
  277.         wclear();
  278.         wtextattr(LGREEN|_MAGENTA);
  279.         wputs("\n  With the wmbardef() & wmbarget()"
  280.               "\n  functions, you can make pull-down"
  281.               "\n  and bar-select menus.");
  282.         wprints(5,12,YELLOW|BLINK|_MAGENTA,pressakey);
  283.         if(waitkeyt(273)==ESC) exit_prog();
  284.         pulldown_demo();
  285.         if(waitkeyt(273)==ESC) exit_prog();
  286.         wprints(5,12,_MAGENTA,spaces);
  287.         wprints(3,24,YELLOW|_MAGENTA,"Select one:");
  288.         wmbardef(5,3,LCYAN|_MAGENTA,"Add record",'A');
  289.         wmbardef(5,18,LCYAN|_MAGENTA,"Show record",'S');
  290.         wmbardef(7,3,LCYAN|_MAGENTA,"Delete record",'D');
  291.         wmbardef(7,18,LCYAN|_MAGENTA,"Update record",'U');
  292.         wmbardef(9,3,LCYAN|_MAGENTA,"Print record",'P');
  293.         wmbardef(9,18,LCYAN|_MAGENTA,"Quit program",'Q');
  294.         i=wmbarget(LCYAN|_LGREY,'A',NO);
  295.         wprints(3,24,_MAGENTA,spaces);
  296.         if(!i) exit_prog();
  297.         wgotoxy(11,10);
  298.         wtextattr(WHITE|_MAGENTA);
  299.         wprintf("You selected %c!",i);
  300.         delay_(12);
  301.  
  302.         /*  open demo window 5 and demonstrate screen swapping  */
  303.  
  304.         whandle[5]=wopen(3,3,12,33,0,YELLOW|_BLACK);
  305.         if(!whandle[5]) error_exit();
  306.         wtextattr(LCYAN|_BLACK);
  307.         wputs("\n  The ssave() and srestore()"
  308.               "\n  functions allow screen"
  309.               "\n  swapping to/from memory.");
  310.         wprints(5,8,LRED|BLINK|_BLACK,pressakey);
  311.         if(waitkeyt(273)==ESC) exit_prog();
  312.         wprints(5,8,_BLACK,spaces);
  313.         sbuf2=ssave();
  314.         if(!sbuf2) error_exit();
  315.         gotoxy_(24,79);
  316.         clrscrn();
  317.         prints(10,27,LMAGENTA,"Press a key to return");
  318.         if(waitkeyt(273)==ESC) exit_prog();
  319.         srestore(sbuf2);
  320.  
  321.  
  322.         /*  open demo window 6 and demonstrate activating of windows  */
  323.  
  324.         whandle[6]=wopen(11,48,21,77,1,LCYAN|_CYAN);
  325.         wtextattr(WHITE|_CYAN);
  326.         wputs("\n TCXL's wactiv() is used to"
  327.               "\n activate a window, making"
  328.               "\n it available for windowing"
  329.               "\n operations.");
  330.         wprints(4,14,YELLOW|BLINK|_CYAN,pressakey);
  331.         if(waitkeyt(273)==ESC) exit_prog();
  332.         wprints(4,14,_CYAN,spaces);
  333.         for(i=0;i<=6;i++) {
  334.             if(kbhit()) {                            /*  check for keypress  */
  335.                 if(getch()==ESC) exit_prog();
  336.             }
  337.             if(wactiv(whandle[i])) error_exit();
  338.             delay_(15);
  339.         }
  340.  
  341.  
  342.         /*  open demo window 7 and demonstrate moving of active window  */
  343.  
  344.         whandle[7]=wopen(4,2,16,35,2,LGREEN|_BROWN);
  345.         if(!whandle[7]) error_exit();
  346.         wtextattr(WHITE|_BROWN);
  347.         wputs("\n To move the active window,"
  348.               "\n the wmove() function is"
  349.               "\n used.");
  350.         wprints(3,8,YELLOW|BLINK|_BROWN,pressakey);
  351.         if(waitkeyt(273)==ESC) exit_prog();
  352.         wprints(3,8,_BROWN,spaces);
  353.         if(wmove(0,0)) error_exit();
  354.         delay_(12);
  355.         if(wmove(10,4)) error_exit();
  356.         delay_(12);
  357.         if(wmove(6,19)) error_exit();
  358.         delay_(12);
  359.         if(kbhit()) {                               /*  check for keypress  */
  360.             if(getch()==ESC) exit_prog();
  361.         }
  362.         if(wmove(1,13)) error_exit();
  363.         delay_(12);
  364.         if(wmove(2,35)) error_exit();
  365.         delay_(12);
  366.         if(wmove(11,35)) error_exit();
  367.         delay_(12);
  368.  
  369.  
  370.         /*  demonstrate making copies of the same window  */
  371.  
  372.         wtextattr(LRED|_BROWN);
  373.         wputs("\n\n The wcopy() function will"
  374.                 "\n create a duplicate of the"
  375.                 "\n active window.");
  376.         wprints(7,17,YELLOW|BLINK|_BROWN,pressakey);
  377.         if(waitkeyt(273)==ESC) exit_prog();
  378.         wprints(7,17,_BROWN,spaces);
  379.         whandle[8]=wcopy(0,0);
  380.         if(!whandle[8]) error_exit();
  381.         delay_(12);
  382.         whandle[9]=wcopy(1,37);
  383.         if(!whandle[9]) error_exit();
  384.         if(kbhit()) {                               /*  check for keypress  */
  385.             if(getch()==ESC) exit_prog();
  386.         }
  387.         delay_(18);
  388.         wclose();                                      /*  close copies  */
  389.         delay_(12);
  390.         wclose();
  391.         delay_(12);
  392.  
  393.  
  394.         /*  close all windows except window 0  */
  395.  
  396.         while(wnopen()>1) {
  397.             if(kbhit()) {
  398.                 if(getch()==ESC) exit_prog();
  399.             }
  400.             wclose();
  401.             delay_(6);
  402.         }
  403.  
  404.  
  405.         /*  list other features of TCXL  */
  406.  
  407.         wclear();
  408.         wputs("  Other features of TCXL include:\n");
  409.         wtextattr(LGREEN|_RED);
  410.         wputs("\n  - EGA 43 & VGA 50 line modes"
  411.               "\n  - expanded memory usage"
  412.               "\n  - screen/window swapping to disk"
  413.               "\n  - advanced string manipulation"
  414.               "\n  - equipment detection"
  415.               "\n  - mouse functions"
  416.               "\n  - printer functions");
  417.         wprints(8,26,YELLOW|BLINK|_RED,pressakey);
  418.         if(waitkeyt(273)==ESC) exit_prog();
  419.         wprints(8,26,_RED,spaces);
  420.  
  421.  
  422.         /*  get response from the keyboard, controlling input  */
  423.  
  424.         wclear();
  425.         if(wmove(7,19)) error_exit();
  426.         wgotoxy(3,11);
  427.         wtextattr(WHITE|_RED);
  428.         wputs("View demo again?  ");
  429.         setcursz(7,1);                           /*  turn cursor on  */
  430.         clearkeys();                             /*  clear keyboard buffer  */
  431.         ch=wgetchf("YyNn");                      /*  get keyboard response  */
  432.         setcursz(32,0);                          /*  turn cursor back off  */
  433.         if(ch==ESC) exit_prog();                 /*  see if Esc was pressed  */
  434.         wclose();
  435.         if(ch=='Y'||ch=='y') {
  436.         }
  437.         else {
  438.             exit_prog();
  439.         }
  440.     }
  441. }
  442.  
  443. /*  This function is the demonstration of pull-down windows   */
  444.  
  445. void pulldown_demo(void)
  446. {
  447.     char m1,m2;
  448.  
  449.     if(!wopen(0,0,24,79,2,CYAN)) error_exit();
  450.     wprints(0,0,_BLUE,"                                        "
  451.                       "                                      ");
  452.     wprints(1,0,CYAN,"────────────────────────────────────────"
  453.                       "──────────────────────────────────────");
  454.     wgotoxy(2,0);
  455.     wtextattr(YELLOW);
  456.     wputs("This is a sample editor interface to demonstrate how TCXL's "
  457.           "wmbardef()\n"
  458.           "and wmbarget() functions can be used for pull-down menus.  "
  459.           "Use arrow keys\n"
  460.           "to move selection bar around and use the Esc key to exit the "
  461.           "menu you are\n"
  462.           "currently in.  Any selection from a pull-down menu will return "
  463.           "you to demo.");
  464.     m1='F';                         /* initialize selection bar position  */
  465.     m2=PDMAIN;
  466.     top:
  467.     wmbardef(0,2,YELLOW|_BLUE,"File",'F');      /* define main menu */
  468.     wmbardef(0,15,YELLOW|_BLUE,"Editing",'E');
  469.     wmbardef(0,31,YELLOW|_BLUE,"Defaults",'D');
  470.     wmbardef(0,47,YELLOW|_BLUE,"Help",'H');
  471.     wmbardef(0,59,YELLOW|_BLUE,"Options",'O');
  472.     if(wmbardef(0,73,YELLOW|_BLUE,"Quit",'Q')) error_exit();
  473.     m1=wmbarget(YELLOW|_MAGENTA,m1,m2);
  474.     switch(m1) {          /*  test return value from main (horizontal) menu  */
  475.         case 'F':                    /* define pull-down menu for option 'F' */
  476.             if(!wopen(2,1,11,14,0,LGREY)) error_exit();
  477.             wmbardef(0,0,YELLOW|_BLUE," Load       ",'L');
  478.             wmbardef(1,0,YELLOW|_BLUE," Save       ",'S');
  479.             wmbardef(2,0,YELLOW|_BLUE," Rename     ",'R');
  480.             wmbardef(3,0,YELLOW|_BLUE," New        ",'N');
  481.             wmbardef(4,0,YELLOW|_BLUE," Directory  ",'D');
  482.             wmbardef(5,0,YELLOW|_BLUE," Change dir ",'C');
  483.             wmbardef(6,0,YELLOW|_BLUE," OS Shell   ",'O');
  484.             if(wmbardef(7,0,YELLOW|_BLUE," Quit       ",'Q')) error_exit();
  485.             m2=wmbarget(YELLOW|_MAGENTA,'L',PDMENU);
  486.             wclose();
  487.             if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */
  488.  
  489. /*          This is where you would test the
  490.             return value from the pull-down menu        */
  491.  
  492.             break;
  493.         case 'E':                    /* define pull-down menu for option 'E' */
  494.             if(!wopen(2,14,10,28,0,LGREY)) error_exit();
  495.             wmbardef(0,0,YELLOW|_BLUE," Cut         ",'C');
  496.             wmbardef(1,0,YELLOW|_BLUE," Paste       ",'P');
  497.             wmbardef(2,0,YELLOW|_BLUE," cOpy        ",'O');
  498.             wmbardef(3,0,YELLOW|_BLUE," block Begin ",'B');
  499.             wmbardef(4,0,YELLOW|_BLUE," block End   ",'E');
  500.             wmbardef(5,0,YELLOW|_BLUE," Insert line ",'I');
  501.             if(wmbardef(6,0,YELLOW|_BLUE," Delete line ",'D')) error_exit();
  502.             m2=wmbarget(YELLOW|_MAGENTA,'C',PDMENU);
  503.             wclose();
  504.             if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */
  505.  
  506. /*          This is where you would test the
  507.             return value from the pull-down menu        */
  508.  
  509.             break;
  510.         case 'D':                    /* define pull-down menu for option 'D' */
  511.             if(!wopen(2,30,11,52,0,LGREY)) error_exit();
  512.             wmbardef(0,0,YELLOW|_BLUE," Left margin       0 ",'L');
  513.             wmbardef(1,0,YELLOW|_BLUE," Right margin     72 ",'R');
  514.             wmbardef(2,0,YELLOW|_BLUE," Tab width         4 ",'T');
  515.             wmbardef(3,0,YELLOW|_BLUE," tab eXpansion   yes ",'X');
  516.             wmbardef(4,0,YELLOW|_BLUE," Insert mode     yes ",'I');
  517.             wmbardef(5,0,YELLOW|_BLUE," iNdent mode     yes ",'N');
  518.             wmbardef(6,0,YELLOW|_BLUE," Word wrap mode   no ",'W');
  519.             if(wmbardef(7,0,YELLOW|_BLUE," Save defaults       ",'S')) {
  520.                 error_exit();
  521.             }
  522.             m2=wmbarget(YELLOW|_MAGENTA,'L',PDMENU);
  523.             wclose();
  524.             if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */
  525.  
  526. /*          This is where you would test the
  527.             return value from the pull-down menu        */
  528.  
  529.             break;
  530.         case 'H':                    /* define pull-down menu for option 'H' */
  531.             if(!wopen(2,46,7,65,0,LGREY)) error_exit();
  532.             wmbardef(0,0,YELLOW|_BLUE," help on Help     ",'H');
  533.             wmbardef(1,0,YELLOW|_BLUE," help on Editing  ",'E');
  534.             wmbardef(2,0,YELLOW|_BLUE," help on Defaults ",'D');
  535.             if(wmbardef(3,0,YELLOW|_BLUE," help on Options  ",'O')) {
  536.                 error_exit();
  537.             }
  538.             m2=wmbarget(YELLOW|_MAGENTA,'H',PDMENU);
  539.             wclose();
  540.             if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */
  541.  
  542. /*          This is where you would test the
  543.             return value from the pull-down menu        */
  544.  
  545.             break;
  546.         case 'O':                    /* define pull-down menu for option 'O' */
  547.             if(!wopen(2,56,8,77,0,LGREY)) error_exit();
  548.             wmbardef(0,0,YELLOW|_BLUE," screen siZe     43 ",'Z');
  549.             wmbardef(1,0,YELLOW|_BLUE," Backup files   yes ",'B');
  550.             wmbardef(2,0,YELLOW|_BLUE," bOxed display   no ",'O');
  551.             wmbardef(3,0,YELLOW|_BLUE," Load options       ",'L');
  552.             if(wmbardef(4,0,YELLOW|_BLUE," Save options       ",'S')) {
  553.                 error_exit();
  554.             }
  555.             m2=wmbarget(YELLOW|_MAGENTA,'Z',PDMENU);
  556.             wclose();
  557.             if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */
  558.  
  559. /*          This is where you would test the
  560.             return value from the pull-down menu        */
  561.  
  562.             break;
  563.         case 'Q':                    /* define pull-down menu for option 'Q' */
  564.             if(!wopen(2,60,7,78,0,LGREY)) error_exit();
  565.             wcclear(BLUE|_BLUE);
  566.             wprints(0,2,WHITE|_BLUE,"Are you sure?");
  567.             wmbardef(2,0,YELLOW|_BLUE,"       No        ",'N');
  568.             if(wmbardef(3,0,YELLOW|_BLUE,"       Yes       ",'Y')) {
  569.                 error_exit();
  570.             }
  571.             m2=wmbarget(YELLOW|_MAGENTA,'N',PDMENU);
  572.             wclose();
  573.             if(m2<=PDMENU) goto top;        /* test for Esc or Lt/Rt Arrow   */
  574.  
  575. /*          This is where you would test the
  576.             return value from the pull-down menu        */
  577.  
  578.             break;
  579.         default:
  580.     }
  581.     wclose();
  582. }
  583.  
  584.  
  585. /*  if the Esc key or Ctrl-Break is pressed, this function will be called  */ 
  586.  
  587. void interrupt exit_prog(void)
  588. {
  589.     clearkeys();                       /*  clear keyboard buffer  */
  590.     setcursz(6,7);                     /*  set cursor size back to normal  */
  591.     srestore(sbuf1);                   /*  restore original screen  */
  592.     gotoxy_(row,col);                  /*  restore original cursor position  */
  593.     exit(0);
  594. }
  595.  
  596. /*  if an error occurs, this function will be called  */
  597.  
  598. void error_exit(void)
  599. {
  600.     setcursz(6,7);                       /*  set cursor size back to normal  */
  601.     if(_werrno) {
  602.         printf("\nError:  %s      ",werrmsg());    /*  display error message */
  603.     }
  604.     else {
  605.         abort();
  606.     }
  607.     exit(1);
  608. }
  609.