DBFORDER.LST 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. Listing:
  2. 1 IMPLEMENTATION MODULE DBFOrder;
  3. 2 (*
  4. 3 * ModBase
  5. 4 * Release 3.0
  6. 5 * (c) Copyright 1986 - 1991 PMI
  7. 6 * P.O. Box 8402
  8. 7 * Green Bay Wi 53308
  9. 8 * All Rights Reserved
  10. 9 * by Ed Ross
  11. 10 *)
  12. 11
  13. 12 FROM ModBase3 IMPORT InitDBF,OpenDBF,CloseDBF,ReadDBRec,GetField,
  14. 13 DBFile,DefaultFixUp,NilDBF;
  15. 14 FROM DBCopier IMPORT DBPack;
  16. 15 FROM DBIndxes IMPORT InitIndex,OpenIndex,AddToUpdateList,CloseIndex,
  17. 16 CurrentRec,FindPositionCh,BuildIndex,GoTop,GoBottom,
  18. 17 NextRecord,PrevRecord,CurrentKeyCh,FindPositionN,
  19. 18 CurrentKeyN,DBIndex,InitCompIndex,BuildCompIndex;
  20. 19 FROM Drectory IMPORT DeleteFile;
  21. 20 FROM StrEdit IMPORT CrunchBlanks,CAPstr;
  22. 21 FROM StrConv IMPORT StrToReal;
  23. 22 FROM NumTypes IMPORT Real8,REALToReal8;
  24. 23 FROM DBStuff IMPORT MakeKey;
  25. 24 FROM ScanUtils IMPORT Present,CaseSens;
  26. 25 FROM DBFields IMPORT GetDateField,GetLogicalField,GetNumField,Replace,
  27. 26 ReplaceD,ReplaceN;
  28. 27
  29. 28
  30. 29 CONST
  31. 30 Buffer = 0;
  32. 31 Safty = TRUE;
  33. 32 Exclusive = FALSE;
  34. 33 AutoLock = TRUE;
  35. 34
  36. 35 VAR IndexOpen,DBInit : BOOLEAN;
  37. 36
  38. 37 PROCEDURE MoveOrderToDBF(Rec : OrderRec );
  39. ***** ^ undeclared identifier
  40. 38 (* This code will move the data from the record to *)
  41. 39 (* the data base *)
  42. 40 BEGIN
  43. 41 WITH Rec DO
  44. ***** ^ not supported yet
  45. 42 Replace( OrderDBF, 1,INVNBR); (* Invoice number *)
  46. ***** ^ not supported yet
  47. ***** ^ undeclared identifier
  48. ***** ^ undeclared identifier
  49. 43 Replace( OrderDBF, 2,ITEMNBR ); (* Item number *)
  50. ***** ^ not supported yet
  51. ***** ^ undeclared identifier
  52. ***** ^ undeclared identifier
  53. 44 Replace( OrderDBF, 3,DESC ); (* Description of item *)
  54. ***** ^ not supported yet
  55. ***** ^ undeclared identifier
  56. ***** ^ undeclared identifier
  57. 45 Replace( OrderDBF, 4,NOTES1 ); (* Notes of items line 1 *)
  58. ***** ^ not supported yet
  59. ***** ^ undeclared identifier
  60. ***** ^ undeclared identifier
  61. 46 Replace( OrderDBF, 5,NOTES2 ); (* Notes for item line 2 *)
  62. ***** ^ not supported yet
  63. ***** ^ undeclared identifier
  64. ***** ^ undeclared identifier
  65. 47 Replace( OrderDBF, 6,NOTES3 ); (* Notes for item line 3 *)
  66. ***** ^ not supported yet
  67. ***** ^ undeclared identifier
  68. ***** ^ undeclared identifier
  69. 48 Replace( OrderDBF, 7,UNITS ); (* Units *)
  70. ***** ^ not supported yet
  71. ***** ^ undeclared identifier
  72. ***** ^ undeclared identifier
  73. 49 ReplaceN( OrderDBF, 8,QNTSOLD ); (* Quantity sold *)
  74. ***** ^ not supported yet
  75. ***** ^ undeclared identifier
  76. ***** ^ undeclared identifier
  77. 50 ReplaceN( OrderDBF, 9,QNTORDER ); (* Quant ordered (for pricing ) *)
  78. ***** ^ not supported yet
  79. ***** ^ undeclared identifier
  80. ***** ^ undeclared identifier
  81. 51 ReplaceN( OrderDBF, 10,REALToReal8(FLOAT(DSCLEVEL ))); (* Discount level applied *)
  82. ***** ^ not supported yet
  83. ***** ^ undeclared identifier
  84. ***** ^ not supported yet
  85. ***** ^ undeclared identifier
  86. ***** ^ undeclared identifier
  87. 52 ReplaceN( OrderDBF, 11,UNITPRC ); (* Item price *)
  88. ***** ^ not supported yet
  89. ***** ^ undeclared identifier
  90. ***** ^ undeclared identifier
  91. 53 ReplaceN( OrderDBF, 12,TOTAL ); (* Total price for line item *)
  92. ***** ^ not supported yet
  93. ***** ^ undeclared identifier
  94. ***** ^ undeclared identifier
  95. 54 Replace( OrderDBF, 13,MANPRICE ); (* over rider computed price *)
  96. ***** ^ not supported yet
  97. ***** ^ undeclared identifier
  98. ***** ^ undeclared identifier
  99. 55 END; (* end of with REC *)
  100. ***** ^ not supported yet
  101. 56 END MoveOrderToDBF;
  102. ***** ^ not supported yet
  103. 57
  104. 58
  105. 59
  106. 60 PROCEDURE MoveOrderFromDBF(VAR Rec : OrderRec );
  107. ***** ^ undeclared identifier
  108. 61 (* This code will move the data from the Database to *)
  109. 62 (* the record *)
  110. 63 VAR B : BOOLEAN;
  111. 64 R : Real8;
  112. 65 BEGIN
  113. 66 WITH Rec DO
  114. ***** ^ not supported yet
  115. 67 GetField( OrderDBF, 1,INVNBR ); (* Invoice number *)
  116. ***** ^ not supported yet
  117. ***** ^ undeclared identifier
  118. ***** ^ undeclared identifier
  119. 68 GetField( OrderDBF, 2,ITEMNBR ); (* Item number *)
  120. ***** ^ not supported yet
  121. ***** ^ undeclared identifier
  122. ***** ^ undeclared identifier
  123. 69 GetField( OrderDBF, 3,DESC ); (* Description of item *)
  124. ***** ^ not supported yet
  125. ***** ^ undeclared identifier
  126. ***** ^ undeclared identifier
  127. 70 GetField( OrderDBF, 4,NOTES1 ); (* Notes of items line 1 *)
  128. ***** ^ not supported yet
  129. ***** ^ undeclared identifier
  130. ***** ^ undeclared identifier
  131. 71 GetField( OrderDBF, 5,NOTES2 ); (* Notes for item line 2 *)
  132. ***** ^ not supported yet
  133. ***** ^ undeclared identifier
  134. ***** ^ undeclared identifier
  135. 72 GetField( OrderDBF, 6,NOTES3 ); (* Notes for item line 3 *)
  136. ***** ^ not supported yet
  137. ***** ^ undeclared identifier
  138. ***** ^ undeclared identifier
  139. 73 GetField( OrderDBF, 7,UNITS ); (* Units *)
  140. ***** ^ not supported yet
  141. ***** ^ undeclared identifier
  142. ***** ^ undeclared identifier
  143. 74 GetNumField( OrderDBF, 8,QNTSOLD ); (* Quantity sold *)
  144. ***** ^ not supported yet
  145. ***** ^ undeclared identifier
  146. ***** ^ undeclared identifier
  147. 75 GetNumField( OrderDBF, 9,QNTORDER ); (* Quant ordered (for pricing ) *)
  148. ***** ^ not supported yet
  149. ***** ^ undeclared identifier
  150. ***** ^ undeclared identifier
  151. 76 GetNumField( OrderDBF, 10,R);
  152. ***** ^ not supported yet
  153. ***** ^ undeclared identifier
  154. ***** ^ not supported yet
  155. 77 DSCLEVEL := TRUNC(R); (* Discount level applied *)
  156. ***** ^ undeclared identifier
  157. ***** ^ undeclared identifier
  158. ***** ^ not supported yet
  159. 78 GetNumField( OrderDBF, 11,UNITPRC ); (* Item price *)
  160. ***** ^ not supported yet
  161. ***** ^ undeclared identifier
  162. ***** ^ undeclared identifier
  163. 79 GetNumField( OrderDBF, 12,TOTAL ); (* Total price for line item *)
  164. ***** ^ not supported yet
  165. ***** ^ undeclared identifier
  166. ***** ^ undeclared identifier
  167. 80 GetField( OrderDBF, 13,MANPRICE ); (* over rider computed price *)
  168. ***** ^ not supported yet
  169. ***** ^ undeclared identifier
  170. ***** ^ undeclared identifier
  171. 81 END; (* end of with REC^ *)
  172. ***** ^ not supported yet
  173. 82 END MoveOrderFromDBF;
  174. ***** ^ not supported yet
  175. 83
  176. 84
  177. 85 PROCEDURE MakeOrderKey(DBF : DBFile; Idx : DBIndex;
  178. 86 VAR Key : ARRAY OF CHAR);
  179. ***** ^ not supported yet
  180. 87
  181. 88 VAR B : BOOLEAN;
  182. 89 BEGIN
  183. 90 GetField( DBF, 1,Key );
  184. ***** ^ not supported yet
  185. ***** ^ not supported yet
  186. ***** ^ not supported yet
  187. 91 MakeKey(Key);
  188. ***** ^ not supported yet
  189. ***** ^ not supported yet
  190. 92 END MakeOrderKey;
  191. ***** ^ not supported yet
  192. 93
  193. 94
  194. 95
  195. 96
  196. 97 PROCEDURE OpenOrderDBF(WithIdx : BOOLEAN);
  197. 98 VAR ER : CARDINAL;
  198. 99 BEGIN
  199. 100 IndexOpen := WithIdx;
  200. 101
  201. 102 (* Open the DBF file *)
  202. 103
  203. 104 IF NOT DBInit THEN
  204. 105 DBInit:=TRUE;
  205. 106 InitDBF("Order.DBF", OrderDBF,Buffer,Safty,Exclusive,AutoLock,DefaultFixUp );
  206. ***** ^ not supported yet
  207. ***** ^ not supported yet
  208. ***** ^ undeclared identifier
  209. ***** ^ not supported yet
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. ***** ^ not supported yet
  213. 107 InitCompIndex( "Invnbr.Idx",InvnbrIdx,OrderDBF,MakeOrderKey,Buffer,
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. ***** ^ undeclared identifier
  217. ***** ^ undeclared identifier
  218. ***** ^ not supported yet
  219. 108 Safty,FALSE,Exclusive);
  220. ***** ^ not supported yet
  221. ***** ^ not supported yet
  222. 109 AddToUpdateList( OrderDBF, InvnbrIdx );
  223. ***** ^ not supported yet
  224. ***** ^ undeclared identifier
  225. ***** ^ undeclared identifier
  226. 110
  227. 111 END;
  228. 112 IF NOT OpenDBF( OrderDBF)
  229. ***** ^ not supported yet
  230. ***** ^ undeclared identifier
  231. 113 THEN END;
  232. 114
  233. 115 IF WithIdx
  234. 116 THEN
  235. 117 (* open all indexes and append to dbfile *)
  236. 118 IF NOT OpenIndex( InvnbrIdx )
  237. ***** ^ not supported yet
  238. ***** ^ undeclared identifier
  239. 119 THEN
  240. 120 ER := BuildCompIndex(InvnbrIdx,'C','Invnbr',12);
  241. ***** ^ not supported yet
  242. ***** ^ undeclared identifier
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. 121 END;
  246. 122 ActOrderIdx := InvnbrIdx; (* make current index *)
  247. ***** ^ undeclared identifier
  248. ***** ^ undeclared identifier
  249. 123 END; (* end with inx *)
  250. 124 END OpenOrderDBF;
  251. ***** ^ not supported yet
  252. 125
  253. 126
  254. 127
  255. 128 PROCEDURE CloseOrderDBF (); (* close Data and index files *)
  256. 129
  257. 130 BEGIN
  258. 131 CloseDBF(OrderDBF); (* close dbf file *)
  259. ***** ^ not supported yet
  260. ***** ^ undeclared identifier
  261. 132 IF IndexOpen
  262. 133 THEN
  263. 134 CloseIndex(InvnbrIdx ); (* close index file *)
  264. ***** ^ not supported yet
  265. ***** ^ undeclared identifier
  266. 135 END;
  267. 136 END CloseOrderDBF;
  268. ***** ^ not supported yet
  269. 137
  270. 138
  271. 139
  272. 140 PROCEDURE FindOrderByInvnbr( Key : ARRAY OF CHAR) : BOOLEAN;
  273. ***** ^ not supported yet
  274. 141 VAR Found : BOOLEAN;
  275. 142 CKey : ARRAY[0..80] OF CHAR;
  276. ***** ^ not supported yet
  277. ***** ^ not supported yet
  278. 143 BEGIN
  279. 144 ActOrderIdx := InvnbrIdx ; (* make this index the active idx*)
  280. ***** ^ undeclared identifier
  281. ***** ^ undeclared identifier
  282. 145 FindPositionCh( InvnbrIdx, Key, Found);
  283. ***** ^ not supported yet
  284. ***** ^ undeclared identifier
  285. ***** ^ not supported yet
  286. ***** ^ not supported yet
  287. 146 CurrentKeyCh(InvnbrIdx,CKey);
  288. ***** ^ not supported yet
  289. ***** ^ undeclared identifier
  290. ***** ^ not supported yet
  291. 147 Found := Present(Key,CKey,CaseSens);
  292. ***** ^ not supported yet
  293. ***** ^ not supported yet
  294. ***** ^ not supported yet
  295. ***** ^ not supported yet
  296. 148 IF Found
  297. 149 THEN ReadDBRec( OrderDBF, CurrentRec( InvnbrIdx));
  298. ***** ^ not supported yet
  299. ***** ^ undeclared identifier
  300. ***** ^ not supported yet
  301. ***** ^ undeclared identifier
  302. 150 END;
  303. 151 RETURN Found;
  304. 152 END FindOrderByInvnbr;
  305. ***** ^ not supported yet
  306. 153
  307. 154
  308. 155
  309. 156
  310. 157
  311. 158
  312. 159
  313. 160 PROCEDURE NextOrder () : BOOLEAN;
  314. 161 VAR
  315. 162 L : LONGINT; (* record number *)
  316. 163 BEGIN
  317. 164 IF NextRecord( ActOrderIdx,L)
  318. ***** ^ not supported yet
  319. ***** ^ undeclared identifier
  320. ***** ^ not supported yet
  321. 165 THEN ReadDBRec( OrderDBF,L );
  322. ***** ^ not supported yet
  323. ***** ^ undeclared identifier
  324. ***** ^ not supported yet
  325. 166 RETURN TRUE;
  326. 167 ELSE RETURN FALSE;
  327. 168 END;
  328. 169 END NextOrder;
  329. ***** ^ not supported yet
  330. 170
  331. 171 PROCEDURE PrevOrder () : BOOLEAN;
  332. 172 VAR
  333. 173 L : LONGINT; (* record number *)
  334. 174 BEGIN
  335. 175 IF PrevRecord( ActOrderIdx,L)
  336. ***** ^ not supported yet
  337. ***** ^ undeclared identifier
  338. ***** ^ not supported yet
  339. 176 THEN ReadDBRec( OrderDBF,L );
  340. ***** ^ not supported yet
  341. ***** ^ undeclared identifier
  342. ***** ^ not supported yet
  343. 177 RETURN TRUE;
  344. 178 ELSE RETURN FALSE;
  345. 179 END;
  346. 180 END PrevOrder;
  347. ***** ^ not supported yet
  348. 181
  349. 182 PROCEDURE FirstOrder ();
  350. 183 VAR
  351. 184 L : LONGINT; (* record number *)
  352. 185 BEGIN
  353. 186 GoTop(ActOrderIdx);
  354. ***** ^ not supported yet
  355. ***** ^ undeclared identifier
  356. 187 ReadDBRec( OrderDBF,CurrentRec( ActOrderIdx));
  357. ***** ^ not supported yet
  358. ***** ^ undeclared identifier
  359. ***** ^ not supported yet
  360. ***** ^ undeclared identifier
  361. 188 END FirstOrder;
  362. ***** ^ not supported yet
  363. 189
  364. 190 PROCEDURE LastOrder ();
  365. 191 VAR
  366. 192 L : LONGINT; (* record number *)
  367. 193 BEGIN
  368. 194 GoBottom(ActOrderIdx);
  369. ***** ^ not supported yet
  370. ***** ^ undeclared identifier
  371. 195 ReadDBRec( OrderDBF,CurrentRec( ActOrderIdx));
  372. ***** ^ not supported yet
  373. ***** ^ undeclared identifier
  374. ***** ^ not supported yet
  375. ***** ^ undeclared identifier
  376. 196 END LastOrder;
  377. ***** ^ not supported yet
  378. 197
  379. 198
  380. 199
  381. 200 PROCEDURE PackOrder();
  382. 201 VAR
  383. 202 EM : CARDINAL;
  384. 203 BEGIN
  385. 204 CloseOrderDBF();
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. 205 OpenOrderDBF(FALSE); (* no index *)
  389. ***** ^ not supported yet
  390. ***** ^ not supported yet
  391. 206 DBPack(OrderDBF);
  392. ***** ^ not supported yet
  393. ***** ^ undeclared identifier
  394. 207
  395. 208 CloseDBF(OrderDBF);
  396. ***** ^ not supported yet
  397. ***** ^ undeclared identifier
  398. 209 EM := DeleteFile("Invnbr.Idx");
  399. ***** ^ not supported yet
  400. ***** ^ not supported yet
  401. 210 OpenOrderDBF(TRUE); (* open & rebuild the index *)
  402. ***** ^ not supported yet
  403. ***** ^ not supported yet
  404. 211 CloseOrderDBF();
  405. ***** ^ not supported yet
  406. ***** ^ not supported yet
  407. 212
  408. 213 END PackOrder;
  409. ***** ^ not supported yet
  410. 214 BEGIN
  411. 215 NilDBF(OrderDBF);
  412. ***** ^ not supported yet
  413. ***** ^ undeclared identifier
  414. 216 IndexOpen := FALSE;
  415. 217 DBInit:=FALSE;
  416. 218 END DBFOrder.
  417. ***** ^ not supported yet
  418. 198 errors