CLUB.MOD 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. MODULE Club;
  2. (*
  3. Copyright (C) 1988,1989 Jensen & Partners International
  4. *)
  5. IMPORT Globals, Btree, Window, Client, Items, IO, FIO, Sales;
  6. FROM Globals IMPORT ClientFile, ItemFile, ClientData, ItemData,
  7. ClientIndex, ItemIndex,
  8. oldWin, TitleWin, DisplayWin, UpdateTitle,
  9. StoreName;
  10. VAR
  11. aClient : Client.ClientRec;
  12. anItem : Items.ItemRec;
  13. ch, ch2, ch3 : CHAR;
  14. GO, Found : BOOLEAN;
  15. lines : CARDINAL;
  16. PROCEDURE OpenClientFiles();
  17. BEGIN
  18. IF NOT FIO.Exists("CLIENT.DAT") THEN (* create a new one *)
  19. ClientFile := Btree.Open("CLIENT.DAT",2,Btree.FixSize,FALSE,FALSE,TRUE);
  20. ClientData := Btree.OpenData(ClientFile,1,SIZE(Client.ClientRec),TRUE);
  21. ClientIndex := Btree.OpenIndex(ClientFile,ClientData,2,Globals.Compare,
  22. Client.MakeKey,SIZE(Globals.FileKey),
  23. TRUE,TRUE);
  24. Btree.Close(ClientFile);
  25. END; (* if *)
  26. ClientFile := Btree.Open("CLIENT.DAT",2,Btree.FixSize,FALSE,FALSE,FALSE);
  27. ClientData := Btree.OpenData(ClientFile,1,SIZE(Client.ClientRec),FALSE);
  28. ClientIndex := Btree.OpenIndex(ClientFile,ClientData,2,Globals.Compare,
  29. Client.MakeKey,SIZE(Globals.FileKey),TRUE,
  30. FALSE);
  31. END OpenClientFiles;
  32. PROCEDURE OpenItemFiles();
  33. BEGIN
  34. IF NOT FIO.Exists("ITEMS.DAT") THEN (* create a new one *)
  35. ItemFile := Btree.Open("ITEMS.DAT",2,Btree.FixSize,FALSE,FALSE,TRUE);
  36. ItemData := Btree.OpenData(ItemFile,1,SIZE(Items.ItemRec),TRUE);
  37. ItemIndex := Btree.OpenIndex(ItemFile,ItemData,2,Globals.Compare,
  38. Items.MakeKey,SIZE(Globals.FileKey),TRUE,
  39. TRUE);
  40. Btree.Close(ItemFile);
  41. END; (* if *)
  42. ItemFile := Btree.Open("ITEMS.DAT",2,Btree.FixSize,FALSE,FALSE,FALSE);
  43. ItemData := Btree.OpenData(ItemFile,1,SIZE(Items.ItemRec),FALSE);
  44. ItemIndex := Btree.OpenIndex(ItemFile,ItemData,2,Globals.Compare,
  45. Items.MakeKey,SIZE(Globals.FileKey),TRUE,
  46. FALSE);
  47. END OpenItemFiles;
  48. PROCEDURE Help();
  49. CONST
  50. HelpWinDef = Window.WinDef(10,7,70,17,Window.Blue,Window.LightGray,
  51. FALSE, TRUE, TRUE, TRUE, Window.DoubleFrame,
  52. Window.Black, Window.LightGray);
  53. VAR
  54. helpWin : Window.WinType;
  55. ch : CHAR;
  56. BEGIN
  57. oldWin := Window.Used();
  58. helpWin := Window.Open(HelpWinDef);
  59. Window.Use(helpWin);
  60. Window.Clear();
  61. Window.SetTitle(helpWin,"Help Window", Window.CenterUpperTitle);
  62. Window.PutOnTop(helpWin);
  63. IO.WrLn(); IO.WrLn();
  64. IO.WrStr(" This is the help window. If you would like to");
  65. IO.WrLn();
  66. IO.WrStr(" change the help, look in the Help() routine in");
  67. IO.WrLn();
  68. IO.WrStr(" the main CLUB.MOD file.");
  69. IO.WrLn();
  70. IO.WrLn(); IO.WrLn();
  71. IO.WrStr(" Press any key to continue... ");
  72. Window.CursorOn();
  73. ch := IO.RdKey();
  74. Window.CursorOff();
  75. Window.Close(helpWin);
  76. Window.Use(oldWin);
  77. Window.PutOnTop(oldWin);
  78. END Help;
  79. BEGIN (* main program *)
  80. StoreName := "Btree Demonstration Store";
  81. Window.PutOnTop(TitleWin);
  82. UpdateTitle(TRUE);
  83. OpenClientFiles();
  84. OpenItemFiles();
  85. REPEAT
  86. Globals.GetMenu("Help Clients Inventory Sales Quit >>",
  87. Globals.CharSet{'H','C','I','S','Q'}, ch );
  88. CASE ch OF
  89. 'H' : Help();
  90. | 'C' : Client.Template();
  91. REPEAT
  92. Globals.GetMenu( "Add Find/edit/delete List Quit >>",
  93. Globals.CharSet{'A','F','E','D','L','Q'}, ch2);
  94. CASE ch2 OF
  95. 'A' : Client.Input(aClient,TRUE);
  96. Btree.Add(ClientData,aClient,
  97. SIZE(Client.ClientRec));
  98. | 'F', 'E', 'D' : aClient.CNum := "";
  99. Found := Client.Search(aClient);
  100. | 'L' : oldWin := Window.Used();
  101. Window.Use(DisplayWin);
  102. Window.Clear();
  103. Window.PutOnTop(DisplayWin);
  104. lines := 0; (* max 17 *)
  105. Btree.Reset(ClientData);
  106. GO := TRUE;
  107. WHILE Btree.Next(ClientIndex,aClient) AND GO DO
  108. IO.WrStrAdj(aClient.CNum,-11);
  109. IO.WrStrAdj(aClient.LName,-16);
  110. IO.WrStrAdj(aClient.FName,-11);
  111. IO.WrStrAdj(aClient.Phone,-16);
  112. IO.WrLn();
  113. INC(lines);
  114. IF lines > 16 THEN
  115. IO.WrStr("Press <ESC> to quit, any other key to continue: ");
  116. ch3 := IO.RdKey();
  117. IF ch3 = 33C THEN
  118. GO := FALSE;
  119. END; (* if *)
  120. Window.Clear();
  121. lines := 0;
  122. END; (* if *)
  123. END; (* while *)
  124. Globals.WriteAt(18,1,"Press a key to finish ");
  125. ch3 := IO.RdKey();
  126. Window.Hide(DisplayWin);
  127. Window.Use(oldWin);
  128. Window.PutOnTop(oldWin);
  129. | 'Q' : Client.Close();
  130. END; (* case *)
  131. UNTIL ch2 = 'Q';
  132. | 'I' : Items.Template();
  133. REPEAT
  134. Globals.GetMenu(
  135. "Add Find/edit/delete List Quit >>",
  136. Globals.CharSet{'A','F','E','D','L','Q'}, ch2);
  137. CASE ch2 OF
  138. 'A' : Items.Input(anItem,TRUE);
  139. Btree.Add(ItemData,anItem,SIZE(Items.ItemRec));
  140. | 'F','E','D' : anItem.INum := "";
  141. Found := Items.Search(anItem);
  142. | 'L' : oldWin := Window.Used();
  143. Window.Use(DisplayWin);
  144. Window.Clear();
  145. Window.PutOnTop(DisplayWin);
  146. lines := 0; (* max 17 *)
  147. Btree.Reset(ItemData);
  148. GO := TRUE;
  149. WHILE Btree.Next(ItemIndex,anItem) AND GO DO
  150. IO.WrStrAdj(anItem.INum,-11);
  151. IO.WrStrAdj(anItem.Description,-26);
  152. IO.WrStrAdj(anItem.Mfgr,-21);
  153. IO.WrStrAdj(anItem.PartNum,-11);
  154. IO.WrLn();
  155. INC(lines);
  156. IF lines > 16 THEN
  157. IO.WrStr("Press <ESC> to quit, any other key to continue: ");
  158. ch3 := IO.RdKey();
  159. IF ch3 = 33C THEN
  160. GO := FALSE;
  161. END; (* if *)
  162. Window.Clear();
  163. lines := 0;
  164. END; (* if *)
  165. END; (* while *)
  166. Globals.WriteAt(18,1,"Press a key to finish ");
  167. ch3 := IO.RdKey();
  168. Window.Hide(DisplayWin);
  169. Window.Use(oldWin);
  170. Window.PutOnTop(oldWin);
  171. | 'Q' : Items.Close();
  172. END; (* case *)
  173. UNTIL ch2 = 'Q';
  174. | 'S' : (* run the sales floor *)
  175. Sales.Template();
  176. REPEAT
  177. Sales.Clear(); (* clear old transaction *)
  178. Globals.GetMenu(
  179. "A)nother sale, S)how summary, or Q)uit to Menu",
  180. Globals.CharSet{'A','Q','S'},ch2);
  181. CASE ch2 OF
  182. 'A' : Sales.Work();
  183. | 'S' : Sales.Summary();
  184. ELSE
  185. Globals.Beep();
  186. END; (* case *)
  187. UNTIL ch2 = 'Q';
  188. Sales.Close();
  189. ELSE
  190. Globals.Beep();
  191. END; (* case *)
  192. UNTIL ch = 'Q';
  193. Btree.Close(ClientFile);
  194. Btree.Close(ItemFile);
  195. Window.CursorOn;
  196. END Club.