DBFINVTR.LST 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. Listing:
  2. 1 IMPLEMENTATION MODULE DBFInvtry;
  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,InitCompIndex,BuildCompIndex,DBIndex;
  20. 19 FROM Drectory IMPORT DeleteFile;
  21. 20 FROM M2Strings IMPORT Assign;
  22. 21 FROM StrEdit IMPORT CrunchBlanks,CAPstr,AssignStr;
  23. 22 FROM DBStuff IMPORT MakeKey;
  24. 23 FROM StrConv IMPORT StrToReal;
  25. 24 FROM NumTypes IMPORT Real8,REALToReal8;
  26. 25 FROM LowLevel IMPORT Fill;
  27. 26 FROM SYSTEM IMPORT ADR;
  28. 27 FROM ScanUtils IMPORT Present,CaseSens;
  29. 28 FROM PosUtils IMPORT Equal;
  30. 29 FROM DBFields IMPORT GetDateField,GetLogicalField,GetNumField,Replace,
  31. 30 ReplaceD,ReplaceN,ReplaceL;
  32. 31
  33. 32 CONST
  34. 33 Buffer = 0;
  35. 34 Safty = TRUE;
  36. 35 Exclusive = FALSE;
  37. 36 AutoLock = TRUE;
  38. 37
  39. 38 VAR
  40. 39 DBInit,IndexOpen : BOOLEAN;
  41. 40
  42. 41
  43. 42 PROCEDURE MoveInvtryToDBF(Rec : InvtryRec );
  44. ***** ^ undeclared identifier
  45. 43 (* This code will move the data from the record to *)
  46. 44 (* the data base *)
  47. 45 BEGIN
  48. 46 WITH Rec DO
  49. ***** ^ not supported yet
  50. 47 CAPstr(INVCODE); (* only caps for item code*)
  51. ***** ^ not supported yet
  52. ***** ^ undeclared identifier
  53. 48 Replace( InvtryDBF, 1,INVCODE);
  54. ***** ^ not supported yet
  55. ***** ^ undeclared identifier
  56. ***** ^ undeclared identifier
  57. 49 ReplaceN( InvtryDBF, 2,REALToReal8(FLOAT(PRICETBL)));
  58. ***** ^ not supported yet
  59. ***** ^ undeclared identifier
  60. ***** ^ not supported yet
  61. ***** ^ undeclared identifier
  62. ***** ^ undeclared identifier
  63. 50 Replace( InvtryDBF, 3,GROUP);
  64. ***** ^ not supported yet
  65. ***** ^ undeclared identifier
  66. ***** ^ undeclared identifier
  67. 51 CAPstr(GROUP);
  68. ***** ^ not supported yet
  69. ***** ^ undeclared identifier
  70. 52 CrunchBlanks(GROUP);
  71. ***** ^ not supported yet
  72. ***** ^ undeclared identifier
  73. 53 Replace( InvtryDBF, 4,DESC);
  74. ***** ^ not supported yet
  75. ***** ^ undeclared identifier
  76. ***** ^ undeclared identifier
  77. 54 ReplaceN( InvtryDBF, 5,REALToReal8(FLOAT(REORDER)));
  78. ***** ^ not supported yet
  79. ***** ^ undeclared identifier
  80. ***** ^ not supported yet
  81. ***** ^ undeclared identifier
  82. ***** ^ undeclared identifier
  83. 55 ReplaceN( InvtryDBF, 6,ONHAND);
  84. ***** ^ not supported yet
  85. ***** ^ undeclared identifier
  86. ***** ^ undeclared identifier
  87. 56 ReplaceN( InvtryDBF, 7,REALToReal8(FLOAT(MINORDER)));
  88. ***** ^ not supported yet
  89. ***** ^ undeclared identifier
  90. ***** ^ not supported yet
  91. ***** ^ undeclared identifier
  92. ***** ^ undeclared identifier
  93. 57 ReplaceN( InvtryDBF, 8,PURPRICE);
  94. ***** ^ not supported yet
  95. ***** ^ undeclared identifier
  96. ***** ^ undeclared identifier
  97. 58 ReplaceL( InvtryDBF, 9,STOCKED);
  98. ***** ^ not supported yet
  99. ***** ^ undeclared identifier
  100. ***** ^ undeclared identifier
  101. 59 Replace( InvtryDBF, 10,UNITS);
  102. ***** ^ not supported yet
  103. ***** ^ undeclared identifier
  104. ***** ^ undeclared identifier
  105. 60 ReplaceD( InvtryDBF, 11,LASTPUR);
  106. ***** ^ not supported yet
  107. ***** ^ undeclared identifier
  108. ***** ^ undeclared identifier
  109. 61 ReplaceN( InvtryDBF, 12,LSTPUAMT);
  110. ***** ^ not supported yet
  111. ***** ^ undeclared identifier
  112. ***** ^ undeclared identifier
  113. 62 CAPstr(ORDERFRM);
  114. ***** ^ not supported yet
  115. ***** ^ undeclared identifier
  116. 63 Replace( InvtryDBF, 13,ORDERFRM);
  117. ***** ^ not supported yet
  118. ***** ^ undeclared identifier
  119. ***** ^ undeclared identifier
  120. 64 ReplaceN( InvtryDBF, 14,UNITPRICE ); (* Unit price if not price table *)
  121. ***** ^ not supported yet
  122. ***** ^ undeclared identifier
  123. ***** ^ undeclared identifier
  124. 65 Replace(InvtryDBF,15,ONORDER); (* 'Y' - item is onorder *)
  125. ***** ^ not supported yet
  126. ***** ^ undeclared identifier
  127. ***** ^ undeclared identifier
  128. 66 ReplaceN(InvtryDBF,16,REORDAMT); (* normal reorder quant *)
  129. ***** ^ not supported yet
  130. ***** ^ undeclared identifier
  131. ***** ^ undeclared identifier
  132. 67
  133. 68 END; (* end of with REC *)
  134. ***** ^ not supported yet
  135. 69 END MoveInvtryToDBF;
  136. ***** ^ not supported yet
  137. 70
  138. 71
  139. 72
  140. 73 PROCEDURE MoveInvtryFromDBF(VAR Rec : InvtryRec );
  141. ***** ^ undeclared identifier
  142. 74 (* This code will move the data from the Database to *)
  143. 75 (* the record *)
  144. 76 VAR B : BOOLEAN;
  145. 77 R : Real8;
  146. 78 BEGIN
  147. 79 WITH Rec DO
  148. ***** ^ not supported yet
  149. 80 GetField( InvtryDBF, 1,INVCODE );
  150. ***** ^ not supported yet
  151. ***** ^ undeclared identifier
  152. ***** ^ undeclared identifier
  153. 81 GetNumField( InvtryDBF, 2,R);
  154. ***** ^ not supported yet
  155. ***** ^ undeclared identifier
  156. ***** ^ not supported yet
  157. 82 PRICETBL:= TRUNC(R);
  158. ***** ^ undeclared identifier
  159. ***** ^ undeclared identifier
  160. ***** ^ not supported yet
  161. 83 GetField( InvtryDBF, 3,GROUP );
  162. ***** ^ not supported yet
  163. ***** ^ undeclared identifier
  164. ***** ^ undeclared identifier
  165. 84 GetField( InvtryDBF, 4,DESC );
  166. ***** ^ not supported yet
  167. ***** ^ undeclared identifier
  168. ***** ^ undeclared identifier
  169. 85 GetNumField( InvtryDBF, 5,R);
  170. ***** ^ not supported yet
  171. ***** ^ undeclared identifier
  172. ***** ^ not supported yet
  173. 86 REORDER:= TRUNC(R);
  174. ***** ^ undeclared identifier
  175. ***** ^ undeclared identifier
  176. ***** ^ not supported yet
  177. 87 GetNumField( InvtryDBF, 6,ONHAND);
  178. ***** ^ not supported yet
  179. ***** ^ undeclared identifier
  180. ***** ^ undeclared identifier
  181. 88 GetNumField( InvtryDBF, 7,R);
  182. ***** ^ not supported yet
  183. ***** ^ undeclared identifier
  184. ***** ^ not supported yet
  185. 89 MINORDER:= TRUNC(R);
  186. ***** ^ undeclared identifier
  187. ***** ^ undeclared identifier
  188. ***** ^ not supported yet
  189. 90 GetNumField( InvtryDBF, 8,PURPRICE);
  190. ***** ^ not supported yet
  191. ***** ^ undeclared identifier
  192. ***** ^ undeclared identifier
  193. 91 GetLogicalField( InvtryDBF, 9,STOCKED);
  194. ***** ^ not supported yet
  195. ***** ^ undeclared identifier
  196. ***** ^ undeclared identifier
  197. 92 GetField( InvtryDBF, 10,UNITS );
  198. ***** ^ not supported yet
  199. ***** ^ undeclared identifier
  200. ***** ^ undeclared identifier
  201. 93 GetDateField( InvtryDBF, 11,LASTPUR);
  202. ***** ^ not supported yet
  203. ***** ^ undeclared identifier
  204. ***** ^ undeclared identifier
  205. 94 GetNumField( InvtryDBF, 12,LSTPUAMT);
  206. ***** ^ not supported yet
  207. ***** ^ undeclared identifier
  208. ***** ^ undeclared identifier
  209. 95 GetField( InvtryDBF, 13,ORDERFRM );
  210. ***** ^ not supported yet
  211. ***** ^ undeclared identifier
  212. ***** ^ undeclared identifier
  213. 96 GetNumField( InvtryDBF, 14,UNITPRICE ); (* Unit price if not price table *)
  214. ***** ^ not supported yet
  215. ***** ^ undeclared identifier
  216. ***** ^ undeclared identifier
  217. 97 GetField(InvtryDBF,15,ONORDER );
  218. ***** ^ not supported yet
  219. ***** ^ undeclared identifier
  220. ***** ^ undeclared identifier
  221. 98 GetNumField(InvtryDBF,16,REORDAMT);
  222. ***** ^ not supported yet
  223. ***** ^ undeclared identifier
  224. ***** ^ undeclared identifier
  225. 99 END; (* end of with REC^ *)
  226. ***** ^ not supported yet
  227. 100 END MoveInvtryFromDBF;
  228. ***** ^ not supported yet
  229. 101
  230. 102 PROCEDURE FixInvRec();
  231. 103 VAR Rec : InvtryRec;
  232. ***** ^ undeclared identifier
  233. 104 BEGIN
  234. 105 MoveInvtryFromDBF(Rec);
  235. ***** ^ not supported yet
  236. ***** ^ not supported yet
  237. 106 MoveInvtryToDBF(Rec);
  238. ***** ^ not supported yet
  239. ***** ^ not supported yet
  240. 107 END FixInvRec;
  241. ***** ^ not supported yet
  242. 108
  243. 109 PROCEDURE MakeItemKey( DBF : DBFile; Idx : DBIndex;
  244. 110 VAR Key : ARRAY OF CHAR);
  245. ***** ^ not supported yet
  246. 111
  247. 112 VAR B : BOOLEAN;
  248. 113 BEGIN
  249. 114 GetField( DBF, 1,Key );
  250. ***** ^ not supported yet
  251. ***** ^ not supported yet
  252. ***** ^ not supported yet
  253. 115 MakeKey(Key);
  254. ***** ^ not supported yet
  255. ***** ^ not supported yet
  256. 116
  257. 117 END MakeItemKey;
  258. ***** ^ not supported yet
  259. 118
  260. 119
  261. 120
  262. 121 PROCEDURE OpenInvtryDBF(WithIdx : BOOLEAN);
  263. 122 VAR
  264. 123 ER : CARDINAL;
  265. 124 BEGIN
  266. 125 IndexOpen := WithIdx;
  267. 126
  268. 127 (* Open the DBF file *)
  269. 128 IF NOT DBInit THEN
  270. 129 DBInit:=TRUE;
  271. 130 InitDBF("Invtry.DBF", InvtryDBF,Buffer,Safty,Exclusive,AutoLock,DefaultFixUp );
  272. ***** ^ not supported yet
  273. ***** ^ not supported yet
  274. ***** ^ undeclared identifier
  275. ***** ^ not supported yet
  276. ***** ^ not supported yet
  277. ***** ^ not supported yet
  278. ***** ^ not supported yet
  279. 131 InitCompIndex( "Invcode.Idx",InvcodeIdx,InvtryDBF,MakeItemKey,Buffer,
  280. ***** ^ not supported yet
  281. ***** ^ not supported yet
  282. ***** ^ undeclared identifier
  283. ***** ^ undeclared identifier
  284. ***** ^ not supported yet
  285. 132 Safty,FALSE,Exclusive);
  286. ***** ^ not supported yet
  287. ***** ^ not supported yet
  288. 133 AddToUpdateList( InvtryDBF, InvcodeIdx );
  289. ***** ^ not supported yet
  290. ***** ^ undeclared identifier
  291. ***** ^ undeclared identifier
  292. 134
  293. 135 END;
  294. 136 IF NOT OpenDBF( InvtryDBF)
  295. ***** ^ not supported yet
  296. ***** ^ undeclared identifier
  297. 137 THEN END;
  298. 138 IF WithIdx THEN
  299. 139
  300. 140 (* open all indexes and append to dbfile *)
  301. 141 IF NOT OpenIndex( InvcodeIdx )
  302. ***** ^ not supported yet
  303. ***** ^ undeclared identifier
  304. 142 THEN
  305. 143 ER := BuildCompIndex(InvcodeIdx, 'C','Invcode',6);
  306. ***** ^ not supported yet
  307. ***** ^ undeclared identifier
  308. ***** ^ not supported yet
  309. ***** ^ not supported yet
  310. 144 END;
  311. 145 ActInvtryIdx := InvcodeIdx; (* make current index *)
  312. ***** ^ undeclared identifier
  313. ***** ^ undeclared identifier
  314. 146
  315. 147 END; (* with index *)
  316. 148 END OpenInvtryDBF;
  317. ***** ^ not supported yet
  318. 149
  319. 150
  320. 151
  321. 152 PROCEDURE CloseInvtryDBF (); (* close Data and index files *)
  322. 153
  323. 154 BEGIN
  324. 155 CloseDBF(InvtryDBF); (* close dbf file *)
  325. ***** ^ not supported yet
  326. ***** ^ undeclared identifier
  327. 156 IF IndexOpen
  328. 157 THEN
  329. 158 CloseIndex(InvcodeIdx ); (* close index file *)
  330. ***** ^ not supported yet
  331. ***** ^ undeclared identifier
  332. 159 END;
  333. 160 END CloseInvtryDBF;
  334. ***** ^ not supported yet
  335. 161
  336. 162
  337. 163
  338. 164 PROCEDURE FindInvtryByInvcode( Key : ARRAY OF CHAR) : BOOLEAN;
  339. ***** ^ not supported yet
  340. 165 VAR Found : BOOLEAN;
  341. 166 CKey : ARRAY[0..80] OF CHAR;
  342. ***** ^ not supported yet
  343. ***** ^ not supported yet
  344. 167 L : LONGINT;
  345. 168 BEGIN
  346. 169 Fill(ADR(CKey),80,0);
  347. ***** ^ not supported yet
  348. ***** ^ not supported yet
  349. ***** ^ not supported yet
  350. ***** ^ not supported yet
  351. 170 Assign(Key,CKey);
  352. ***** ^ not supported yet
  353. ***** ^ not supported yet
  354. ***** ^ not supported yet
  355. 171 CrunchBlanks(CKey);
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. 172 ActInvtryIdx := InvcodeIdx ; (* make this index the active idx*)
  359. ***** ^ undeclared identifier
  360. ***** ^ undeclared identifier
  361. 173 FindPositionCh( InvcodeIdx, CKey, Found);
  362. ***** ^ not supported yet
  363. ***** ^ undeclared identifier
  364. ***** ^ not supported yet
  365. ***** ^ not supported yet
  366. 174 ReadDBRec( InvtryDBF, CurrentRec( InvcodeIdx)); (* if found - then exact*)
  367. ***** ^ not supported yet
  368. ***** ^ undeclared identifier
  369. ***** ^ not supported yet
  370. ***** ^ undeclared identifier
  371. 175 (* else the closest one*)
  372. 176 RETURN Found;
  373. 177 END FindInvtryByInvcode;
  374. ***** ^ not supported yet
  375. 178
  376. 179
  377. 180
  378. 181
  379. 182
  380. 183
  381. 184
  382. 185 PROCEDURE FindInvtryByOrderfrm( Key : ARRAY OF CHAR) : BOOLEAN;
  383. ***** ^ not supported yet
  384. 186 VAR Found : BOOLEAN;
  385. 187 CKey : ARRAY[0..80] OF CHAR;
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. 188 BEGIN
  389. 189 ActInvtryIdx := OrderfrmIdx ; (* make this index the active idx*)
  390. ***** ^ undeclared identifier
  391. ***** ^ undeclared identifier
  392. 190 MakeKey(Key);
  393. ***** ^ not supported yet
  394. ***** ^ not supported yet
  395. 191 FindPositionCh( OrderfrmIdx, Key, Found);
  396. ***** ^ not supported yet
  397. ***** ^ undeclared identifier
  398. ***** ^ not supported yet
  399. ***** ^ not supported yet
  400. 192 CurrentKeyCh(OrderfrmIdx,CKey);
  401. ***** ^ not supported yet
  402. ***** ^ undeclared identifier
  403. ***** ^ not supported yet
  404. 193 Found := Equal(Key,CKey);
  405. ***** ^ not supported yet
  406. ***** ^ not supported yet
  407. ***** ^ not supported yet
  408. 194 IF Found
  409. 195 THEN ReadDBRec( InvtryDBF, CurrentRec( OrderfrmIdx));
  410. ***** ^ not supported yet
  411. ***** ^ undeclared identifier
  412. ***** ^ not supported yet
  413. ***** ^ undeclared identifier
  414. 196 END;
  415. 197 RETURN Found;
  416. 198 END FindInvtryByOrderfrm;
  417. ***** ^ not supported yet
  418. 199
  419. 200
  420. 201
  421. 202
  422. 203
  423. 204
  424. 205
  425. 206 PROCEDURE NextInvtry () : BOOLEAN;
  426. 207 VAR
  427. 208 L : LONGINT; (* record number *)
  428. 209 BEGIN
  429. 210 IF NextRecord( ActInvtryIdx,L)
  430. ***** ^ not supported yet
  431. ***** ^ undeclared identifier
  432. ***** ^ not supported yet
  433. 211 THEN ReadDBRec( InvtryDBF,L );
  434. ***** ^ not supported yet
  435. ***** ^ undeclared identifier
  436. ***** ^ not supported yet
  437. 212 RETURN TRUE;
  438. 213 ELSE RETURN FALSE;
  439. 214 END;
  440. 215 END NextInvtry;
  441. ***** ^ not supported yet
  442. 216
  443. 217 PROCEDURE PrevInvtry () : BOOLEAN;
  444. 218 VAR
  445. 219 L : LONGINT; (* record number *)
  446. 220 BEGIN
  447. 221 IF PrevRecord( ActInvtryIdx,L)
  448. ***** ^ not supported yet
  449. ***** ^ undeclared identifier
  450. ***** ^ not supported yet
  451. 222 THEN ReadDBRec( InvtryDBF,L );
  452. ***** ^ not supported yet
  453. ***** ^ undeclared identifier
  454. ***** ^ not supported yet
  455. 223 RETURN TRUE;
  456. 224 ELSE RETURN FALSE;
  457. 225 END;
  458. 226 END PrevInvtry;
  459. ***** ^ not supported yet
  460. 227
  461. 228 PROCEDURE FirstInvtry ();
  462. 229 VAR
  463. 230 L : LONGINT; (* record number *)
  464. 231 BEGIN
  465. 232 GoTop(ActInvtryIdx);
  466. ***** ^ not supported yet
  467. ***** ^ undeclared identifier
  468. 233 ReadDBRec( InvtryDBF,CurrentRec( ActInvtryIdx));
  469. ***** ^ not supported yet
  470. ***** ^ undeclared identifier
  471. ***** ^ not supported yet
  472. ***** ^ undeclared identifier
  473. 234 END FirstInvtry;
  474. ***** ^ not supported yet
  475. 235
  476. 236 PROCEDURE LastInvtry ();
  477. 237 VAR
  478. 238 L : LONGINT; (* record number *)
  479. 239 BEGIN
  480. 240 GoBottom(ActInvtryIdx);
  481. ***** ^ not supported yet
  482. ***** ^ undeclared identifier
  483. 241 ReadDBRec( InvtryDBF,CurrentRec( ActInvtryIdx));
  484. ***** ^ not supported yet
  485. ***** ^ undeclared identifier
  486. ***** ^ not supported yet
  487. ***** ^ undeclared identifier
  488. 242 END LastInvtry;
  489. ***** ^ not supported yet
  490. 243
  491. 244 PROCEDURE PackInvtry();
  492. 245 VAR
  493. 246 EM : CARDINAL;
  494. 247 BEGIN
  495. 248 CloseInvtryDBF();
  496. ***** ^ not supported yet
  497. ***** ^ not supported yet
  498. 249 OpenInvtryDBF(FALSE);
  499. ***** ^ not supported yet
  500. ***** ^ not supported yet
  501. 250 DBPack(InvtryDBF);
  502. ***** ^ not supported yet
  503. ***** ^ undeclared identifier
  504. 251
  505. 252 CloseDBF(InvtryDBF);
  506. ***** ^ not supported yet
  507. ***** ^ undeclared identifier
  508. 253 EM := DeleteFile("Invcode.Idx");
  509. ***** ^ not supported yet
  510. ***** ^ not supported yet
  511. 254 EM := DeleteFile("Orderfrm.Idx");
  512. ***** ^ not supported yet
  513. ***** ^ not supported yet
  514. 255 OpenInvtryDBF(TRUE); (* open & rebuild the index *)
  515. ***** ^ not supported yet
  516. ***** ^ not supported yet
  517. 256 CloseInvtryDBF();
  518. ***** ^ not supported yet
  519. ***** ^ not supported yet
  520. 257
  521. 258 END PackInvtry;
  522. ***** ^ not supported yet
  523. 259
  524. 260
  525. 261 BEGIN
  526. 262 NilDBF(InvtryDBF);
  527. ***** ^ not supported yet
  528. ***** ^ undeclared identifier
  529. 263 IndexOpen := FALSE;
  530. 264 DBInit:=FALSE;
  531. 265 END DBFInvtry.
  532. ***** ^ not supported yet
  533. 266 errors