DBFSALES.LST 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. Listing:
  2. 1 IMPLEMENTATION MODULE DBFSalesrec;
  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,DBFile,
  14. 13 DeleteRecord,DefaultFixUp,NilDBF,PosOfField;
  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 StrEdit IMPORT CrunchBlanks;
  21. 20 FROM DBStuff IMPORT MakeKey;
  22. 21 FROM Drectory IMPORT DeleteFile;
  23. 22 FROM StrConv IMPORT StrToReal;
  24. 23 FROM NumTypes IMPORT Real8;
  25. 24 FROM ScanUtils IMPORT Present,CaseSens;
  26. 25 FROM DBFields IMPORT GetDateField,GetLogicalField,GetNumField,Replace,
  27. 26 ReplaceD,ReplaceN;
  28. 27
  29. 28 CONST
  30. 29 Buffer = 0;
  31. 30 Safty = TRUE;
  32. 31 Exclusive = FALSE;
  33. 32 AutoLock = TRUE;
  34. 33 KeepDeleted = FALSE;
  35. 34 VAR
  36. 35 DBInit,IndexOpen : BOOLEAN;
  37. 36
  38. 37
  39. 38 PROCEDURE MoveSalesrecToDBF(Rec : SalesRec );
  40. ***** ^ undeclared identifier
  41. 39 (* This code will move the data from the record to *)
  42. 40 (* the data base *)
  43. 41 BEGIN
  44. 42 WITH Rec DO
  45. ***** ^ not supported yet
  46. 43 Replace( SalesrecDBF, 1,ITEMNBR); (* Item number *)
  47. ***** ^ not supported yet
  48. ***** ^ undeclared identifier
  49. ***** ^ undeclared identifier
  50. 44 ReplaceN( SalesrecDBF, 2,Sold[1] ); (* number of units sold in January *)
  51. ***** ^ not supported yet
  52. ***** ^ undeclared identifier
  53. ***** ^ undeclared identifier
  54. ***** ^ not supported yet
  55. 45 ReplaceN( SalesrecDBF, 3,Sold[2] ); (* Feb *)
  56. ***** ^ not supported yet
  57. ***** ^ undeclared identifier
  58. ***** ^ undeclared identifier
  59. ***** ^ not supported yet
  60. 46 ReplaceN( SalesrecDBF, 4,Sold[3] ); (* Mar *)
  61. ***** ^ not supported yet
  62. ***** ^ undeclared identifier
  63. ***** ^ undeclared identifier
  64. ***** ^ not supported yet
  65. 47 ReplaceN( SalesrecDBF, 5,Sold[4] ); (* *)
  66. ***** ^ not supported yet
  67. ***** ^ undeclared identifier
  68. ***** ^ undeclared identifier
  69. ***** ^ not supported yet
  70. 48 ReplaceN( SalesrecDBF, 6,Sold[5] ); (* *)
  71. ***** ^ not supported yet
  72. ***** ^ undeclared identifier
  73. ***** ^ undeclared identifier
  74. ***** ^ not supported yet
  75. 49 ReplaceN( SalesrecDBF, 7,Sold[6] ); (* *)
  76. ***** ^ not supported yet
  77. ***** ^ undeclared identifier
  78. ***** ^ undeclared identifier
  79. ***** ^ not supported yet
  80. 50 ReplaceN( SalesrecDBF, 8,Sold[7] ); (* *)
  81. ***** ^ not supported yet
  82. ***** ^ undeclared identifier
  83. ***** ^ undeclared identifier
  84. ***** ^ not supported yet
  85. 51 ReplaceN( SalesrecDBF, 9,Sold[8] ); (* *)
  86. ***** ^ not supported yet
  87. ***** ^ undeclared identifier
  88. ***** ^ undeclared identifier
  89. ***** ^ not supported yet
  90. 52 ReplaceN( SalesrecDBF, 10,Sold[9] ); (* *)
  91. ***** ^ not supported yet
  92. ***** ^ undeclared identifier
  93. ***** ^ undeclared identifier
  94. ***** ^ not supported yet
  95. 53 ReplaceN( SalesrecDBF, 11,Sold[10] ); (* *)
  96. ***** ^ not supported yet
  97. ***** ^ undeclared identifier
  98. ***** ^ undeclared identifier
  99. ***** ^ not supported yet
  100. 54 ReplaceN( SalesrecDBF, 12,Sold[11] ); (* *)
  101. ***** ^ not supported yet
  102. ***** ^ undeclared identifier
  103. ***** ^ undeclared identifier
  104. ***** ^ not supported yet
  105. 55 ReplaceN( SalesrecDBF, 13,Sold[12] ); (* *)
  106. ***** ^ not supported yet
  107. ***** ^ undeclared identifier
  108. ***** ^ undeclared identifier
  109. ***** ^ not supported yet
  110. 56 END; (* end of with REC *)
  111. ***** ^ not supported yet
  112. 57 END MoveSalesrecToDBF;
  113. ***** ^ not supported yet
  114. 58
  115. 59
  116. 60
  117. 61 PROCEDURE MoveSalesrecFromDBF(VAR Rec : SalesRec );
  118. ***** ^ undeclared identifier
  119. 62 (* This code will move the data from the Database to *)
  120. 63 (* the record *)
  121. 64 VAR B : BOOLEAN;
  122. 65 R : Real8;
  123. 66 BEGIN
  124. 67 WITH Rec DO
  125. ***** ^ not supported yet
  126. 68 GetField( SalesrecDBF, 1,ITEMNBR); (* Item number *)
  127. ***** ^ not supported yet
  128. ***** ^ undeclared identifier
  129. ***** ^ undeclared identifier
  130. 69 GetNumField( SalesrecDBF, 2,Sold[1] ); (* number of units Sold in January *)
  131. ***** ^ not supported yet
  132. ***** ^ undeclared identifier
  133. ***** ^ undeclared identifier
  134. ***** ^ not supported yet
  135. 70 GetNumField( SalesrecDBF, 3,Sold[2] ); (* Feb *)
  136. ***** ^ not supported yet
  137. ***** ^ undeclared identifier
  138. ***** ^ undeclared identifier
  139. ***** ^ not supported yet
  140. 71 GetNumField( SalesrecDBF, 4,Sold[3] ); (* Mar *)
  141. ***** ^ not supported yet
  142. ***** ^ undeclared identifier
  143. ***** ^ undeclared identifier
  144. ***** ^ not supported yet
  145. 72 GetNumField( SalesrecDBF, 5,Sold[4] ); (* *)
  146. ***** ^ not supported yet
  147. ***** ^ undeclared identifier
  148. ***** ^ undeclared identifier
  149. ***** ^ not supported yet
  150. 73 GetNumField( SalesrecDBF, 6,Sold[5] ); (* *)
  151. ***** ^ not supported yet
  152. ***** ^ undeclared identifier
  153. ***** ^ undeclared identifier
  154. ***** ^ not supported yet
  155. 74 GetNumField( SalesrecDBF, 7,Sold[6] ); (* *)
  156. ***** ^ not supported yet
  157. ***** ^ undeclared identifier
  158. ***** ^ undeclared identifier
  159. ***** ^ not supported yet
  160. 75 GetNumField( SalesrecDBF, 8,Sold[7] ); (* *)
  161. ***** ^ not supported yet
  162. ***** ^ undeclared identifier
  163. ***** ^ undeclared identifier
  164. ***** ^ not supported yet
  165. 76 GetNumField( SalesrecDBF, 9,Sold[8] ); (* *)
  166. ***** ^ not supported yet
  167. ***** ^ undeclared identifier
  168. ***** ^ undeclared identifier
  169. ***** ^ not supported yet
  170. 77 GetNumField( SalesrecDBF, 10,Sold[9] ); (* *)
  171. ***** ^ not supported yet
  172. ***** ^ undeclared identifier
  173. ***** ^ undeclared identifier
  174. ***** ^ not supported yet
  175. 78 GetNumField( SalesrecDBF, 11,Sold[10] ); (* *)
  176. ***** ^ not supported yet
  177. ***** ^ undeclared identifier
  178. ***** ^ undeclared identifier
  179. ***** ^ not supported yet
  180. 79 GetNumField( SalesrecDBF, 12,Sold[11] ); (* *)
  181. ***** ^ not supported yet
  182. ***** ^ undeclared identifier
  183. ***** ^ undeclared identifier
  184. ***** ^ not supported yet
  185. 80 GetNumField( SalesrecDBF, 13,Sold[12] ); (* *)
  186. ***** ^ not supported yet
  187. ***** ^ undeclared identifier
  188. ***** ^ undeclared identifier
  189. ***** ^ not supported yet
  190. 81 END; (* end of with REC^ *)
  191. ***** ^ not supported yet
  192. 82 END MoveSalesrecFromDBF;
  193. ***** ^ not supported yet
  194. 83
  195. 84
  196. 85
  197. 86
  198. 87
  199. 88 PROCEDURE MakeItemnbrKey( DBF : DBFile; Idx : DBIndex;
  200. 89 VAR Key : ARRAY OF CHAR);
  201. ***** ^ not supported yet
  202. 90 VAR
  203. 91 B : BOOLEAN;
  204. 92 FldNum : CARDINAL;
  205. 93 BEGIN
  206. 94 (* this routine doesn't alwasy work - may need to replace with getfiled*)
  207. 95 (* FldNum := PosOfField(DBF,'Itemnbr');*)
  208. 96 GetField(DBF,1,Key);
  209. ***** ^ not supported yet
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. 97 MakeKey(Key);
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. 98 END MakeItemnbrKey;
  216. ***** ^ not supported yet
  217. 99
  218. 100
  219. 101
  220. 102
  221. 103 PROCEDURE OpenSalesrecDBF(WithIdx : BOOLEAN);
  222. 104 VAR ER : CARDINAL;
  223. 105 BEGIN
  224. 106
  225. 107 IndexOpen := WithIdx;
  226. 108 (* Open the DBF file *)
  227. 109 IF NOT DBInit THEN
  228. 110 DBInit:=TRUE;
  229. 111 InitDBF("Salesrec.DBF", SalesrecDBF,Buffer,Safty,Exclusive,
  230. ***** ^ not supported yet
  231. ***** ^ not supported yet
  232. ***** ^ undeclared identifier
  233. ***** ^ not supported yet
  234. ***** ^ not supported yet
  235. 112 AutoLock,DefaultFixUp );
  236. ***** ^ not supported yet
  237. ***** ^ not supported yet
  238. 113 InitCompIndex( "Itemnbr.Idx",SalesRecIdx,SalesrecDBF,MakeItemnbrKey,Buffer, Safty,
  239. ***** ^ not supported yet
  240. ***** ^ not supported yet
  241. ***** ^ undeclared identifier
  242. ***** ^ undeclared identifier
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. 114 KeepDeleted,Exclusive);
  246. ***** ^ not supported yet
  247. ***** ^ not supported yet
  248. 115 AddToUpdateList( SalesrecDBF, SalesRecIdx );
  249. ***** ^ not supported yet
  250. ***** ^ undeclared identifier
  251. ***** ^ undeclared identifier
  252. 116
  253. 117 END;
  254. 118
  255. 119 IF NOT OpenDBF( SalesrecDBF)
  256. ***** ^ not supported yet
  257. ***** ^ undeclared identifier
  258. 120 THEN END;
  259. 121
  260. 122 (* open all indexes and append to dbfile *)
  261. 123 IF WithIdx THEN
  262. 124
  263. 125 IF NOT OpenIndex( SalesRecIdx )
  264. ***** ^ not supported yet
  265. ***** ^ undeclared identifier
  266. 126 THEN
  267. 127 ER := BuildCompIndex(SalesRecIdx,'C','Itemnbr',40); (* check key lenght *)
  268. ***** ^ not supported yet
  269. ***** ^ undeclared identifier
  270. ***** ^ not supported yet
  271. ***** ^ not supported yet
  272. 128 END;
  273. 129
  274. 130
  275. 131 ActSalesrecIdx := SalesRecIdx; (* make current index *)
  276. ***** ^ undeclared identifier
  277. ***** ^ undeclared identifier
  278. 132 END; (* end with indext *)
  279. 133 END OpenSalesrecDBF;
  280. ***** ^ not supported yet
  281. 134
  282. 135
  283. 136
  284. 137 PROCEDURE CloseSalesrecDBF (); (* close Data and index files *)
  285. 138
  286. 139 BEGIN
  287. 140 CloseDBF(SalesrecDBF); (* close dbf file *)
  288. ***** ^ not supported yet
  289. ***** ^ undeclared identifier
  290. 141 IF IndexOpen
  291. 142 THEN
  292. 143
  293. 144 CloseIndex(SalesRecIdx ); (* close index file *)
  294. ***** ^ not supported yet
  295. ***** ^ undeclared identifier
  296. 145 END; (* end index open*)
  297. 146 END CloseSalesrecDBF;
  298. ***** ^ not supported yet
  299. 147
  300. 148
  301. 149
  302. 150 PROCEDURE FindSalesrecByItemnbr( Key : ARRAY OF CHAR) : BOOLEAN;
  303. ***** ^ not supported yet
  304. 151 VAR Found : BOOLEAN;
  305. 152 CKey : ARRAY[0..80] OF CHAR;
  306. ***** ^ not supported yet
  307. ***** ^ not supported yet
  308. 153 BEGIN
  309. 154 ActSalesrecIdx := SalesRecIdx ; (* make this index the active idx*)
  310. ***** ^ undeclared identifier
  311. ***** ^ undeclared identifier
  312. 155 FindPositionCh( SalesRecIdx, Key, Found);
  313. ***** ^ not supported yet
  314. ***** ^ undeclared identifier
  315. ***** ^ not supported yet
  316. ***** ^ not supported yet
  317. 156 CurrentKeyCh(SalesRecIdx,CKey);
  318. ***** ^ not supported yet
  319. ***** ^ undeclared identifier
  320. ***** ^ not supported yet
  321. 157 Found := Present(Key,CKey,CaseSens);
  322. ***** ^ not supported yet
  323. ***** ^ not supported yet
  324. ***** ^ not supported yet
  325. ***** ^ not supported yet
  326. 158 IF Found
  327. 159 THEN ReadDBRec( SalesrecDBF, CurrentRec( SalesRecIdx));
  328. ***** ^ not supported yet
  329. ***** ^ undeclared identifier
  330. ***** ^ not supported yet
  331. ***** ^ undeclared identifier
  332. 160 END;
  333. 161 RETURN Found;
  334. 162 END FindSalesrecByItemnbr;
  335. ***** ^ not supported yet
  336. 163
  337. 164
  338. 165
  339. 166
  340. 167
  341. 168
  342. 169
  343. 170 PROCEDURE NextSalesrec () : BOOLEAN;
  344. 171 VAR
  345. 172 L : LONGINT; (* record number *)
  346. 173 BEGIN
  347. 174 IF NextRecord( ActSalesrecIdx,L)
  348. ***** ^ not supported yet
  349. ***** ^ undeclared identifier
  350. ***** ^ not supported yet
  351. 175 THEN ReadDBRec( SalesrecDBF,L );
  352. ***** ^ not supported yet
  353. ***** ^ undeclared identifier
  354. ***** ^ not supported yet
  355. 176 RETURN TRUE;
  356. 177 ELSE RETURN FALSE;
  357. 178 END;
  358. 179 END NextSalesrec;
  359. ***** ^ not supported yet
  360. 180
  361. 181 PROCEDURE PrevSalesrec () : BOOLEAN;
  362. 182 VAR
  363. 183 L : LONGINT; (* record number *)
  364. 184 BEGIN
  365. 185 IF PrevRecord( ActSalesrecIdx,L)
  366. ***** ^ not supported yet
  367. ***** ^ undeclared identifier
  368. ***** ^ not supported yet
  369. 186 THEN ReadDBRec( SalesrecDBF,L );
  370. ***** ^ not supported yet
  371. ***** ^ undeclared identifier
  372. ***** ^ not supported yet
  373. 187 RETURN TRUE;
  374. 188 ELSE RETURN FALSE;
  375. 189 END;
  376. 190 END PrevSalesrec;
  377. ***** ^ not supported yet
  378. 191
  379. 192 PROCEDURE FirstSalesrec ();
  380. 193 VAR
  381. 194 L : LONGINT; (* record number *)
  382. 195 BEGIN
  383. 196 GoTop(ActSalesrecIdx);
  384. ***** ^ not supported yet
  385. ***** ^ undeclared identifier
  386. 197 ReadDBRec( SalesrecDBF,CurrentRec( ActSalesrecIdx));
  387. ***** ^ not supported yet
  388. ***** ^ undeclared identifier
  389. ***** ^ not supported yet
  390. ***** ^ undeclared identifier
  391. 198 END FirstSalesrec;
  392. ***** ^ not supported yet
  393. 199
  394. 200 PROCEDURE LastSalesrec ();
  395. 201 VAR
  396. 202 L : LONGINT; (* record number *)
  397. 203 BEGIN
  398. 204 GoBottom(ActSalesrecIdx);
  399. ***** ^ not supported yet
  400. ***** ^ undeclared identifier
  401. 205 ReadDBRec( SalesrecDBF,CurrentRec( ActSalesrecIdx));
  402. ***** ^ not supported yet
  403. ***** ^ undeclared identifier
  404. ***** ^ not supported yet
  405. ***** ^ undeclared identifier
  406. 206 END LastSalesrec;
  407. ***** ^ not supported yet
  408. 207 PROCEDURE PackSalesrec();
  409. 208 VAR
  410. 209 EM : CARDINAL;
  411. 210 LI : LONGINT;
  412. 211 Tmp : SalesRec;
  413. ***** ^ undeclared identifier
  414. 212 BEGIN
  415. 213 CloseSalesrecDBF();
  416. ***** ^ not supported yet
  417. ***** ^ not supported yet
  418. 214 OpenSalesrecDBF(FALSE); (* open with no index *)
  419. ***** ^ not supported yet
  420. ***** ^ not supported yet
  421. 215 DBPack(SalesrecDBF);
  422. ***** ^ not supported yet
  423. ***** ^ undeclared identifier
  424. 216 CloseSalesrecDBF();
  425. ***** ^ not supported yet
  426. ***** ^ not supported yet
  427. 217
  428. 218 EM := DeleteFile('Itemnbr');
  429. ***** ^ not supported yet
  430. ***** ^ not supported yet
  431. 219 OpenSalesrecDBF(TRUE); (* open to rebuild the indexes*)
  432. ***** ^ not supported yet
  433. ***** ^ not supported yet
  434. 220 CloseSalesrecDBF();
  435. ***** ^ not supported yet
  436. ***** ^ not supported yet
  437. 221 END PackSalesrec;
  438. ***** ^ not supported yet
  439. 222
  440. 223 (* initialization code *)
  441. 224 BEGIN
  442. 225 NilDBF(SalesrecDBF);
  443. ***** ^ not supported yet
  444. ***** ^ undeclared identifier
  445. 226 IndexOpen := FALSE;
  446. 227 DBInit:=FALSE;
  447. 228 END DBFSalesrec.
  448. ***** ^ not supported yet
  449. 219 errors