home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 228_01 / cwindemo.c < prev    next >
Text File  |  1987-07-31  |  31KB  |  933 lines

  1. /*
  2. HEADER:         CUGXXX;
  3. TITLE:          C Windowing Package;
  4. DATE:           3-20-86;
  5. DESCRIPTION:    User-supported C Windowing Package;
  6. KEYWORDS:       Windows;
  7. FILENAME:       CWINDEMO.C;
  8. WARNINGS:       None;
  9. AUTHORS:        Glen Boyd;
  10. COMPILER:       Lattice C;
  11. REFERENCES:     US-DISK 1310;
  12. ENDREF
  13. */
  14. #define foreground(A)    ((color_mon==1)?(A):(7))
  15.  
  16.  
  17.     int    u_row[14]={2,2,2,2,2,8,14,20,20,20,20,20,14,8};
  18.     int    u_col[14]={6,21,36,51,66,66,66,66,51,36,21,6,6,6};
  19.     int    l_row[14]={6,6,6,6,6,12,18,24,24,24,24,24,18,12};
  20.     int    l_col[14]={15,30,45,60,75,75,75,75,60,45,30,15,15,15};
  21.     int    wind[14];
  22.  
  23.     int    color_mon=0;
  24.  
  25.  
  26. main()
  27.  
  28. {
  29.  
  30.     int    temp,key,i,j,k,l;
  31.  
  32.     color(7,0);
  33.  
  34.     temp=open_window(9,15,13,61);
  35.  
  36.     locate(11,20);printf("Do you have a color monitor (Y/N) [ ]");
  37.     locate(11,55);
  38.     putch(key=getch());
  39.     if(key=='Y' || key=='y')color_mon=1;
  40.  
  41.     close_window(temp);
  42.  
  43.     color(foreground(1),0);
  44.     temp=open_window(3,5,23,75);
  45.     color_window(temp,foreground(14),0);
  46.     cls_window(temp);
  47.     print_window(temp,"╓─────────────────────────────────────────────── ▒▒▒▒█████\n");
  48.     print_window(temp,"║                            ░░░░░░              ███████▄\n");
  49.     print_window(temp,"║    ██   █   ██             ░____               ████O████\n");
  50.     print_window(temp,"║     ██ ███ ██                   ░              ▀▀▀▀▀▀▀▀▀\n");
  51.     print_window(temp,"║      ██   ██   I N D O W   ░░░░░░   O F T        │\n");
  52.     print_window(temp,"║                                                  │\n");
  53.     print_window(temp,"╚══════════╤══════════════════════════╤════════════╛\n");
  54.     print_window(temp,"           │   Fast - Small - Easy &  │   ╔════════════════════╗\n");
  55.     print_window(temp,"           │        C H E A P         │   ║  Glen Boyd         ║\n");
  56.     print_window(temp,"     ╔═════│                          │═══╣  21606 Criptana    ║\n");
  57.     print_window(temp,"     ║     │  W I N D O W S  For  'C' │   ║  Mission Viejo, CA ║\n");
  58.     print_window(temp,"     ║     │                          │   ║         92692      ║\n");
  59.     print_window(temp,"     ║     ╘══════════════════════════╛   ╚══╦═════════════════╝\n");
  60.     print_window(temp,"     ║                                       ║\n");
  61.     print_window(temp,"     ║ If you use these functions and find   ║\n");
  62.     print_window(temp,"     ║ them of value, a contribution of $30  ║\n");
  63.     print_window(temp,"     ║ would be greatly appreciated.         ║\n");
  64.     print_window(temp,"     ║                                       ║\n");
  65.     print_window(temp,"     ╚═══════════════════════════════════════╝");
  66.  
  67.     key=getch();
  68.  
  69.     close_window(temp);
  70.  
  71.  
  72.     for(i=0;i<=13;i++){
  73.  
  74.         color(foreground(i+1),0);
  75.         wind[i]=open_window(u_row[i],u_col[i],l_row[i],l_col[i]);
  76.  
  77.     }
  78.  
  79.     for(i=13;i>=0;i--){
  80.  
  81.         close_window(wind[i]);
  82.  
  83.     }
  84.  
  85.     for(i=13;i>=0;i--){
  86.  
  87.         color(foreground(i+1),0);
  88.         wind[i]=open_window(u_row[i],u_col[i],l_row[i],l_col[i]);
  89.  
  90.     }
  91.  
  92.     for(i=0;i<=13;i++){
  93.  
  94.         close_window(wind[i]);
  95.  
  96.     }
  97.  
  98.     for(i=0;i<14;i++){
  99.  
  100.         color(foreground(i+1),0);
  101.         wind[i]=open_window(u_row[i],u_col[i],l_row[i],l_col[i]);
  102.         color_window(wind[i],foreground(13),0);
  103.         print_window(wind[i],"C-WINDOWC-WINDOWC-WINDOW");
  104.         color_window(wind[i],foreground(i+1),0);
  105.  
  106.     }
  107.  
  108.  
  109.  
  110.  
  111.     subject(-1);
  112.  
  113.  
  114. /*  Move box 14 into place */
  115.  
  116.     for(i=15;i<=35;i++){
  117.  
  118.         move_window(wind[13],2);
  119.         slower();
  120.  
  121.     }
  122.     close_window(wind[13]);
  123.  
  124.  
  125.     subject(13);
  126.  
  127. /* Move box 13 into place */
  128.  
  129.     for(i=14;i>=11;i--){
  130.  
  131.         move_window(wind[12],1);
  132.         slower(13);
  133.  
  134.     }
  135.  
  136.     for(i=15;i<=40;i++){
  137.  
  138.         move_window(wind[12],2);
  139.         slower();
  140.  
  141.     }
  142.     close_window(wind[12]);
  143.  
  144.     subject(12);
  145.  
  146.  
  147. /* Move box 12 into place */
  148.  
  149.     for(i=11;i>=7;i--){
  150.  
  151.         for(j=u_col[i];j>6;j--){
  152.  
  153.             move_window(wind[i],4);
  154.             slower();
  155.         }
  156.  
  157.         for(j=u_row[i];j>11;j--){
  158.  
  159.             move_window(wind[i],1);
  160.             slower();
  161.         }
  162.  
  163.         l_col[i]=11;
  164.  
  165.         for(j=l_col[i];j<=35;j++){
  166.  
  167.             move_window(wind[i],2);
  168.             slower();
  169.         }
  170.  
  171.         close_window(wind[i]);
  172.  
  173.         subject(i);
  174.  
  175.     }
  176.  
  177.     for(i=6;i>=4;i--){
  178.  
  179.         for(j=l_row[i];j<24;j++){
  180.             move_window(wind[i],3);
  181.             slower();
  182.         }
  183.         l_row[i]=24;
  184.  
  185.  
  186.         for(j=u_col[i];j>6;j--){
  187.  
  188.             move_window(wind[i],4);
  189.             slower();
  190.         }
  191.  
  192.  
  193.         for(j=l_row[i];j>15;j--){
  194.  
  195.             move_window(wind[i],1);
  196.             slower();
  197.         }
  198.  
  199.         l_col[i]=6;
  200.  
  201.         for(j=l_col[i];j<=35;j++){
  202.  
  203.             move_window(wind[i],2);
  204.             slower();
  205.         }
  206.  
  207.         close_window(wind[i]);
  208.  
  209.         subject(i);
  210.  
  211.     }
  212.  
  213.  
  214.     for(i=3;i>=0;i--){
  215.  
  216.         for(j=l_col[i];j<75;j++){
  217.  
  218.             move_window(wind[i],2);
  219.             slower();
  220.         }
  221.  
  222.         l_col[i]=75;
  223.  
  224.  
  225.         for(j=l_row[i];j<24;j++){
  226.             move_window(wind[i],3);
  227.             slower();
  228.         }
  229.         l_row[i]=24;
  230.  
  231.  
  232.         for(j=l_col[i];j>15;j--){
  233.  
  234.             move_window(wind[i],4);
  235.             slower();
  236.         }
  237.  
  238.         for(j=l_row[i];j>15;j--){
  239.  
  240.             move_window(wind[i],1);
  241.             slower();
  242.         }
  243.  
  244.         l_col[i]=11;
  245.  
  246.         for(j=l_col[i];j<=35;j++){
  247.  
  248.             move_window(wind[i],2);
  249.             slower();
  250.         }
  251.  
  252.         close_window(wind[i]);
  253.  
  254.         subject(i);
  255.  
  256.     }
  257.  
  258.     subject(-2);
  259.  
  260. }
  261.  
  262. subject(wind)
  263.  
  264. int    wind;
  265.  
  266. {
  267.  
  268. static    int    temp,
  269.         temp2;
  270.     int    key,
  271.         wind1,
  272.         wind2,
  273.         wind3,
  274.         wind4,i,j;
  275.  
  276.     char    string[100];
  277.  
  278.     switch(wind){
  279.  
  280.  
  281.         case (-1):
  282.  
  283.             color(foreground(14),0);
  284.             temp2=open_window(8,17,18,64);
  285.             color_window(temp2,foreground(2),0);
  286.             print_window(temp2," C-WINDOWS is a comprehensive screen and");
  287.             print_window(temp2,"\n window handling package.  C-WINDOWS relieves");
  288.             print_window(temp2,"\n the programmer of handling extensive screen");
  289.             print_window(temp2,"\n and window manipulation.  C-WINDOWS is a");
  290.             print_window(temp2,"\n library of pre-written 'C' and ASSEMBLY");
  291.             print_window(temp2,"\n functions which do printing, coloring,");
  292.             print_window(temp2,"\n cursor positioning, and window handling.");
  293.             locate_window(temp2,9,9);
  294.             print_window(temp2,"Press any key to continue...");
  295.             color_window(temp2,foreground(14),0);
  296.             key=getch();
  297.  
  298.             break;
  299.  
  300.         case(13):
  301.  
  302.             color(foreground(14),0);
  303.             temp=open_window(4,9,23,73);
  304.             color_window(temp,foreground(2),0);
  305.  
  306.             print_window(temp," C-WINDOWS is supplied in a MS-DOS object library.  To obtain ");
  307.             print_window(temp,"\n the source for C-WINDOWS send a $30 contribution.  \n");
  308.  
  309.             print_window(temp,"\n C-WINDOWS provides you with a extensive set  of  pre-written ");
  310.             print_window(temp,"\n functions   for   manipulation  of  the  screen.   C-WINDOWS ");
  311.             print_window(temp,"\n provides functions for handling standard screen I/O such  as ");
  312.             print_window(temp,"\n printing, locating the cursor, setting color, scrolling part ");
  313.             print_window(temp,"\n of the screen, printing boxes, saving and restoring parts of ");
  314.             print_window(temp,"\n the  screen,  and  printing  horizontal and veritcal bars of ");
  315.             print_window(temp,"\n characters. \n");
  316.  
  317.             print_window(temp,"\n C-WINDOWS also contains a extensive  set  of  functions  for ");
  318.             print_window(temp,"\n handling  windows.  C-WINDOWS treats each seperate window as ");
  319.             print_window(temp,"\n a seperate virtual screen.  C-WINDOWS allows you to  scroll, ");
  320.             print_window(temp,"\n locate in,  color, blank, print in, move, open, close and re ");
  321.             print_window(temp,"\n activate each window by only specifying the window you  want \n");
  322.  
  323.  
  324.             locate_window(temp,18,15);
  325.             print_window(temp,"Press any key to continue...");
  326.             color_window(temp,foreground(14),0);
  327.             key=getch();
  328.             close_window(temp);
  329.  
  330.             break;
  331.         case(12):
  332.  
  333.             color(foreground(14),0);
  334.             temp=open_window(4,9,23,73);
  335.             color_window(temp,foreground(2),0);
  336.  
  337.             print_window(temp," this to take place in. \n");
  338.  
  339.             print_window(temp,"\n C-WINDOWS  has  a  default maximum setting of 255 windows at ");
  340.             print_window(temp,"\n one time.  This can be changed easily to a greater or lessor ");
  341.             print_window(temp,"\n amount by recompiling the source.  C-WINDOWS treats  windows ");
  342.             print_window(temp,"\n in  the same manor as the Macintosh and LISA computers.  You ");
  343.             print_window(temp,"\n can open windows in layers on top of  each  other  and  then ");
  344.             print_window(temp,"\n re-activate  a  window  which  is  in  the  middle of or the ");
  345.             print_window(temp,"\n bottom.  C-WINDOWS will restore any text under  the  windows ");
  346.             print_window(temp,"\n when they are opened, closed or re-activated.\n");
  347.  
  348.             print_window(temp,"\n To  use  the C-WINDOWS functions,  all you have to do is put ");
  349.             print_window(temp,"\n the code in your program which makes the call to the funtion ");
  350.             print_window(temp,"\n and then at link time specify the appropriate library.  Here ");
  351.             print_window(temp,"\n is a example of how this program 'demo.c' was  compiled  and ");
  352.             print_window(temp,"\n linked. \n");
  353.  
  354.  
  355.  
  356.             locate_window(temp,18,15);
  357.             print_window(temp,"Press any key to continue...");
  358.             color_window(temp,foreground(14),0);
  359.             key=getch();
  360.             close_window(temp);
  361.  
  362.             break;
  363.         case(11):
  364.  
  365.             color(foreground(14),0);
  366.             temp=open_window(4,9,23,73);
  367.             color_window(temp,foreground(2),0);
  368.  
  369.             print_window(temp,"            A>lc1 b:demo");
  370.             print_window(temp,"\n            A>lc2 b:demo");
  371.             print_window(temp,"\n            A>link a:cs+b:demo,demo,,b:windows+a:lcs\n");
  372.  
  373.             print_window(temp,"\n C-WINDOWS  was  written  using the LATTICE 2.12 'C' compiler ");
  374.             print_window(temp,"\n and IBM macro assembler ver 1.0.  For those who are familiar ");
  375.             print_window(temp,"\n with this compiler you can make sense out of the above.  For ");
  376.             print_window(temp,"\n those  who  are  not:  lc1 and lc2 are the two passes of the ");
  377.             print_window(temp,"\n compiler,  and when you link,  the file cs is a header  file ");
  378.             print_window(temp,"\n which   is   linked   to  your  'C'  program.   The  library ");
  379.             print_window(temp,"\n 'windows.lib'  must  be  specified  before  'lcs.lib'   (the ");
  380.             print_window(temp,"\n LATTICE   library)   because   'windows.lib'  contains  some ");
  381.             print_window(temp,"\n replacements for the LATTICE library. \n");
  382.  
  383.  
  384.             locate_window(temp,18,15);
  385.             print_window(temp,"Press any key to continue...");
  386.             color_window(temp,foreground(14),0);
  387.             key=getch();
  388.             close_window(temp);
  389.  
  390.             break;
  391.         case(10):
  392.  
  393.             color(foreground(14),0);
  394.             temp=open_window(4,9,23,73);
  395.             color_window(temp,foreground(2),0);
  396.  
  397.             print_window(temp," To give the support of color and full  screen  operation  to ");
  398.             print_window(temp,"\n standard  'C'  some changes had to be made to how the screen ");
  399.             print_window(temp,"\n is handled.  C-WINDOWS handles  color  and  cursor  location ");
  400.             print_window(temp,"\n similiar  to  that  of  IBM BASIC.  C-WINDOWS adds color and ");
  401.             print_window(temp,"\n cursor location support to the standard  printf()  function. ");
  402.             print_window(temp,"\n Printf()  looks  at  the last color specified with a color() ");
  403.             print_window(temp,"\n function call and then prints using that color.  If no color ");
  404.             print_window(temp,"\n has been specified it uses the default setting of  white  on ");
  405.             print_window(temp,"\n black.  Printf()  was rewritten in assembly language to give ");
  406.             print_window(temp,"\n blazing speed increase and to support  color.  This  version ");
  407.             print_window(temp,"\n of  printf() is not compatable with the standard redirection ");
  408.             print_window(temp,"\n I/O supported by DOS,  but most  programs,  at  least  those ");
  409.             print_window(temp,"\n which are screen intensive,  never use this technique anyway ");
  410.             print_window(temp,"\n so there is on real loss. ");
  411.  
  412.  
  413.             locate_window(temp,18,15);
  414.             print_window(temp,"Press any key to continue...");
  415.             color_window(temp,foreground(14),0);
  416.             key=getch();
  417.             close_window(temp);
  418.  
  419.             break;
  420.         case(9):
  421.  
  422.             color(foreground(14),0);
  423.             temp=open_window(4,9,23,73);
  424.             color_window(temp,foreground(2),0);
  425.  
  426.             print_window(temp," The files provided with this package are:\n");
  427.  
  428.             print_window(temp,"\n             WINDOWS.LIB        |  The library of functions");
  429.             print_window(temp,"\n             WINDOWS.DOC        |  Documentation for each");
  430.             print_window(temp,"\n                                   fuction in the library");
  431.             print_window(temp,"\n             DEMO.EXE           |  This demonstration file");
  432.             print_window(temp,"\n             DEMO.C             |  The source to this demo");
  433.             print_window(temp,"\n                                   file, so you can see ");
  434.             print_window(temp,"\n                                   C-WINDOWS in use.\n");
  435.  
  436.             print_window(temp,"\n As mentioned earlier.  To obtain  the  source  to  C-WINDOWS ");
  437.             print_window(temp,"\n please send a contribution of $30 to: \n");
  438.  
  439.             print_window(temp,"\n                  Glen Boyd");
  440.             print_window(temp,"\n                  21606 Criptana");
  441.             print_window(temp,"\n                  Mission Veijo, CA 92692");
  442.  
  443.  
  444.             locate_window(temp,18,15);
  445.             print_window(temp,"Press any key to continue...");
  446.             color_window(temp,foreground(14),0);
  447.             key=getch();
  448.             close_window(temp);
  449.  
  450.             break;
  451.  
  452.         case(8):
  453.  
  454.             color(foreground(14),0);
  455.             temp=open_window(4,9,23,73);
  456.             color_window(temp,foreground(2),0);
  457.  
  458.             print_window(temp," When  you  send in a contribution I will send you a diskette ");
  459.             print_window(temp,"\n which contains the source and any new  revisions  to  the  C ");
  460.             print_window(temp,"\n WINDOWS  library,  any new functions which I have added to C ");
  461.             print_window(temp,"\n WINDOWS and documentation for  the  whole  package.  I  will ");
  462.             print_window(temp,"\n also  send  you any new programs which I have written.  Your ");
  463.             print_window(temp,"\n name will go on a mailing list and you will receive any news ");
  464.             print_window(temp,"\n about a new version or new programs which I have  available. ");
  465.             print_window(temp,"\n You  will also receive a telephone # to call for support and ");
  466.             print_window(temp,"\n or questions about C-WINDOWS or any other related  questions ");
  467.             print_window(temp,"\n you might have. \n");
  468.  
  469.             print_window(temp,"\n This  demo  you  are watching is written entirely in 'C' and ");
  470.             print_window(temp,"\n uses the C-WINDOWS functions to do the  windows  and  screen ");
  471.             print_window(temp,"\n manipulation.  I  will take you through a tour of what these ");
  472.             print_window(temp,"\n functions are and how they can be used to write some  useful ");
  473.             print_window(temp,"\n applications. ");
  474.  
  475.             locate_window(temp,18,15);
  476.             print_window(temp,"Press any key to continue...");
  477.             color_window(temp,foreground(14),0);
  478.             key=getch();
  479.             close_window(temp);
  480.  
  481.             break;
  482.         case(7):
  483.  
  484.             color(foreground(14),0);
  485.             temp=open_window(4,9,23,73);
  486.             color_window(temp,foreground(2),0);
  487.  
  488.             print_window(temp," color()                   /* Allows setting of");
  489.             print_window(temp,"\n                              the default color */");
  490.             print_window(temp,"\n locate()                  /* Position cursor on");
  491.             print_window(temp,"\n                              the screen */");
  492.             print_window(temp,"\n place()                   /* Print single char */");
  493.             print_window(temp,"\n cls()                     /* Clear entire screen */");
  494.             print_window(temp,"\n v_bar()                   /* Print vertical bar of");
  495.             print_window(temp,"\n                              a specified char */");
  496.             print_window(temp,"\n h_bar()                   /* Print horizontial bar");
  497.             print_window(temp,"\n                              of a specified char */");
  498.             print_window(temp,"\n scroll()                  /* Scroll any part of the");
  499.             print_window(temp,"\n                              screen */");
  500.             print_window(temp,"\n printf()                  /* just like standard printf");
  501.             print_window(temp,"\n                              except written in assembly");
  502.             print_window(temp,"\n                              for speed and color */");
  503.  
  504.  
  505.             locate_window(temp,18,15);
  506.             print_window(temp,"Press any key to continue...");
  507.             color_window(temp,foreground(14),0);
  508.             key=getch();
  509.             close_window(temp);
  510.  
  511.             break;
  512.         case(6):
  513.  
  514.             color(foreground(14),0);
  515.             temp=open_window(4,9,23,73);
  516.             color_window(temp,foreground(2),0);
  517.             print_window(temp," box()                     /* Draws a box using double");
  518.             print_window(temp,"\n                              line drawing characters */");
  519.             print_window(temp,"\n minor_box( )              /* Draws a box using single");
  520.             print_window(temp,"\n                              line drawing characters */");
  521.             print_window(temp,"\n window()                  /* Makes an exploding box */");
  522.             print_window(temp,"\n save_restore()            /* Save and restore portions");
  523.             print_window(temp,"\n                              of the screen */\n");
  524.  
  525.             print_window(temp,"\n Are  functions  which operate with the screen no matter what ");
  526.             print_window(temp,"\n is on it.  These function can be used by themselves to write ");
  527.             print_window(temp,"\n your  own  window  or  screen   handling   routines.   These ");
  528.             print_window(temp,"\n functions  are  the  primitives used in the functions listed ");
  529.             print_window(temp,"\n below to  handle  the  windows.  Windows  are  handled  like ");
  530.             print_window(temp,"\n individual screens, for example if I open a window up, which ");
  531.             print_window(temp,"\n is  ten  rows  by  thirty columns then C-WINDOWS treats this ");
  532.             print_window(temp,"\n like a  seperate  screen.  You  can  scroll,  print,  color, ");
  533.  
  534.  
  535.  
  536.             locate_window(temp,18,15);
  537.             print_window(temp,"Press any key to continue...");
  538.             color_window(temp,foreground(14),0);
  539.             key=getch();
  540.             close_window(temp);
  541.  
  542.             break;
  543.  
  544.         case(5):
  545.  
  546.             color(foreground(14),0);
  547.             temp=open_window(4,9,23,73);
  548.             color_window(temp,foreground(2),0);
  549.  
  550.  
  551.             print_window(temp," locate the cursor, and do a host of other functions directly ");
  552.             print_window(temp,"\n to this virtual screen by just passing it a window #.  I can ");
  553.             print_window(temp,"\n have  up to 255 virtual screens open at the same time,  that ");
  554.             print_window(temp,"\n is if I have that much memory.  \n");
  555.  
  556.             print_window(temp,"\n activate()              /* Make a window active on");
  557.             print_window(temp,"\n                            the screen */");
  558.             print_window(temp,"\n open_window()           /* Open a window */");
  559.             print_window(temp,"\n close_window()          /* Close a previously opened");
  560.             print_window(temp,"\n                            window */");
  561.             print_window(temp,"\n scroll_window()         /* Scroll the text inside of");
  562.             print_window(temp,"\n                            a window */");
  563.             print_window(temp,"\n locate_window()         /* Locate the cursor inside");
  564.             print_window(temp,"\n                            of a window */");
  565.             print_window(temp,"\n print_window()          /* Allows printing in a");
  566.             print_window(temp,"\n                            specified window */");
  567.  
  568.  
  569.             locate_window(temp,18,15);
  570.             print_window(temp,"Press any key to continue...");
  571.             color_window(temp,foreground(14),0);
  572.  
  573.             key=getch();
  574.             close_window(temp);
  575.             break;
  576.         case(4):
  577.  
  578.             color_window(temp,foreground(2),0);
  579.  
  580.             temp=open_window(4,9,23,73);
  581.             color_window(temp,foreground(2),0);
  582.  
  583.             print_window(temp," cls_window()            /* Clears out a specified");
  584.             print_window(temp,"\n                            window */");
  585.             print_window(temp,"\n move_window()           /* Move a window around");
  586.             print_window(temp,"\n color_window()          /* Set color in a window */");
  587.             print_window(temp,"\n                            on the screen */\n");
  588.  
  589.             print_window(temp,"\n When a window is opened all text under the  window  will  be ");
  590.             print_window(temp,"\n saved,  then the window will open up using the current color ");
  591.             print_window(temp,"\n specified with the last  color()  function  call,  then  the ");
  592.             print_window(temp,"\n virtual  screen  (the  inside of the window) will be cleared ");
  593.             print_window(temp,"\n and the cursor will locate in the HOME postion (row 1 column ");
  594.             print_window(temp,"\n 1).  Any printing,  locating,  and  coloring  that  is  done ");
  595.             print_window(temp,"\n inside  this  window  will  be relative to its HOME postion. ");
  596.             print_window(temp,"\n C-WINDOWS allows overlapping windows, which can be opened on ");
  597.             print_window(temp,"\n top of each other.  When a  window  is  opened,  it  is  the \n");
  598.  
  599.  
  600.  
  601.             locate_window(temp,18,15);
  602.             print_window(temp,"Press any key to continue...");
  603.             color_window(temp,foreground(14),0);
  604.  
  605.             key=getch();
  606.             close_window(temp);
  607.  
  608.             break;
  609.  
  610.         case(3):
  611.  
  612.             color(foreground(14),0);
  613.             temp=open_window(4,9,23,73);
  614.             color_window(temp,foreground(2),0);
  615.  
  616.  
  617.             print_window(temp," current (active) window,  that is, it is the window which is ");
  618.             print_window(temp,"\n on top.  When another window is opened it becomes the active ");
  619.             print_window(temp,"\n window  and  the  previous  window  becomes  inactive.  This ");
  620.             print_window(temp,"\n mechanism  allows  for  windows  to be layered on top of one ");
  621.             print_window(temp,"\n another.  You can do anything to any window at any  time  by ");
  622.             print_window(temp,"\n just  specifying  the window #,  and C-WINDOWS will sort out ");
  623.             print_window(temp,"\n what is to be done to  whom.  For  example  if  I  have  ten ");
  624.             print_window(temp,"\n windows  opened up and I want to print to the third one then ");
  625.             print_window(temp,"\n I  would  call  the  print_window()  fucntion  passing   the ");
  626.             print_window(temp,"\n appropriate  window  #  and  data  to  be  printed in it.  C ");
  627.             print_window(temp,"\n WINDOWS will make it the activate window,  by bringing it to ");
  628.             print_window(temp,"\n the top and then printing in it. \n");
  629.  
  630.             print_window(temp,"\n I  am  going  to  take  you through a short demonstration of ");
  631.             print_window(temp,"\n opening windows and printing to them.  This  demo  will  use ");
  632.             print_window(temp,"\n four windows which are opened,  closed,  activated,  printed ");
  633.  
  634.             locate_window(temp,18,15);
  635.             print_window(temp,"Press any key to continue...");
  636.             color_window(temp,foreground(14),0);
  637.  
  638.             key=getch();
  639.             close_window(temp);
  640.  
  641.             break;
  642.         case(2):
  643.  
  644.             color(foreground(14),0);
  645.             temp=open_window(4,9,23,73);
  646.             color_window(temp,foreground(2),0);
  647.  
  648.             print_window(temp," in,  move around,  cleared,  and scrolled text in.  First we ");
  649.             print_window(temp,"\n will  start  off  by  opening  a window in ten rows tall and ");
  650.             print_window(temp,"\n thirty five columns wide.  We will position this  window  in ");
  651.             print_window(temp,"\n our  upper left corner of this window.  The function call to ");
  652.             print_window(temp,"\n do this looks like this. \n");
  653.  
  654.             print_window(temp,"\n            wind1=open_window(7,14,18,50);\n");
  655.  
  656.             print_window(temp,"\n Ok,  lets examine this statement  before  we  do  the  call. ");
  657.             print_window(temp,"\n First  of  all  the  function  open_window()  will  return a ");
  658.             print_window(temp,"\n integer which is a window ID #,  this # is  a  ID  which  is ");
  659.             print_window(temp,"\n assigned  when  the  window  is  opened.  This  ID  does not ");
  660.             print_window(temp,"\n represent the coresponding place which it  was  opened,  but ");
  661.             print_window(temp,"\n represents  a  ID  given  to  that  window.  Each  window is ");
  662.             print_window(temp,"\n assigned an unique ID number which is used in identifying it ");
  663.  
  664.  
  665.             locate_window(temp,18,15);
  666.             print_window(temp,"Press any key to continue...");
  667.             color_window(temp,foreground(14),0);
  668.  
  669.             key=getch();
  670.             close_window(temp);
  671.  
  672.             break;
  673.         case(1):
  674.  
  675.             color(foreground(14),0);
  676.             temp=open_window(4,9,23,73);
  677.             color_window(temp,foreground(2),0);
  678.             print_window(temp," with the rest of the windows.  Ok,  the firt argument in the ");
  679.             print_window(temp,"\n function call is the row which the upper left hand corner of ");
  680.             print_window(temp,"\n the window will be placed in,  the next is the column of the ");
  681.             print_window(temp,"\n upper left hand corner, the next two arguments are the lower ");
  682.             print_window(temp,"\n left  hand  corners  row  and  column.   Well  now  that  we ");
  683.             print_window(temp,"\n understand that lets do the call. \n\n");
  684.  
  685.             locate_window(temp,18,15);
  686.             print_window(temp,"Press any key to continue...");
  687.             color_window(temp,foreground(14),0);
  688.  
  689.             key=getch();
  690.  
  691.             color(foreground(1),0);
  692.  
  693.         wind1=open_window(7,14,18,50);
  694.  
  695.  
  696. /*  do the open  */
  697.  
  698.             print_window(wind1," Now you can see  we  are  inside");
  699.             print_window(wind1,"\n this   window   and  it  is  the ");
  700.             print_window(wind1,"\n current active window.  Now lets ");
  701.             print_window(wind1,"\n open up some more windows so  we ");
  702.             print_window(wind1,"\n can see some more. ");
  703.             print_window(wind1,"\n Press any key when ready..");
  704.             key=getch();
  705.  
  706.             color(foreground(4),0);
  707.  
  708.  
  709.         wind2=open_window(1,23,12,60);
  710.  
  711. /* open up another window */
  712.  
  713.             print_window(wind2," This is our second window");
  714.             print_window(wind2,"\n\n Press any key when ready..");
  715.             key=getch();
  716.  
  717.             color(foreground(15),0);
  718.  
  719.  
  720.         wind3=open_window(9,43,20,80);
  721.  
  722.  
  723.             print_window(wind3," This is our third window");
  724.             print_window(wind3,"\n\n Press any key when ready..");
  725.             key=getch();
  726.  
  727.  
  728.             color(foreground(10),0);
  729.  
  730.         wind4=open_window(14,1,25,37);
  731.  
  732. /* open up another window */
  733.  
  734.             print_window(wind4," This  is  our   fourth   window. ");
  735.             print_window(wind4,"\n Notice   that  I  specified  the ");
  736.             print_window(wind4,"\n window    locations     in     a ");
  737.             print_window(wind4,"\n overlapping    fashion.     Each ");
  738.             print_window(wind4,"\n window  is  placed  some   where ");
  739.             print_window(wind4,"\n overlapping   the   one   under- ");
  740.             print_window(wind4,"\n neath.  Now that we  have  these ");
  741.             print_window(wind4,"\n windows  open we can call up any ");
  742.             print_window(wind4,"\n window at any  time.  Lets  call ");
  743.             print_window(wind4,"\n window two. Press any key... ");
  744.  
  745.             key=getch();
  746.  
  747.  
  748. /* Now activate window two */
  749.  
  750.             cls_window(wind2);
  751.             print_window(wind2," Notice how this  window  becomes ");
  752.             print_window(wind2,"\n active   restoring   all   stuff ");
  753.             print_window(wind2,"\n underneath  it  and     anything ");
  754.             print_window(wind2,"\n inside    the    window.    Lets ");
  755.             print_window(wind2,"\n demonstrate  some  other  things ");
  756.             print_window(wind2,"\n C-WINDOWS  can  do.   Lets  move ");
  757.             print_window(wind2,"\n this window  to  the  right  ten ");
  758.             print_window(wind2,"\n spaces.  Press any key ten times ");
  759.  
  760.  
  761.             for(i=0;i<10;i++){
  762.  
  763.                 key=getch();
  764.                 move_window(wind2,2);
  765.             }
  766.  
  767.             key=getch();
  768.  
  769.  
  770. /* do the move */
  771.  
  772.             cls_window(wind2);
  773.  
  774.             print_window(wind2," I am going  to  demonstrate  the ");
  775.             print_window(wind2,"\n scrolling capabilities  of  each ");
  776.             print_window(wind2,"\n window.\n\n   Press any key when ");
  777.             print_window(wind2,"ready... ");
  778.  
  779.             key=getch();
  780.  
  781.  
  782. /* Do scrolling on each window */
  783.  
  784.             cls_window(wind1);
  785.  
  786.             for(j=1;j<=25;j++){
  787.  
  788.                 sprintf(string," This is scrolling up %d\n",j);
  789.                 print_window(wind1,string);
  790.  
  791.             }
  792.  
  793.             cls_window(wind4);
  794.  
  795.             for(j=1;j<=25;j++){
  796.  
  797.                 sprintf(string," This is scrolling up %d\n",j);
  798.                 print_window(wind4,string);
  799.  
  800.             }
  801.             for(j=25;j>=10;j--){
  802.  
  803.                 scroll_window(wind4,1,1);
  804.                 locate_window(wind4,1,1);
  805.                 sprintf(string,"  This is a scrolling down %d",j-9);
  806.                 print_window(wind4,string);
  807.  
  808.             }
  809.  
  810.             locate_window(wind4,10,1);
  811.             print_window(wind4,"\n Press any key to continue...");
  812.             key=getch();
  813.  
  814.  
  815. /* open window 1 and */
  816.  
  817. /* clear window one */
  818.             cls_window(wind1);
  819.  
  820.             print_window(wind1," Now we are back  to  window  one ");
  821.             print_window(wind1,"\n and you can start to see some of ");
  822.             print_window(wind1,"\n the power we have by just having ");
  823.             print_window(wind1,"\n four windows, and you have up to ");
  824.             print_window(wind1,"\n 255! \n");
  825.  
  826.             print_window(wind1,"\n Press any key when ready...");
  827.             key=getch();
  828.             close_window(wind1);
  829. /* close window one */
  830.  
  831.             cls_window(wind3);
  832.  
  833. /* clear window 3 */
  834.             print_window(wind3,"\n Now lets close them all\n");
  835.  
  836.             print_window(wind3,"\n Press any key when ready...");
  837.             key=getch();
  838.  
  839.             close_window(wind3);
  840. /* close window 3 */
  841.             cls_window(wind4);
  842.  
  843. /* clear window 4 */
  844.             print_window(wind4," Now lets close window 4");
  845.  
  846.             print_window(wind4,"\n Press any key when ready...");
  847.             key=getch();
  848.  
  849.             close_window(wind4);
  850. /* close window 4 */
  851.             cls_window(wind2);
  852. /* clear window 2 */
  853.  
  854.             print_window(wind2," This  is  the  last  one so here ");
  855.             print_window(wind2,"\n goes.  Watch  how  the  previous ");
  856.             print_window(wind2,"\n window,  which  is the one below ");
  857.             print_window(wind2,"\n becomes active as we  close  all ");
  858.             print_window(wind2,"\n the windows on top of it. ");
  859.  
  860.             print_window(wind2,"\n Press any key when ready...");
  861.  
  862.             key=getch();
  863.  
  864.             close_window(wind2);
  865.  
  866. /* close window 2 */
  867.  
  868.             cls_window(temp);
  869.  
  870.             color_window(temp,foreground(2),0);
  871.             print_window(temp,"\n We made it back here and thats all folks...");
  872.             print_window(temp,"\n Thank you and have fun, writting applications.");
  873.  
  874.             locate_window(temp,18,15);
  875.             print_window(temp,"Press any key to continue...");
  876.  
  877.             key=getch();
  878.             close_window(temp);
  879.  
  880.             break;
  881.         case(0):
  882.  
  883.             color(foreground(14),0);
  884.             temp=open_window(4,9,23,73);
  885.             color_window(temp,foreground(2),0);
  886.  
  887.             print_window(temp," To get the latest copy of this program or to leave a");
  888.             print_window(temp,"\n message for me, you can call");
  889.             print_window(temp,"\n\n                   The Consultants Exchange");
  890.             print_window(temp,"\n                   714-842-6348");
  891.             print_window(temp,"\n                   Huntington Beach, CA");
  892.             print_window(temp,"\n\n And leave a message on it for Glen Boyd");
  893.             print_window(temp,"\n This is a Electronic BBS.  You must have a");
  894.             print_window(temp,"\n modem to call this number.");
  895.  
  896.             locate_window(temp,18,15);
  897.             print_window(temp,"Press any key to continue...");
  898.             color_window(temp,foreground(14),0);
  899.  
  900.             key=getch();
  901.             close_window(temp);
  902.  
  903.             break;
  904.  
  905.         case(-2):
  906.  
  907.             close_window(temp2);
  908.  
  909.             break;
  910.  
  911.     }
  912.  
  913. }
  914.  
  915. slow()
  916. {
  917.  
  918.     int    i;
  919.     for(i=0;i<=5000;i++);
  920.  
  921. }
  922.  
  923. slower()
  924.  
  925. {
  926.  
  927.     int    i;
  928.  
  929.     for(i=0;i<=350;i++);
  930.  
  931. }
  932.  
  933.