ADDRESS2.LST 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. Listing:
  2. 1 MODULE Address2;
  3. 2 (*
  4. 3 Copyright 1989 by Jensen & Partners International, All Rights Reserved
  5. 4 *)
  6. 5
  7. 6
  8. 7 IMPORT IO, FIO, Window, Btree, Str, Lib, Misc;
  9. 8
  10. 9
  11. 10 TYPE
  12. 11 AddrKey = ARRAY[0..25] OF CHAR;
  13. ***** ^ not supported yet
  14. ***** ^ not supported yet
  15. 12 AddrRec = RECORD
  16. 13 LName : ARRAY[0..14] OF CHAR;
  17. ***** ^ not supported yet
  18. ***** ^ not supported yet
  19. 14 FName : ARRAY[0..9] OF CHAR;
  20. ***** ^ not supported yet
  21. ***** ^ not supported yet
  22. 15 Street : ARRAY[0..25] OF CHAR;
  23. ***** ^ not supported yet
  24. ***** ^ not supported yet
  25. 16 City : ARRAY[0..15] OF CHAR;
  26. ***** ^ not supported yet
  27. ***** ^ not supported yet
  28. 17 State : ARRAY[0..1] OF CHAR;
  29. ***** ^ not supported yet
  30. ***** ^ not supported yet
  31. 18 Zip : ARRAY[0..4] OF CHAR;
  32. ***** ^ not supported yet
  33. ***** ^ not supported yet
  34. 19 Phone : ARRAY[0..12] OF CHAR;
  35. ***** ^ not supported yet
  36. ***** ^ not supported yet
  37. 20 END; (* record *)
  38. ***** ^ not supported yet
  39. 21 CharSet = SET OF CHAR;
  40. ***** ^ not supported yet
  41. 22
  42. 23
  43. 24 VAR
  44. 25 choice, ch2 : CHAR;
  45. 26 FOUND,
  46. 27 DONE : BOOLEAN;
  47. 28 DataColor,
  48. 29 TemplateColor : Window.Color;
  49. ***** ^ not supported yet
  50. 30 NameFile : Btree.FHandle; (* physical file handle *)
  51. ***** ^ not supported yet
  52. 31 NameData, (* logical data file handle *)
  53. 32 NameIndex : Btree.IHandle; (* logical index file handle *)
  54. ***** ^ not supported yet
  55. 33 blankAddr,
  56. 34 tempAddr : AddrRec;
  57. ***** ^ not supported yet
  58. 35 Create : BOOLEAN;
  59. 36
  60. 37
  61. 38 PROCEDURE MAKEKEY(keyA,myRecA: ADDRESS);
  62. ***** ^ undeclared identifier
  63. 39 VAR
  64. 40 key : POINTER TO AddrKey;
  65. ***** ^ not supported yet
  66. 41 myRec : POINTER TO AddrRec;
  67. ***** ^ not supported yet
  68. 42 i,j : CARDINAL;
  69. 43 BEGIN
  70. 44 key := keyA;
  71. ***** ^ not supported yet
  72. ***** ^ not supported yet
  73. 45 myRec := myRecA;
  74. ***** ^ not supported yet
  75. ***** ^ not supported yet
  76. 46 Str.Copy(key^,myRec^.LName);
  77. ***** ^ not supported yet
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. ***** ^ not supported yet
  81. ***** ^ not supported yet
  82. 47 i := Str.Length(key^);
  83. ***** ^ not supported yet
  84. ***** ^ not supported yet
  85. ***** ^ not supported yet
  86. 48 WHILE (i#0) AND (key^[i-1]=' ') DO
  87. ***** ^ not supported yet
  88. ***** ^ not supported yet
  89. 49 key^[i-1] := 0C;
  90. ***** ^ not supported yet
  91. ***** ^ not supported yet
  92. 50 DEC(i);
  93. ***** ^ undeclared identifier
  94. ***** ^ not supported yet
  95. 51 END; (* while *)
  96. 52 Str.Append(key^," ");
  97. ***** ^ not supported yet
  98. ***** ^ not supported yet
  99. ***** ^ not supported yet
  100. ***** ^ not supported yet
  101. 53 Str.Append(key^,myRec^.FName);
  102. ***** ^ not supported yet
  103. ***** ^ not supported yet
  104. ***** ^ not supported yet
  105. ***** ^ not supported yet
  106. ***** ^ not supported yet
  107. 54 i := Str.Length(key^);
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. ***** ^ not supported yet
  111. 55 WHILE (i#0) AND (key^[i-1]=' ') DO
  112. ***** ^ not supported yet
  113. ***** ^ not supported yet
  114. 56 key^[i-1] := 0C;
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. 57 DEC(i);
  118. ***** ^ undeclared identifier
  119. ***** ^ not supported yet
  120. 58 END; (* while *)
  121. 59 Str.Caps(key^);
  122. ***** ^ not supported yet
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. 60 END MAKEKEY;
  126. ***** ^ not supported yet
  127. 61
  128. 62
  129. 63 PROCEDURE COMPARE(key1,key2: ADDRESS): Btree.CmpRes;
  130. ***** ^ undeclared identifier
  131. ***** ^ not supported yet
  132. 64 (* compare two keys, and determine which is "smaller" *)
  133. 65 BEGIN
  134. 66 RETURN Btree.CmpRes(Str.Compare(AddrKey(key1^),AddrKey(key2^))+1);
  135. ***** ^ not supported yet
  136. ***** ^ not supported yet
  137. ***** ^ not supported yet
  138. ***** ^ not supported yet
  139. ***** ^ not supported yet
  140. ***** ^ not supported yet
  141. ***** ^ not supported yet
  142. 67 END COMPARE;
  143. ***** ^ not supported yet
  144. 68
  145. 69
  146. 70 PROCEDURE Beep();
  147. 71 BEGIN
  148. 72 (* generic *) FIO.WrChar(FIO.StandardOutput,CHR(7));
  149. ***** ^ not supported yet
  150. ***** ^ not supported yet
  151. ***** ^ not supported yet
  152. ***** ^ not supported yet
  153. ***** ^ undeclared identifier
  154. ***** ^ not supported yet
  155. 73 (* OS/2 *) (* Lib.Speaker(1500,10); *)
  156. 74 (* DOS *) (* Lib.Sound(1500);
  157. 75 Lib.Delay(10);
  158. 76 Lib.NoSound(); *)
  159. 77 END Beep;
  160. ***** ^ not supported yet
  161. 78
  162. 79
  163. 80 PROCEDURE WriteAt(row,col: CARDINAL; txt: ARRAY OF CHAR);
  164. ***** ^ not supported yet
  165. 81 BEGIN
  166. 82 Window.GotoXY(col,row);
  167. ***** ^ not supported yet
  168. ***** ^ not supported yet
  169. ***** ^ not supported yet
  170. 83 IO.WrStr(txt);
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. 84 END WriteAt;
  175. ***** ^ not supported yet
  176. 85
  177. 86
  178. 87 PROCEDURE Template();
  179. 88 BEGIN
  180. 89 Window.TextColor(TemplateColor);
  181. ***** ^ not supported yet
  182. ***** ^ not supported yet
  183. ***** ^ not supported yet
  184. 90 WriteAt(3,3,"Name:");
  185. ***** ^ not supported yet
  186. ***** ^ not supported yet
  187. 91 WriteAt(3,50,"(first last)");
  188. ***** ^ not supported yet
  189. ***** ^ not supported yet
  190. 92 WriteAt(4,3,"Address:");
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. 93 WriteAt(5,3,"City:");
  194. ***** ^ not supported yet
  195. ***** ^ not supported yet
  196. 94 WriteAt(5,40,"State:");
  197. ***** ^ not supported yet
  198. ***** ^ not supported yet
  199. 95 WriteAt(5,55,"Zip:");
  200. ***** ^ not supported yet
  201. ***** ^ not supported yet
  202. 96 WriteAt(6,3,"Phone:");
  203. ***** ^ not supported yet
  204. ***** ^ not supported yet
  205. 97 END Template;
  206. ***** ^ not supported yet
  207. 98
  208. 99
  209. 100 PROCEDURE Display(myRec: AddrRec);
  210. 101 BEGIN
  211. 102 Window.TextColor(DataColor);
  212. ***** ^ not supported yet
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. 103 WriteAt(3,12,myRec.FName); IO.WrStr(" "); IO.WrStr(myRec.LName);
  216. ***** ^ not supported yet
  217. ***** ^ not supported yet
  218. ***** ^ not supported yet
  219. ***** ^ not supported yet
  220. ***** ^ not supported yet
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. ***** ^ not supported yet
  225. ***** ^ not supported yet
  226. 104 WriteAt(4,12,myRec.Street);
  227. ***** ^ not supported yet
  228. ***** ^ not supported yet
  229. ***** ^ not supported yet
  230. 105 WriteAt(5,12,myRec.City);
  231. ***** ^ not supported yet
  232. ***** ^ not supported yet
  233. ***** ^ not supported yet
  234. 106 WriteAt(5,47,myRec.State);
  235. ***** ^ not supported yet
  236. ***** ^ not supported yet
  237. ***** ^ not supported yet
  238. 107 WriteAt(5,60,myRec.Zip);
  239. ***** ^ not supported yet
  240. ***** ^ not supported yet
  241. ***** ^ not supported yet
  242. 108 WriteAt(6,12,myRec.Phone);
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. ***** ^ not supported yet
  246. 109 END Display;
  247. ***** ^ not supported yet
  248. 110
  249. 111
  250. 112 PROCEDURE GetMenu(Prompt: ARRAY OF CHAR; OKChars: CharSet;
  251. ***** ^ not supported yet
  252. 113 VAR ch: CHAR);
  253. 114 VAR
  254. 115 OK : BOOLEAN;
  255. 116 MenuWin : Window.WinType;
  256. ***** ^ not supported yet
  257. 117 i : CARDINAL;
  258. 118 BEGIN
  259. 119 MenuWin := Window.Open( Window.WinDef( 0, 22, 79, 24,
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. ***** ^ not supported yet
  263. ***** ^ not supported yet
  264. ***** ^ not supported yet
  265. 120 Window.White,Window.Black,TRUE,FALSE,TRUE,TRUE,
  266. ***** ^ not supported yet
  267. ***** ^ not supported yet
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. 121 Window.SingleFrame,Window.White,Window.Black) );
  271. ***** ^ not supported yet
  272. ***** ^ not supported yet
  273. ***** ^ not supported yet
  274. ***** ^ not supported yet
  275. ***** ^ not supported yet
  276. ***** ^ not supported yet
  277. 122 i := Str.Length(Prompt);
  278. ***** ^ not supported yet
  279. ***** ^ not supported yet
  280. ***** ^ not supported yet
  281. 123 Window.Change(MenuWin,((80-i) DIV 2) -2,22, ((80-i) DIV 2) + i + 3, 24);
  282. ***** ^ not supported yet
  283. ***** ^ not supported yet
  284. ***** ^ not supported yet
  285. ***** ^ not supported yet
  286. 124 Window.SetFrame(MenuWin,Window.SingleFrame,TemplateColor,Window.Black);
  287. ***** ^ not supported yet
  288. ***** ^ not supported yet
  289. ***** ^ not supported yet
  290. ***** ^ not supported yet
  291. ***** ^ not supported yet
  292. ***** ^ not supported yet
  293. ***** ^ not supported yet
  294. ***** ^ not supported yet
  295. 125 Window.TextColor(DataColor);
  296. ***** ^ not supported yet
  297. ***** ^ not supported yet
  298. ***** ^ not supported yet
  299. 126 Window.Use(MenuWin);
  300. ***** ^ not supported yet
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. 127 Window.PutOnTop(MenuWin);
  304. ***** ^ not supported yet
  305. ***** ^ not supported yet
  306. ***** ^ not supported yet
  307. 128 IO.WrStr(" ");
  308. ***** ^ not supported yet
  309. ***** ^ not supported yet
  310. ***** ^ not supported yet
  311. 129 IO.WrStr(Prompt);
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. ***** ^ not supported yet
  315. 130 OK := FALSE;
  316. 131 REPEAT
  317. 132 ch := CAP(IO.RdKey());
  318. ***** ^ undeclared identifier
  319. ***** ^ not supported yet
  320. ***** ^ not supported yet
  321. ***** ^ not supported yet
  322. 133 IF ch IN OKChars THEN
  323. ***** ^ not supported yet
  324. 134 OK := TRUE;
  325. 135 ELSE
  326. 136 Beep();
  327. ***** ^ not supported yet
  328. ***** ^ not supported yet
  329. 137 END;
  330. 138 UNTIL OK;
  331. 139 Window.Close(MenuWin);
  332. ***** ^ not supported yet
  333. ***** ^ not supported yet
  334. ***** ^ not supported yet
  335. 140 END GetMenu;
  336. ***** ^ not supported yet
  337. 141
  338. 142
  339. 143 PROCEDURE ShowNames();
  340. 144 VAR
  341. 145 myRec : AddrRec;
  342. ***** ^ not supported yet
  343. 146 ch : CHAR;
  344. 147 row : CARDINAL;
  345. 148 switchColor : BOOLEAN;
  346. 149 loc : LONGCARD;
  347. ***** ^ undeclared identifier
  348. 150 BEGIN
  349. 151 Window.Clear();
  350. ***** ^ not supported yet
  351. ***** ^ not supported yet
  352. ***** ^ not supported yet
  353. 152 Btree.Reset(NameData);
  354. ***** ^ not supported yet
  355. ***** ^ not supported yet
  356. ***** ^ not supported yet
  357. 153 row := 1;
  358. 154 switchColor := TRUE;
  359. 155 LOOP
  360. 156 IF Btree.Next(NameIndex,myRec) THEN
  361. ***** ^ not supported yet
  362. ***** ^ not supported yet
  363. ***** ^ not supported yet
  364. ***** ^ not supported yet
  365. 157 IF switchColor THEN
  366. 158 Window.TextColor(TemplateColor);
  367. ***** ^ not supported yet
  368. ***** ^ not supported yet
  369. ***** ^ not supported yet
  370. 159 ELSE
  371. 160 Window.TextColor(DataColor);
  372. ***** ^ not supported yet
  373. ***** ^ not supported yet
  374. ***** ^ not supported yet
  375. 161 END;
  376. 162 switchColor := NOT switchColor;
  377. 163 IO.WrStrAdj(myRec.LName, -17);
  378. ***** ^ not supported yet
  379. ***** ^ not supported yet
  380. ***** ^ not supported yet
  381. ***** ^ not supported yet
  382. ***** ^ not supported yet
  383. 164 IO.WrStrAdj(myRec.FName, -12);
  384. ***** ^ not supported yet
  385. ***** ^ not supported yet
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. ***** ^ not supported yet
  389. 165 IO.WrStrAdj(myRec.Phone, -15);
  390. ***** ^ not supported yet
  391. ***** ^ not supported yet
  392. ***** ^ not supported yet
  393. ***** ^ not supported yet
  394. ***** ^ not supported yet
  395. 166 IO.WrLn();
  396. ***** ^ not supported yet
  397. ***** ^ not supported yet
  398. ***** ^ not supported yet
  399. 167 INC(row);
  400. ***** ^ undeclared identifier
  401. ***** ^ not supported yet
  402. 168 Btree.Release(NameIndex);
  403. ***** ^ not supported yet
  404. ***** ^ not supported yet
  405. ***** ^ not supported yet
  406. 169 IF row>23 THEN
  407. 170 IO.WrLn();
  408. ***** ^ not supported yet
  409. ***** ^ not supported yet
  410. ***** ^ not supported yet
  411. 171 IO.WrStr("Press <ESC> to quit, any other key to continue: ");
  412. ***** ^ not supported yet
  413. ***** ^ not supported yet
  414. ***** ^ not supported yet
  415. 172 ch := IO.RdKey();
  416. ***** ^ not supported yet
  417. ***** ^ not supported yet
  418. ***** ^ not supported yet
  419. 173 IF ch = 33C THEN RETURN; END;
  420. 174 Window.Clear();
  421. ***** ^ not supported yet
  422. ***** ^ not supported yet
  423. ***** ^ not supported yet
  424. 175 row := 1;
  425. 176 END; (* if *)
  426. 177 ELSE
  427. 178 CASE Btree.LastError(NameIndex) OF
  428. ***** ^ not supported yet
  429. ***** ^ not supported yet
  430. ***** ^ not supported yet
  431. 179 Btree.OK : EXIT;
  432. ***** ^ not supported yet
  433. ***** ^ not supported yet
  434. 180 | Btree.Locked : IF Btree.NextIndex(NameIndex,loc) THEN
  435. ***** ^ not supported yet
  436. ***** ^ not supported yet
  437. ***** ^ not supported yet
  438. ***** ^ not supported yet
  439. ***** ^ not supported yet
  440. ***** ^ not supported yet
  441. 181 IO.WrStr('[LOCKED]');
  442. ***** ^ not supported yet
  443. ***** ^ not supported yet
  444. ***** ^ not supported yet
  445. 182 IO.WrLn;
  446. ***** ^ not supported yet
  447. ***** ^ not supported yet
  448. 183 ELSE
  449. 184 CASE Btree.LastError(NameIndex) OF
  450. ***** ^ not supported yet
  451. ***** ^ not supported yet
  452. ***** ^ not supported yet
  453. 185 Btree.OK : EXIT; (* Huh? *)
  454. ***** ^ not supported yet
  455. ***** ^ not supported yet
  456. 186 | Btree.Locked : IO.WrStr('[INDEX LOCKED]');
  457. ***** ^ not supported yet
  458. ***** ^ not supported yet
  459. ***** ^ not supported yet
  460. ***** ^ not supported yet
  461. ***** ^ not supported yet
  462. 187 IO.WrLn;
  463. ***** ^ not supported yet
  464. ***** ^ not supported yet
  465. 188 EXIT;
  466. 189 ELSE
  467. 190 IO.WrStr('[ERROR]');
  468. ***** ^ not supported yet
  469. ***** ^ not supported yet
  470. ***** ^ not supported yet
  471. 191 IO.WrLn;
  472. ***** ^ not supported yet
  473. ***** ^ not supported yet
  474. 192 EXIT;
  475. 193 END;
  476. 194 END;
  477. 195 ELSE
  478. 196 IO.WrStr('[ERROR]');
  479. ***** ^ not supported yet
  480. ***** ^ not supported yet
  481. ***** ^ not supported yet
  482. 197 IO.WrLn;
  483. ***** ^ not supported yet
  484. ***** ^ not supported yet
  485. 198 EXIT;
  486. 199 END;
  487. 200 END;
  488. 201 END;
  489. 202 END ShowNames;
  490. ***** ^ not supported yet
  491. 203
  492. 204
  493. 205 PROCEDURE FindName();
  494. 206 VAR
  495. 207 fname : AddrKey;
  496. ***** ^ not supported yet
  497. 208 myRec : AddrRec;
  498. ***** ^ not supported yet
  499. 209 ch : CHAR;
  500. 210 BEGIN
  501. 211 Window.Clear();
  502. ***** ^ not supported yet
  503. ***** ^ not supported yet
  504. ***** ^ not supported yet
  505. 212 Window.TextColor(TemplateColor);
  506. ***** ^ not supported yet
  507. ***** ^ not supported yet
  508. ***** ^ not supported yet
  509. 213 FOUND := FALSE;
  510. 214 WriteAt(3,3,"Enter name as 'Last First' (e.g. 'Smith John').");
  511. ***** ^ not supported yet
  512. ***** ^ not supported yet
  513. 215 WriteAt(4,3,"Be sure to include the space between the names.");
  514. ***** ^ not supported yet
  515. ***** ^ not supported yet
  516. 216 WriteAt(5,3,"> ");
  517. ***** ^ not supported yet
  518. ***** ^ not supported yet
  519. 217 Window.TextColor(DataColor);
  520. ***** ^ not supported yet
  521. ***** ^ not supported yet
  522. ***** ^ not supported yet
  523. 218 Misc.InputStr(fname,25);
  524. ***** ^ not supported yet
  525. ***** ^ not supported yet
  526. ***** ^ not supported yet
  527. ***** ^ not supported yet
  528. 219 Str.Caps(fname);
  529. ***** ^ not supported yet
  530. ***** ^ not supported yet
  531. ***** ^ not supported yet
  532. 220 Window.TextColor(TemplateColor);
  533. ***** ^ not supported yet
  534. ***** ^ not supported yet
  535. ***** ^ not supported yet
  536. 221 WriteAt(7,3,"Searching... ");
  537. ***** ^ not supported yet
  538. ***** ^ not supported yet
  539. 222 IF Btree.Find(NameIndex,fname,myRec) THEN
  540. ***** ^ not supported yet
  541. ***** ^ not supported yet
  542. ***** ^ not supported yet
  543. ***** ^ not supported yet
  544. ***** ^ not supported yet
  545. 223 Window.Clear();
  546. ***** ^ not supported yet
  547. ***** ^ not supported yet
  548. ***** ^ not supported yet
  549. 224 Template();
  550. ***** ^ not supported yet
  551. ***** ^ not supported yet
  552. 225 Display(myRec);
  553. ***** ^ not supported yet
  554. ***** ^ not supported yet
  555. 226 FOUND := TRUE;
  556. 227 ELSIF Btree.LastError(NameIndex) # Btree.Locked THEN
  557. ***** ^ not supported yet
  558. ***** ^ not supported yet
  559. ***** ^ not supported yet
  560. ***** ^ not supported yet
  561. ***** ^ not supported yet
  562. 228 WriteAt(7,20,"done. Failed exact search. Trying closest match.");
  563. ***** ^ not supported yet
  564. ***** ^ not supported yet
  565. 229 Window.TextColor(DataColor);
  566. ***** ^ not supported yet
  567. ***** ^ not supported yet
  568. ***** ^ not supported yet
  569. 230 WriteAt(9,3,"Searching... ");
  570. ***** ^ not supported yet
  571. ***** ^ not supported yet
  572. 231 IF Btree.Search(NameIndex,fname,myRec) THEN
  573. ***** ^ not supported yet
  574. ***** ^ not supported yet
  575. ***** ^ not supported yet
  576. ***** ^ not supported yet
  577. ***** ^ not supported yet
  578. 232 Window.Clear();
  579. ***** ^ not supported yet
  580. ***** ^ not supported yet
  581. ***** ^ not supported yet
  582. 233 Template();
  583. ***** ^ not supported yet
  584. ***** ^ not supported yet
  585. 234 Display(myRec);
  586. ***** ^ not supported yet
  587. ***** ^ not supported yet
  588. 235 FOUND := TRUE;
  589. 236 REPEAT
  590. 237 GetMenu("N)ext, P)revious, or T)his one? ",
  591. ***** ^ not supported yet
  592. ***** ^ not supported yet
  593. 238 CharSet{'N','P','T'},ch);
  594. ***** ^ 'CASE' expected
  595. ***** ^ not supported yet
  596. ***** ^ not supported yet
  597. ***** ^ not supported yet
  598. 239 WriteAt(10,3," ");
  599. 240 CASE ch OF
  600. 241 'N' : IF Btree.Next(NameIndex,myRec) THEN
  601. 242 Display(blankAddr);
  602. 243 Display(myRec);
  603. 244 ELSIF Btree.LastError(NameIndex) = Btree.Locked THEN
  604. 245 WriteAt(10,3,"Locked");
  605. 246 Beep();
  606. 247 ELSE
  607. 248 WriteAt(10,3,"No more records found");
  608. 249 Beep();
  609. 250 Btree.Reset(NameIndex);
  610. 251 Display(blankAddr);
  611. 252 IF Btree.Prev(NameIndex,myRec) THEN
  612. 253 Display(myRec);
  613. 254 ELSE
  614. 255 FOUND := FALSE;
  615. 256 END;
  616. 257 END;
  617. 258 | 'P' : IF Btree.Prev(NameIndex,myRec) THEN
  618. 259 Display(blankAddr);
  619. 260 Display(myRec);
  620. 261 ELSIF Btree.LastError(NameIndex) = Btree.Locked THEN
  621. 262 WriteAt(10,3,"Locked");
  622. 263 Beep();
  623. 264 ELSE
  624. 265 WriteAt(10,3,"No more records found");
  625. 266 Beep();
  626. 267 Btree.Reset(NameIndex);
  627. 268 Display(blankAddr);
  628. 269 IF Btree.Next(NameIndex,myRec) THEN
  629. 270 Display(myRec);
  630. 271 ELSE
  631. 272 FOUND := FALSE;
  632. 273 END;
  633. 274 END;
  634. 275 ELSE
  635. 276 Beep();
  636. 277 END; (* case *)
  637. 278 UNTIL ch = 'T';
  638. 279 ELSE
  639. 280 WriteAt(9,20,"done. Failed closest match search.");
  640. 281 END; (* if *)
  641. 282 ELSE
  642. 283 WriteAt(9,20,"done. Locking conflict occured.");
  643. 284 END; (* if *)
  644. 285 END FindName;
  645. 286
  646. 287
  647. 288 PROCEDURE AddName();
  648. 289 VAR
  649. 290 myRec : AddrRec;
  650. 291 ch : CHAR;
  651. 292 BEGIN
  652. 293 Window.Clear();
  653. 294 Template();
  654. 295 ch := 'N';
  655. 296 myRec := blankAddr;
  656. 297 REPEAT
  657. 298 Window.TextColor(DataColor);
  658. 299 Window.GotoXY(12,3); Misc.InputStr(myRec.FName,10);
  659. 300 Window.GotoXY(35,3); Misc.InputStr(myRec.LName,15);
  660. 301 Window.GotoXY(12,4); Misc.InputStr(myRec.Street,25);
  661. 302 Window.GotoXY(12,5); Misc.InputStr(myRec.City,15);
  662. 303 Window.GotoXY(47,5); Misc.InputStr(myRec.State,2);
  663. 304 Window.GotoXY(60,5); Misc.InputStr(myRec.Zip,5);
  664. 305 Window.GotoXY(12,6); Misc.InputStr(myRec.Phone,12);
  665. 306 GetMenu("Do these look ok? (Y/N) ",CharSet{'Y','N'},ch);
  666. 307 UNTIL ch = 'Y';
  667. 308 (* Now put it in the file *)
  668. 309 Btree.Add(NameData,myRec,SIZE(myRec));
  669. 310 END AddName;
  670. 311
  671. 312
  672. 313 PROCEDURE DeleteName();
  673. 314 VAR
  674. 315 ch : CHAR;
  675. 316 BEGIN
  676. 317 FindName();
  677. 318 IF FOUND THEN
  678. 319 GetMenu("Delete this one? (Y/N) ",CharSet{'Y','N'},ch);
  679. 320 IF ch = 'Y' THEN
  680. 321 Btree.Delete(NameData);
  681. 322 END; (* if *)
  682. 323 END; (* if *)
  683. 324 Btree.Release(NameIndex);
  684. 325 FOUND := FALSE;
  685. 326 END DeleteName;
  686. 327
  687. 328
  688. 329 BEGIN (* main program *)
  689. 330 TemplateColor := Window.LightGreen;
  690. 331 DataColor := Window.Yellow;
  691. 332 Str.Copy(blankAddr.LName," ");
  692. 333 Str.Copy(blankAddr.FName," ");
  693. 334 Str.Copy(blankAddr.Street," ");
  694. 335 Str.Copy(blankAddr.City," ");
  695. 336 Str.Copy(blankAddr.State," ");
  696. 337 Str.Copy(blankAddr.Zip," ");
  697. 338 Str.Copy(blankAddr.Phone," ");
  698. 339 Window.Clear();
  699. 340 Create := NOT FIO.Exists("Addressb.ook");
  700. 341 LOOP
  701. 342 NameFile := Btree.Open("Addressb.ook",2,Btree.FixSize,FALSE,NOT Create,Create);
  702. 343 NameData := Btree.OpenData(NameFile,1,SIZE(AddrRec),Create);
  703. 344 NameIndex := Btree.OpenIndex(NameFile,NameData,2,COMPARE,MAKEKEY,
  704. 345 SIZE(AddrKey),TRUE,Create);
  705. 346 IF Create THEN
  706. 347 Btree.Close(NameFile);
  707. 348 Create := FALSE;
  708. 349 ELSE
  709. 350 EXIT;
  710. 351 END;
  711. 352 END;
  712. 353 DONE := FALSE;
  713. 354 choice := ' ';
  714. 355 REPEAT
  715. 356 GetMenu("S)howNames F)indSomeone A)ddSomeone D)eleteSomeone Q)uit :",
  716. 357 CharSet{'S','F','A','D','Q'},choice);
  717. 358 CASE choice OF
  718. 359 'S' : ShowNames();
  719. 360 | 'F' : FindName();
  720. 361 Btree.Release(NameIndex);
  721. 362 | 'A' : AddName();
  722. 363 | 'D' : DeleteName();
  723. 364 | 'Q' : DONE := TRUE;
  724. 365 ELSE
  725. 366 Beep();
  726. 367 END; (* case *)
  727. 368 UNTIL DONE;
  728. 369 Btree.Close(NameFile);
  729. 370 END Address2.
  730. 358 errors