DBFTEST.LST 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. Listing:
  2. 1 IMPLEMENTATION MODULE DBFTest;
  3. 2 FROM ModBase3 IMPORT InitDBF,OpenDBF,CloseDBF,ReadDBRec,GetField,DBFile,
  4. 3 DeleteRecord,DefaultFixUp,NilDBF,PosOfField,DBFieldArray,
  5. 4 DBFieldPtr,BuildDBF,DBFieldDescriptor;
  6. 5 FROM DBCopier IMPORT DBPack;
  7. 6 FROM DBIndxes IMPORT InitIndex,OpenIndex,AddToUpdateList,CloseIndex,
  8. 7 CurrentRec,FindPositionCh,BuildIndex,GoTop,GoBottom,
  9. 8 NextRecord,PrevRecord,CurrentKeyCh,FindPositionN,
  10. 9 CurrentKeyN,InitCompIndex,BuildCompIndex,DBIndex;
  11. 10 FROM StrEdit IMPORT CrunchBlanks;
  12. 11 FROM HandleIO IMPORT FileExists;
  13. 12 FROM Storage IMPORT ALLOCATE,DEALLOCATE;
  14. 13 FROM DBStuff IMPORT MakeKey;
  15. 14 FROM Drectory IMPORT DeleteFile;
  16. 15 FROM StrConv IMPORT StrToReal;
  17. 16 FROM NumTypes IMPORT Real8;
  18. 17 FROM M2Strings IMPORT Assign;
  19. 18 FROM DBStuff IMPORT MakeKey,MakeDescriptor;
  20. ***** ^ duplicate identifier
  21. ***** ^ duplicate identifier
  22. 19 FROM ScanUtils IMPORT Present,CaseSens;
  23. 20 FROM LowLevel IMPORT Fill;
  24. 21 FROM DBFields IMPORT GetDateField,GetLogicalField,GetNumField,Replace,
  25. 22 ReplaceD,ReplaceN;
  26. 23
  27. 24 CONST
  28. 25 Buffer = 0;
  29. 26 Safty = TRUE;
  30. 27 Exclusive = FALSE;
  31. 28 AutoLock = TRUE;
  32. 29 KeepDeleted = FALSE;
  33. 30 VAR
  34. 31 IndexOpen : BOOLEAN;
  35. 32
  36. 33 PROCEDURE MakeDatabase();
  37. 34 VAR
  38. 35 Error : CARDINAL;
  39. 36 Desc : POINTER TO ARRAY [1..200] OF DBFieldDescriptor;
  40. ***** ^ not supported yet
  41. ***** ^ not supported yet
  42. 37 BEGIN
  43. 38 ALLOCATE(Desc, 2 * SIZE(DBFieldDescriptor));
  44. ***** ^ not supported yet
  45. ***** ^ not supported yet
  46. ***** ^ undeclared identifier
  47. ***** ^ not supported yet
  48. 39 Fill(Desc, 2 * SIZE(DBFieldDescriptor),0);
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. ***** ^ undeclared identifier
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. 40 MakeDescriptor( Desc^[ 1], 'TEST', 30, 0, 'C');
  55. ***** ^ not supported yet
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. ***** ^ not supported yet
  59. ***** ^ not supported yet
  60. 41 MakeDescriptor( Desc^[ 2], 'TEMP', 20, 0, 'C');
  61. ***** ^ not supported yet
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. ***** ^ not supported yet
  65. ***** ^ not supported yet
  66. 42 InitDBF('Test.DBF',TestDBF,0,FALSE,TRUE,FALSE,DefaultFixUp);
  67. ***** ^ not supported yet
  68. ***** ^ not supported yet
  69. ***** ^ undeclared identifier
  70. ***** ^ not supported yet
  71. 43 (* It would be a good to test error.*)
  72. 44 Error:=BuildDBF(Desc^, 2,TestDBF);
  73. ***** ^ not supported yet
  74. ***** ^ not supported yet
  75. ***** ^ undeclared identifier
  76. 45 CloseDBF(TestDBF);
  77. ***** ^ not supported yet
  78. ***** ^ undeclared identifier
  79. 46 DEALLOCATE(Desc, 2 * SIZE(DBFieldDescriptor));
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. ***** ^ undeclared identifier
  83. ***** ^ not supported yet
  84. 47 END MakeDatabase;
  85. ***** ^ not supported yet
  86. 48
  87. 49 PROCEDURE MoveTestToDBF(Rec : TestRec );
  88. ***** ^ undeclared identifier
  89. 50 (* This code will move the data from the record to *)
  90. 51 (* the data base *)
  91. 52 BEGIN
  92. 53 WITH Rec DO
  93. ***** ^ not supported yet
  94. 54 Replace( TestDBF, 1,TEST); (* *)
  95. ***** ^ not supported yet
  96. ***** ^ undeclared identifier
  97. ***** ^ undeclared identifier
  98. 55 Replace( TestDBF, 2,TEMP); (* *)
  99. ***** ^ not supported yet
  100. ***** ^ undeclared identifier
  101. ***** ^ undeclared identifier
  102. 56 END; (* end of with REC *)
  103. ***** ^ not supported yet
  104. 57 END MoveTestToDBF;
  105. ***** ^ not supported yet
  106. 58
  107. 59
  108. 60
  109. 61 PROCEDURE MoveTestFromDBF(VAR Rec : TestRec );
  110. ***** ^ undeclared identifier
  111. 62 (* This code will move the data from the Database to *)
  112. 63 (* the record *)
  113. 64 VAR B : BOOLEAN;
  114. 65 R : Real8;
  115. 66 BEGIN
  116. 67 WITH Rec DO
  117. ***** ^ not supported yet
  118. 68 GetField( TestDBF, 1,TEST); (* *)
  119. ***** ^ not supported yet
  120. ***** ^ undeclared identifier
  121. ***** ^ undeclared identifier
  122. 69 GetField( TestDBF, 2,TEMP); (* *)
  123. ***** ^ not supported yet
  124. ***** ^ undeclared identifier
  125. ***** ^ undeclared identifier
  126. 70 END; (* end of with REC^ *)
  127. ***** ^ not supported yet
  128. 71 END MoveTestFromDBF;
  129. ***** ^ not supported yet
  130. 72
  131. 73
  132. 74
  133. 75 PROCEDURE OpenTestDBF(WithIdx : BOOLEAN);
  134. 76 VAR ER : CARDINAL;
  135. 77 BEGIN
  136. 78
  137. 79 IndexOpen := WithIdx;
  138. 80 (* Open the DBF file *)
  139. 81 IF NOT FileExists("Test.DBF")
  140. ***** ^ not supported yet
  141. ***** ^ not supported yet
  142. 82 THEN MakeDatabase();
  143. ***** ^ not supported yet
  144. ***** ^ not supported yet
  145. 83 END;
  146. 84 InitDBF("Test.DBF", TestDBF,Buffer,Safty,Exclusive,
  147. ***** ^ not supported yet
  148. ***** ^ not supported yet
  149. ***** ^ undeclared identifier
  150. ***** ^ not supported yet
  151. ***** ^ not supported yet
  152. 85 AutoLock,DefaultFixUp );
  153. ***** ^ not supported yet
  154. ***** ^ not supported yet
  155. 86 IF NOT OpenDBF( TestDBF)
  156. ***** ^ not supported yet
  157. ***** ^ undeclared identifier
  158. 87 THEN END;
  159. 88
  160. 89
  161. 90 (* open all indexes and append to dbfile *)
  162. 91 IF WithIdx THEN
  163. 92
  164. 93 InitIndex( "Test.NDX",TestIdx,TestDBF,Buffer, Safty,
  165. ***** ^ not supported yet
  166. ***** ^ not supported yet
  167. ***** ^ undeclared identifier
  168. ***** ^ undeclared identifier
  169. ***** ^ not supported yet
  170. 94 KeepDeleted,Exclusive);
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. 95 IF NOT OpenIndex( TestIdx )
  174. ***** ^ not supported yet
  175. ***** ^ undeclared identifier
  176. 96 THEN
  177. 97 ER := BuildIndex(TestIdx,'Test'); (* check key lenght *)
  178. ***** ^ not supported yet
  179. ***** ^ undeclared identifier
  180. ***** ^ not supported yet
  181. 98 END;
  182. 99 AddToUpdateList( TestDBF, TestIdx );
  183. ***** ^ not supported yet
  184. ***** ^ undeclared identifier
  185. ***** ^ undeclared identifier
  186. 100
  187. 101
  188. 102 ActTestIdx := TestIdx; (* make current index *)
  189. ***** ^ undeclared identifier
  190. ***** ^ undeclared identifier
  191. 103 GoTop(ActTestIdx);
  192. ***** ^ not supported yet
  193. ***** ^ undeclared identifier
  194. 104 END; (* end with indext *)
  195. 105 END OpenTestDBF;
  196. ***** ^ not supported yet
  197. 106
  198. 107
  199. 108
  200. 109 PROCEDURE CloseTestDBF (); (* close Data and index files *)
  201. 110
  202. 111 BEGIN
  203. 112 CloseDBF(TestDBF); (* close dbf file *)
  204. ***** ^ not supported yet
  205. ***** ^ undeclared identifier
  206. 113 IF IndexOpen
  207. 114 THEN
  208. 115
  209. 116 CloseIndex(TestIdx ); (* close index file *)
  210. ***** ^ not supported yet
  211. ***** ^ undeclared identifier
  212. 117 END; (* end index open*)
  213. 118 END CloseTestDBF;
  214. ***** ^ not supported yet
  215. 119
  216. 120
  217. 121
  218. 122 PROCEDURE FindTestByTest( Key : ARRAY OF CHAR) : BOOLEAN;
  219. ***** ^ not supported yet
  220. 123 VAR Found : BOOLEAN;
  221. 124 CKey : ARRAY[0..80] OF CHAR;
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. 125 BEGIN
  225. 126 ActTestIdx := TestIdx ; (* make this index the active idx*)
  226. ***** ^ undeclared identifier
  227. ***** ^ undeclared identifier
  228. 127 FindPositionCh( TestIdx, Key, Found);
  229. ***** ^ not supported yet
  230. ***** ^ undeclared identifier
  231. ***** ^ not supported yet
  232. ***** ^ not supported yet
  233. 128 CurrentKeyCh(TestIdx,CKey);
  234. ***** ^ not supported yet
  235. ***** ^ undeclared identifier
  236. ***** ^ not supported yet
  237. 129 Found := Present(Key,CKey,CaseSens);
  238. ***** ^ not supported yet
  239. ***** ^ not supported yet
  240. ***** ^ not supported yet
  241. ***** ^ not supported yet
  242. 130 IF Found
  243. 131 THEN ReadDBRec( TestDBF, CurrentRec( TestIdx));
  244. ***** ^ not supported yet
  245. ***** ^ undeclared identifier
  246. ***** ^ not supported yet
  247. ***** ^ undeclared identifier
  248. 132 END;
  249. 133 RETURN Found;
  250. 134 END FindTestByTest;
  251. ***** ^ not supported yet
  252. 135
  253. 136
  254. 137
  255. 138
  256. 139
  257. 140
  258. 141
  259. 142 PROCEDURE NextTest () : BOOLEAN;
  260. 143 VAR
  261. 144 L : LONGINT; (* record number *)
  262. 145 BEGIN
  263. 146 IF NextRecord( ActTestIdx,L)
  264. ***** ^ not supported yet
  265. ***** ^ undeclared identifier
  266. ***** ^ not supported yet
  267. 147 THEN ReadDBRec( TestDBF,L );
  268. ***** ^ not supported yet
  269. ***** ^ undeclared identifier
  270. ***** ^ not supported yet
  271. 148 RETURN TRUE;
  272. 149 ELSE RETURN FALSE;
  273. 150 END;
  274. 151 END NextTest;
  275. ***** ^ not supported yet
  276. 152
  277. 153 PROCEDURE PrevTest () : BOOLEAN;
  278. 154 VAR
  279. 155 L : LONGINT; (* record number *)
  280. 156 BEGIN
  281. 157 IF PrevRecord( ActTestIdx,L)
  282. ***** ^ not supported yet
  283. ***** ^ undeclared identifier
  284. ***** ^ not supported yet
  285. 158 THEN ReadDBRec( TestDBF,L );
  286. ***** ^ not supported yet
  287. ***** ^ undeclared identifier
  288. ***** ^ not supported yet
  289. 159 RETURN TRUE;
  290. 160 ELSE RETURN FALSE;
  291. 161 END;
  292. 162 END PrevTest;
  293. ***** ^ not supported yet
  294. 163
  295. 164 PROCEDURE FirstTest ();
  296. 165 VAR
  297. 166 L : LONGINT; (* record number *)
  298. 167 BEGIN
  299. 168 GoTop(ActTestIdx);
  300. ***** ^ not supported yet
  301. ***** ^ undeclared identifier
  302. 169 ReadDBRec( TestDBF,CurrentRec( ActTestIdx));
  303. ***** ^ not supported yet
  304. ***** ^ undeclared identifier
  305. ***** ^ not supported yet
  306. ***** ^ undeclared identifier
  307. 170 END FirstTest;
  308. ***** ^ not supported yet
  309. 171
  310. 172 PROCEDURE LastTest ();
  311. 173 VAR
  312. 174 L : LONGINT; (* record number *)
  313. 175 BEGIN
  314. 176 GoBottom(ActTestIdx);
  315. ***** ^ not supported yet
  316. ***** ^ undeclared identifier
  317. 177 ReadDBRec( TestDBF,CurrentRec( ActTestIdx));
  318. ***** ^ not supported yet
  319. ***** ^ undeclared identifier
  320. ***** ^ not supported yet
  321. ***** ^ undeclared identifier
  322. 178 END LastTest;
  323. ***** ^ not supported yet
  324. 179 PROCEDURE PackTest();
  325. 180 VAR
  326. 181 EM : CARDINAL;
  327. 182 LI : LONGINT;
  328. 183 Tmp : TestRec;
  329. ***** ^ undeclared identifier
  330. 184 BEGIN
  331. 185 CloseTestDBF();
  332. ***** ^ not supported yet
  333. ***** ^ not supported yet
  334. 186 OpenTestDBF(FALSE); (* open with no index *)
  335. ***** ^ not supported yet
  336. ***** ^ not supported yet
  337. 187 DBPack(TestDBF);
  338. ***** ^ not supported yet
  339. ***** ^ undeclared identifier
  340. 188 CloseTestDBF();
  341. ***** ^ not supported yet
  342. ***** ^ not supported yet
  343. 189
  344. 190 EM := DeleteFile('Test');
  345. ***** ^ not supported yet
  346. ***** ^ not supported yet
  347. 191 OpenTestDBF(TRUE); (* open to rebuild the indexes*)
  348. ***** ^ not supported yet
  349. ***** ^ not supported yet
  350. 192 CloseTestDBF();
  351. ***** ^ not supported yet
  352. ***** ^ not supported yet
  353. 193 END PackTest;
  354. ***** ^ not supported yet
  355. 194
  356. 195 (* initialization code *)
  357. 196 BEGIN
  358. 197 NilDBF(TestDBF);
  359. ***** ^ not supported yet
  360. ***** ^ undeclared identifier
  361. 198 IndexOpen := FALSE;
  362. 199
  363. 200 END DBFTest.
  364. ***** ^ not supported yet
  365. 201
  366. 163 errors