home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / pascal / passrc / shell.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-11-18  |  22.5 KB  |  729 lines

  1. { -----------------------------------------------------------------------------
  2.  
  3.                                  NOTICE:
  4.  
  5.       THESE MATERIALS are UNSUPPORTED by OSS!  If you do not understand how to
  6.       use them do not contact OSS for help!  We will not teach you how to 
  7.       program in Pascal.  If you find an error in these materials, feel free
  8.       to SEND US A LETTER explaining the error, and how to fix it.
  9.  
  10.       THE BOTTOM LINE:
  11.  
  12.          Use it, enjoy it, but you are on your own when using these materials!
  13.  
  14.  
  15.                                DISCLAIMER:
  16.  
  17.       OSS makes no representations or warranties with respect to the contents
  18.       hereof and specifically disclaim all warranties of merchantability or
  19.       fitness for any particular purpose.   This document is subject to change
  20.       without notice.
  21.       
  22.       OSS provides these materials for use with Personal Pascal.  Use them in
  23.       any way you wish.
  24.  
  25.    -------------------------------------------------------------------------- }
  26.  
  27.  
  28. Program shell;
  29.  
  30. CONST
  31.         {$I gemconst.pas }              { Include all the GEM constants }
  32.         Desk_Title      =       3;      { Value for Desk menu item      }
  33.         files           =       0;      { File attribute for a file     }
  34.         volumes         =       8;      { File attribute for the volume }
  35.         folders         =       16;     { File attribute for a folder   }
  36.  
  37. TYPE
  38.  
  39.         {$I gemtype.pas }
  40.  
  41. VAR
  42.         wind_title      :       Window_Title;   { Window name           }
  43.  
  44.         msg             :       Message_Buffer; { GEM message buffer    }
  45.  
  46.         a_menu          :       Menu_Ptr;       { Value for our menu    }
  47.  
  48.         Info_Box        :       Dialog_Ptr;     { Need this for Dialog Box }
  49.  
  50.         out_char        :       char;           { Used to display characters
  51.                                                   to the screen         }
  52.  
  53.         title1,  {  -                                                   }
  54.         title2,  {   |                                                  }
  55.         title3,  {   |- Variables for our 5 menu titles                 }
  56.         title4,  {   |                                                  }
  57.         title5,  {  -                                                   }
  58.         item11,  {  -                                                   }
  59.         item12,  {   |                                                  }
  60.         item13,  {   |                                                  }
  61.         item21,  {   |                                                  }
  62.         item22,  {   |                                                  }
  63.         item23,  {   |                                                  }
  64.         item31,  {   |                                                  }
  65.         item32,  {   |- Variables for all menu items                    }
  66.         item33,  {   |                                                  }
  67.         item41,  {   |                                                  }
  68.         item42,  {   |                                                  }
  69.         item43,  {   |                                                  }
  70.         item51,  {   |                                                  }
  71.         item52,  {   |                                                  }
  72.         item53,  {  -                                                   }
  73.         sf,
  74.         info_item,
  75.         ok_button,
  76.         button,
  77.         dummy,
  78.         event_val,
  79.         windtype,
  80.         big_window,
  81.         event,
  82.         what_key, { Key pressed and processed }
  83.         key_lo,   { Low order byte of key     }
  84.         key_hi,   { High order byte of key    }
  85.         hx,       { Hold the maximum screen values for WM_Fulled message }
  86.         hy,
  87.         hw,
  88.         hh,
  89.         xm,       { Screen work area after we open the window }
  90.         ym,
  91.         wm,
  92.         hm,
  93.         cw,       { Character size, width, height and the box size }
  94.         ch,
  95.         bw,
  96.         bh,
  97.         cur_x,    { Cursor position for displaying to the screen }
  98.         cur_y,
  99.         zeron,    { Device zero is the printer                   }
  100.         escn,
  101.         x,
  102.         y               :       integer;
  103.  
  104.         {$I gemsubs.pas }      { Include all GEM subroutines }
  105.  
  106. Procedure bconout(dev, c:integer);   { Put a character to a device }
  107. BIOS(3);                             { Necessary for esc character }
  108.  
  109. Procedure build_screen;
  110. begin
  111.  
  112.         { Your code goes here for what you may want to display on the
  113.           screen. This would have to be saved in order to do a redraw
  114.           after a message from GEM.                                     }
  115.  
  116. end;
  117.  
  118. { The following routine will do a redraw of our window after something
  119.   has been placed over it. It works extremely fast, because it will
  120.   only draw the clipped area, and not the entire screen.                }
  121.  
  122. Procedure Do_Redraw(handle, x0, y0, w0, h0 : integer);
  123. VAR
  124.   x, y, w, h :integer;
  125.  
  126. begin
  127.   Begin_Update;
  128.   Hide_Mouse;
  129.   First_Rect(handle, x, y, w, h);
  130.   While (w <> 0) and (h <> 0) do
  131.     begin
  132.       If Rect_Intersect( x0, y0, w0, h0, x, y, w, h) then
  133.         begin
  134.           Set_Clip(x, y, w, h);
  135.           Paint_Color(white);
  136.           Paint_Rect(x, y, w, h);
  137.           build_screen;
  138.         end;
  139.       Next_Rect(handle, x, y, w, h);
  140.     end;
  141.   Show_Mouse;
  142.   Set_Clip(xm, ym, wm, hm);
  143.   End_Update;
  144. end;
  145.  
  146. { If we get a message from GEM that our window is now to be the front
  147.   window, then this routine will bring it to the front.                 }
  148.  
  149. Procedure Do_Topped;
  150. begin
  151.   Set_Clip(xm, ym, wm, hm);
  152.   Bring_To_Front(big_window);
  153. end;
  154.  
  155. { This routine will only clear and redraw a blank window. If you have
  156.   already placed something on the screen, then you will need to save
  157.   it somewhere if you wish to see it after a redraw or other type of
  158.   GEM message.                                                          }
  159.  
  160. Procedure draw_wind;
  161. begin
  162.   Hide_Mouse;
  163.   Work_Rect(big_window,xm,ym,wm,hm);
  164.   Set_Clip(xm,ym,wm,hm);
  165.   Set_Color(white,1000,1000,1000);
  166.   Paint_Rect(xm,ym,wm,hm);
  167.   Show_Mouse;
  168.   cur_x := xm;
  169.   cur_y := ym + ch;
  170. end;
  171.  
  172. { The following routines process menu item selection. Each one now only
  173.   performs an ALERT box, but any type of code can be added.             }
  174.  
  175. Procedure item11_proc;
  176. begin
  177.   dummy := Do_Alert('[1][ITEM| 1 - 1][ OK ]',0);
  178. end;
  179.  
  180. Procedure item12_proc;
  181. begin
  182.   dummy := Do_Alert('[1][ITEM| 1 - 2][ OK ]',0);
  183. end;
  184.  
  185. Procedure item13_proc;
  186. begin
  187.   dummy := Do_Alert('[1][ITEM| 1 - 3][ OK ]',0);
  188. end;
  189.  
  190. Procedure item21_proc;
  191. begin
  192.   dummy := Do_Alert('[1][ITEM| 2 - 1][ OK ]',0);
  193. end;
  194.  
  195. Procedure item22_proc;
  196. begin
  197.   dummy := Do_Alert('[1][ITEM| 2 - 2][ OK ]',0);
  198. end;
  199.  
  200. Procedure item23_proc;
  201. begin
  202.   dummy := Do_Alert('[1][ITEM| 2 - 3][ OK ]',0);
  203. end;
  204.  
  205. Procedure item31_proc;
  206. begin
  207.   dummy := Do_Alert('[1][ITEM| 3 - 1][ OK ]',0);
  208. end;
  209.  
  210. Procedure item32_proc;
  211. begin
  212.   dummy := Do_Alert('[1][ITEM| 3 - 2][ OK ]',0);
  213. end;
  214.  
  215. Procedure item33_proc;
  216. begin
  217.   dummy := Do_Alert('[1][ITEM| 3 - 3][ OK ]',0);
  218. end;
  219.  
  220. Procedure item41_proc;
  221. begin
  222.   dummy := Do_Alert('[1][ITEM| 4 - 1][ OK ]',0);
  223. end;
  224.  
  225. Procedure item42_proc;
  226. begin
  227.   dummy := Do_Alert('[1][ITEM| 4 - 2][ OK ]',0);
  228. end;
  229.  
  230. Procedure item43_proc;
  231. begin
  232.   dummy := Do_Alert('[1][ITEM| 4 - 3][ OK ]',0);
  233. end;
  234.  
  235. Procedure item51_proc;
  236. begin
  237.   dummy := Do_Alert('[1][ITEM| 5 - 1][ OK ]',0);
  238. end;
  239.  
  240. Procedure item52_proc;
  241. begin
  242.   dummy := Do_Alert('[1][ITEM| 5 - 2][ OK ]',0);
  243. end;
  244.  
  245. Procedure item53_proc;
  246. begin
  247.   dummy := Do_Alert('[1][ITEM| 5 - 3][ OK ]',0);
  248. end;
  249.  
  250. { Here is where we find out which item is selected from the titles      }
  251.  
  252. Procedure title1_proc;
  253. begin
  254.   if msg[4] = item11 then
  255.     item11_proc
  256.   ELSE if msg[4] = item12 then
  257.     item12_proc
  258.   ELSE if msg[4] = item13 then
  259.     item13_proc;
  260.   Menu_Normal(a_menu,title1);
  261. end;
  262.  
  263. Procedure title2_proc;
  264. begin
  265.   if msg[4] = item21 then
  266.     item21_proc
  267.   ELSE if msg[4] = item22 then
  268.     item22_proc
  269.   ELSE if msg[4] = item23 then
  270.     item23_proc;
  271.   Menu_Normal(a_menu,title2);
  272. end;
  273.  
  274. Procedure title3_proc;
  275. begin
  276.   if msg[4] = item31 then
  277.     item31_proc
  278.   ELSE if msg[4] = item32 then
  279.     item32_proc
  280.   ELSE if msg[4] = item33 then
  281.     item33_proc;
  282.   Menu_Normal(a_menu,title3);
  283. end;
  284.  
  285. Procedure title4_proc;
  286. begin
  287.   if msg[4] = item41 then
  288.     item41_proc
  289.   ELSE if msg[4] = item42 then
  290.     item42_proc
  291.   ELSE if msg[4] = item43 then
  292.     item43_proc;
  293.   Menu_Normal(a_menu,title4);
  294. end;
  295.  
  296. Procedure title5_proc;
  297. begin
  298.   if msg[4] = item51 then
  299.     item51_proc
  300.   ELSE if msg[4] = item52 then
  301.     item52_proc
  302.   ELSE if msg[4] = item53 then
  303.     item53_proc;
  304.   Menu_Normal(a_menu,title5);
  305. end;
  306.  
  307. { So you want to build a DIALOG BOX. Here's how you do it               }
  308.  
  309. Procedure infodial;
  310. begin
  311.   sf := System_Font;
  312.   Info_Box := New_Dialog(15,0,0,40,18);
  313.   info_item := Add_DItem(Info_Box,G_Text,None,2,1,36,1,0,$1180);
  314.   Set_DText(Info_Box,info_item,'Pascal Shell',sf,TE_Center);
  315.   info_item := Add_DItem(Info_Box,G_Text,None,2,3,36,1,0,$1180);
  316.   Set_DText(Info_Box,info_item,'by F.P. Nagle',sf,TE_Center);
  317.   info_item := Add_DItem(Info_Box,G_Text,None,2,5,36,1,0,$1180);
  318.   Set_DText(Info_Box,info_item,'Copyright (c) 1986',sf,TE_Center);
  319.   info_item := Add_DItem(Info_Box,G_Text,None,2,9,36,1,0,$1180);
  320.   Set_DText(Info_Box,info_item,'Portions of this program',
  321.               sf,TE_Center);
  322.   info_item := Add_DItem(Info_Box,G_Text,None,2,11,36,1,0,$1180);
  323.   Set_DText(Info_Box,info_item,'Copyright (c) 1986 OSS & CCD',
  324.               sf,TE_Center);
  325.   info_item := Add_DItem(Info_Box,G_Text,None,2,13,36,1,0,$1180);
  326.   Set_DText(Info_Box,info_item,'Used by permission of OSS.',
  327.               sf,TE_Center);
  328.   ok_button := Add_DItem(Info_Box,G_Button,Selectable|Exit_Btn|Default,
  329.               15,15,8,2,2,$1180);
  330.   Set_DText(Info_Box,ok_button,'OK',sf,TE_Center);
  331.   Center_Dialog(Info_Box);
  332.   button := Do_Dialog(Info_Box,0);
  333.   End_Dialog(Info_Box);
  334.   Menu_Normal(a_menu,Desk_Title);
  335. end;
  336.  
  337. { A menu item has been selected, here we find which one.                }
  338.  
  339. Procedure menu_proc;
  340. begin
  341.   If msg[3] = title1 then
  342.     title1_proc
  343.   ELSE if msg[3] = title2 then
  344.     title2_proc
  345.   ELSE if msg[3] = title3 then
  346.     title3_proc
  347.   ELSE if msg[3] = title4 then
  348.     title4_proc
  349.   ELSE if msg[3] = title5 then
  350.     title5_proc
  351.   ELSE if msg[3] = Desk_Title then
  352.     infodial;
  353. end;
  354.  
  355. Procedure blnk_wind;
  356. begin
  357. end;
  358.  
  359. { GEM has told us that the window was moved, so we must redraw it with
  360.   the correct NEW size.                                                 }
  361.  
  362. Procedure move_wind;
  363. begin
  364.   Set_WSize(big_window,msg[4],msg[5],msg[6],msg[7]);
  365.   draw_wind;
  366. end;
  367.  
  368. { GEM has told us that the window has been re-sized, so we need to redraw
  369.   the NEW size window.                                                  }
  370.  
  371. Procedure size_wind;
  372. begin
  373.   Set_WSize(big_window,msg[4],msg[5],msg[6],msg[7]);
  374.   draw_wind;
  375. end;
  376.  
  377. { GEM has told us to fill the screen with this window. Note we saved the
  378.   maximum size in hx, hy, hw, hh when we opened the window initially.   }
  379.  
  380. Procedure full_wind;
  381. begin
  382.   xm := hx;
  383.   ym := hy;
  384.   wm := hw;
  385.   hm := hh;
  386.   Set_WSize(big_window,hx,hy,hw,hh);
  387.   draw_wind;
  388. end;
  389.  
  390. { Here's how to draw a "cursor" on the screen.  It's only a line!       }
  391.  
  392. Procedure linex;
  393. begin
  394.   Line(cur_x + 2, cur_y - (ch - 3), cur_x + 2, cur_y);
  395. end;
  396.  
  397. { Here's how to position the "cursor" on the screen.                    }
  398.  
  399. Procedure pos_cursor;
  400. begin
  401.   cur_x := cur_x + cw;
  402.   If cur_x > (xm + wm) - cw then
  403.     begin
  404.     cur_x := xm;
  405.     cur_y := cur_y + ch;
  406.     If cur_y > (hm + ym) then
  407.       begin
  408.       cur_y := ym + ch;
  409.       draw_wind;
  410.       end
  411.     end;
  412.   linex;
  413. end;
  414.  
  415.         { The only way to display text on the screen under GEM is to
  416.           draw the string. We have saved the character value from the
  417.           key pressed, so here we Draw_String (just one character) to
  418.           the screen. cur_x and cur_y are the cursor position, and
  419.           out_char is the value to be drawn.                            }
  420.  
  421. Procedure disp_it;
  422. begin
  423.   Draw_String(cur_x,cur_y,out_char);
  424. end;
  425.  
  426.         { Here we change the integer value of the key pressed into a
  427.           character which can be used by the Draw_String command. Before
  428.           doing anything to the screen though, we Hide_Mouse so we don't
  429.           lose part of what we want to show. After we get done, we
  430.           Show_Mouse again.                                             }
  431.  
  432. Procedure disp_char;
  433. begin
  434.   Hide_Mouse;
  435.   out_char := chr(key_lo);
  436.   disp_it;
  437.   pos_cursor;
  438.   Show_Mouse;
  439. end;
  440.  
  441.         { Because we are Drawing to the screen, if a back space is
  442.           entered, we need to erase the cursor (line) and move back
  443.           one, and draw a space to the screen. We also need to check
  444.           if the cursor is at the far left already. If so, we can't
  445.           go back any further on this line, so position it at the
  446.           beginning of the current line. You could also add code to
  447.           move UP a line and continue back spacing if desired. This
  448.           is only a demo, so we cut it short here.                      }
  449.  
  450.  
  451. Procedure back_space;
  452. begin
  453.   Hide_Mouse;
  454.   out_char := chr(32);
  455.   disp_it;
  456.   cur_x := cur_x - cw;
  457.   if cur_x < xm then
  458.     cur_x := xm;
  459.   disp_it;
  460.   linex;
  461.   Show_Mouse;
  462. end;
  463.  
  464.         { We received a carriage return (ENTER), so we need to erase
  465.           the cursor (line) on the current line. By making the cur_x
  466.           position off the right side of the screen, we can use the
  467.           pos_cursor routine to determine the new line position.        }
  468.  
  469. Procedure carr_return;
  470. begin
  471.   Hide_Mouse;
  472.   out_char := chr(32);
  473.   disp_it;
  474.   cur_x := xm + wm + cw;
  475.   pos_cursor;
  476.   Show_Mouse;
  477. end;
  478.  
  479. Procedure esc_char;
  480. begin
  481.  
  482. { To actually send the escape character to any output you
  483.   need to use BIOS(3) since GEM will "swallow" all escape
  484.   characters                                               }
  485.  
  486. { bconout(zeron,escn);                                     }
  487.  
  488. end;
  489.  
  490. Procedure not_used;
  491. begin
  492.  
  493. { This program doesn't use these particular keys, but that
  494.   does not mean that they aren't available to you for your
  495.   own usage.  Just  define the  routine  that you  need to
  496.   handle your particular needs.                            }
  497.  
  498. end;
  499.  
  500.         { Here we check what value we received from the key pressed.
  501.           I only show a check of the low value, not the entire 16
  502.           bit value. In order to determine the use of Function keys
  503.           and the special Help/Undo etc. keys, you would have to check
  504.           the high value also, or use the full integer value.           }
  505.  
  506. Procedure check_key;
  507. begin
  508.   CASE key_lo of
  509.     32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
  510.     52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,
  511.     72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,
  512.     92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,
  513.     109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,
  514.     124,125,126,127             :       disp_char;
  515.     8                           :       back_space;
  516.     13                          :       carr_return;
  517.     27                          :       esc_char;
  518.     0,1,2,3,4,5,6,7,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,
  519.     25,26,28,29,30,31           :       not_used;
  520.   END;
  521. end;
  522.  
  523.         { Here we break the 16 bit integer value into two parts, the
  524.           high and low values. Since this is a demo, we are only
  525.           checking for normal ASCII values, excluding Function keys etc.}
  526.  
  527. Procedure key_process;
  528. begin
  529.   key_lo := what_key & $00FF;
  530.   key_hi := what_key & $FF00;
  531.   key_hi := ShR(key_hi,8);
  532.   check_key;
  533.  
  534. end;
  535.  
  536.         { Once we have received a message from GEM it is up to your
  537.           program to determine just what to do with it. This routine
  538.           checks the most used messages, and performs a simple routine
  539.           within the program to handle each type of message.            }
  540.  
  541. Procedure msg_process;
  542. begin
  543.   Case msg[0] of
  544.         MN_Selected     :  If Front_Window = big_window then
  545.                                 menu_proc;
  546.  
  547.         WM_Sized        :  If Front_Window = big_window then
  548.                                 size_wind;
  549.  
  550.         WM_Fulled       :  If Front_Window = big_window then
  551.                                 full_wind;
  552.  
  553.         WM_Moved        :  If Front_Window = big_window then
  554.                                 move_wind;
  555.  
  556.         WM_Redraw       :  If msg[3] = big_window then
  557.           Do_Redraw(msg[3],msg[4],msg[5],msg[6],msg[7]);
  558.  
  559.         WM_Topped       :  Do_Topped;
  560.  
  561.   end;
  562.  
  563. end;
  564.  
  565.         { This is the heart of the program. This event routine is
  566.           repeated over and over until a WM_Closed message is
  567.           received. If the window is closed, the program ends. You
  568.           could also use a QUIT command in one of your menus, and
  569.           force a closed message to cause the program to end.           }
  570.  
  571. Procedure event_rtn;
  572. begin
  573.   event := Get_Event(event_val,
  574.                      0,0,0,             { No button goodies     }
  575.                      0,                 { No timer              }
  576.                      False,0,0,0,0,     { No mouse rects        }
  577.                      False,0,0,0,0,
  578.                      msg,
  579.                      what_key,          { Key pressed           }
  580.                      dummy,dummy,       { Not used              }
  581.                      dummy,dummy,
  582.                      dummy
  583.                      );
  584.  
  585.   If (event & E_Message) <> 0 then
  586.     msg_process;
  587.  
  588.   If (event & E_Keyboard) <> 0 then
  589.     key_process;
  590.  
  591. end;
  592.  
  593.         { This is a demonstratin of how to create your own menu. Variables
  594.           could be of any integer type, so an array would work. I just
  595.           found it simpler to identify each one uniquely.               }
  596.  
  597. Procedure build_menu;
  598. begin
  599.   a_menu := New_Menu(30,'Pascal Shell');
  600.  
  601.   title1 := Add_MTitle(a_menu,' Title 1 ');
  602.   title2 := Add_MTitle(a_menu,' Title 2 ');
  603.   title3 := Add_MTitle(a_menu,' Title 3 ');
  604.   title4 := Add_MTitle(a_menu,' Title 4 ');
  605.   title5 := Add_MTitle(a_menu,' Title 5 ');
  606.  
  607.   item11 := Add_MItem(a_menu,title1,'  Item 1-1 ');
  608.   item12 := Add_MItem(a_menu,title1,'  Item 1-2 ');
  609.   item13 := Add_MItem(a_menu,title1,'  Item 1-3 ');
  610.  
  611.   item21 := Add_MItem(a_menu,title2,'  Item 2-1 ');
  612.   item22 := Add_MItem(a_menu,title2,'  Item 2-2 ');
  613.   item23 := Add_MItem(a_menu,title2,'  Item 2-3 ');
  614.  
  615.   item31 := Add_MItem(a_menu,title3,'  Item 3-1 ');
  616.   item32 := Add_MItem(a_menu,title3,'  Item 3-2 ');
  617.   item33 := Add_MItem(a_menu,title3,'  Item 3-3 ');
  618.  
  619.   item41 := Add_MItem(a_menu,title4,'  Item 4-1 ');
  620.   item42 := Add_MItem(a_menu,title4,'  Item 4-2 ');
  621.   item43 := Add_MItem(a_menu,title4,'  Item 4-3 ');
  622.  
  623.   item51 := Add_MItem(a_menu,title5,'  Item 5-1 ');
  624.   item52 := Add_MItem(a_menu,title5,'  Item 5-2 ');
  625.   item53 := Add_MItem(a_menu,title5,'  Item 5-3 ');
  626.  
  627.   Draw_Menu(a_menu);
  628. end;
  629.  
  630.         { Just an alert box at the very beginning of the program.       }
  631.  
  632. Procedure show_progname;
  633. begin
  634.   dummy := Do_Alert('[1][SHELL.PAS|Version 1.0|by F.P.Nagle][ OK ]',0);
  635. end;
  636.  
  637.         { I always set up at least one initialize procedure in my programs
  638.           which is always called once. This sets the initial values I
  639.           need for titles, etc. Don't rely on ANY compiler to initialize
  640.           your values for you. Play it safe and do it yourself!         }
  641.  
  642. Procedure init;
  643. begin
  644.   zeron         := 0;
  645.   escn          := 27;
  646.   wind_title    := 'Pascal Program Shell';
  647.   windtype      := G_Name | G_Close | G_Move | G_Size | G_Full;
  648.   event_val     := E_Message | E_Keyboard;
  649.  
  650.   Text_Style(Normal);
  651.   Sys_Font_Size(cw,ch,bw,bh);
  652. end;
  653.  
  654.         { This procedure creates and opens YOUR program window!         }
  655.  
  656. Procedure open_wind;
  657. begin
  658.   big_window := New_Window(windtype,wind_title,0,0,0,0);
  659.   Open_Window(big_window,0,0,0,0);
  660.   Work_Rect(0,hx,hy,hw,hh);    { Here we save the full size for later use }
  661.   Work_Rect(big_window,xm,ym,wm,hm);  { This is the screen work size }
  662.   cur_x := xm;                 { Initialize cursor positions         }
  663.   cur_y := ym + ch;
  664.   blnk_wind;
  665. end;
  666.  
  667.         { Every program normally has some cleanup to do when the program
  668.           ends. This is my End Of Program (eop) processing. Close the
  669.           window, delete OUR menu etc.                                  }
  670.  
  671. Procedure eop_processing;
  672. begin
  673.   Close_Window(big_window);
  674.   Delete_Window(big_window);
  675.   Erase_Menu(a_menu);
  676.   Delete_Menu(a_menu);
  677. end;
  678.  
  679.         { This is the main program. We initialize GEM and check that we
  680.           can run. Init_Mouse will always eliminate any Hides we may have
  681.           remaining from previous programs. It will ALWAYS bring the mouse
  682.           into view. Once we know the status of the mouse we can then
  683.           HIDE it within our program. The clear screen command paints a
  684.           white screen for our program. Just a simple way to give us a
  685.           clean slate to begin with. We then execute a series of procedures
  686.           to set up our program. The repeat within this is the main LOOP
  687.           to continually check for events. When the event is to close the
  688.           window, then we are DONE! The End Of Program processing will
  689.           actually Close and Delete our Window and Menus.               }
  690.  
  691. BEGIN
  692.         If Init_Gem >= 0 then
  693.         begin
  694.                 Init_Mouse;
  695.                 Hide_Mouse;
  696.                 Clear_Screen;
  697.                 build_menu;
  698.                 show_progname;
  699.                 init;
  700.                 open_wind;
  701.                 Show_Mouse;
  702.                 Repeat
  703.                   event_rtn
  704.                 Until msg[0] = WM_Closed;
  705.                 eop_processing;
  706.         end;
  707.  
  708.         { After having used Personal Pascal on a few packages about to
  709.           be released, I felt that the information I had gained could
  710.           be helpful to others in creating GEM applications for the
  711.           520/1040 ST. This SHELL can be expanded into a multitude of
  712.           applications. If you develop a new idea based on this, and
  713.           are looking for ways of distributing it, I can be reached at
  714.           the following:
  715.  
  716.           Frank P. Nagle
  717.           38346 Logan Drive
  718.           Fremont, CA 94536-5901
  719.           Answering machine (415) 791-5461
  720.           MCI Mail - FNAGLE
  721.           Compuserve - 70505,577
  722.           Delphi - FRANKN
  723.           GEnie - F.NAGLE
  724.  
  725.           Good luck with your Personal Pascal work!                     }
  726.  
  727. end.
  728.  
  729.