ADDRESS.LST 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. Listing:
  2. 1 MODULE Address;
  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 Lib.Speaker(1500,10);
  149. ***** ^ not supported yet
  150. ***** ^ not supported yet
  151. ***** ^ not supported yet
  152. 73 END Beep;
  153. ***** ^ not supported yet
  154. 74
  155. 75
  156. 76 PROCEDURE WriteAt(row,col: CARDINAL; txt: ARRAY OF CHAR);
  157. ***** ^ not supported yet
  158. 77 BEGIN
  159. 78 Window.GotoXY(col,row);
  160. ***** ^ not supported yet
  161. ***** ^ not supported yet
  162. ***** ^ not supported yet
  163. 79 IO.WrStr(txt);
  164. ***** ^ not supported yet
  165. ***** ^ not supported yet
  166. ***** ^ not supported yet
  167. 80 END WriteAt;
  168. ***** ^ not supported yet
  169. 81
  170. 82
  171. 83 PROCEDURE Template();
  172. 84 BEGIN
  173. 85 Window.TextColor(TemplateColor);
  174. ***** ^ not supported yet
  175. ***** ^ not supported yet
  176. ***** ^ not supported yet
  177. 86 WriteAt(3,3,"Name:");
  178. ***** ^ not supported yet
  179. ***** ^ not supported yet
  180. 87 WriteAt(3,50,"(first last)");
  181. ***** ^ not supported yet
  182. ***** ^ not supported yet
  183. 88 WriteAt(4,3,"Address:");
  184. ***** ^ not supported yet
  185. ***** ^ not supported yet
  186. 89 WriteAt(5,3,"City:");
  187. ***** ^ not supported yet
  188. ***** ^ not supported yet
  189. 90 WriteAt(5,40,"State:");
  190. ***** ^ not supported yet
  191. ***** ^ not supported yet
  192. 91 WriteAt(5,55,"Zip:");
  193. ***** ^ not supported yet
  194. ***** ^ not supported yet
  195. 92 WriteAt(6,3,"Phone:");
  196. ***** ^ not supported yet
  197. ***** ^ not supported yet
  198. 93 END Template;
  199. ***** ^ not supported yet
  200. 94
  201. 95
  202. 96 PROCEDURE Display(myRec: AddrRec);
  203. 97 BEGIN
  204. 98 Window.TextColor(DataColor);
  205. ***** ^ not supported yet
  206. ***** ^ not supported yet
  207. ***** ^ not supported yet
  208. 99 WriteAt(3,12,myRec.FName); IO.WrStr(" "); IO.WrStr(myRec.LName);
  209. ***** ^ not supported yet
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. ***** ^ not supported yet
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. ***** ^ not supported yet
  217. ***** ^ not supported yet
  218. ***** ^ not supported yet
  219. 100 WriteAt(4,12,myRec.Street);
  220. ***** ^ not supported yet
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. 101 WriteAt(5,12,myRec.City);
  224. ***** ^ not supported yet
  225. ***** ^ not supported yet
  226. ***** ^ not supported yet
  227. 102 WriteAt(5,47,myRec.State);
  228. ***** ^ not supported yet
  229. ***** ^ not supported yet
  230. ***** ^ not supported yet
  231. 103 WriteAt(5,60,myRec.Zip);
  232. ***** ^ not supported yet
  233. ***** ^ not supported yet
  234. ***** ^ not supported yet
  235. 104 WriteAt(6,12,myRec.Phone);
  236. ***** ^ not supported yet
  237. ***** ^ not supported yet
  238. ***** ^ not supported yet
  239. 105 END Display;
  240. ***** ^ not supported yet
  241. 106
  242. 107
  243. 108 PROCEDURE GetMenu(Prompt: ARRAY OF CHAR; OKChars: CharSet;
  244. ***** ^ not supported yet
  245. 109 VAR ch: CHAR);
  246. 110 VAR
  247. 111 OK : BOOLEAN;
  248. 112 MenuWin : Window.WinType;
  249. ***** ^ not supported yet
  250. 113 i : CARDINAL;
  251. 114 BEGIN
  252. 115 MenuWin := Window.Open( Window.WinDef( 0, 22, 79, 24,
  253. ***** ^ not supported yet
  254. ***** ^ not supported yet
  255. ***** ^ not supported yet
  256. ***** ^ not supported yet
  257. ***** ^ not supported yet
  258. 116 Window.White,Window.Black,TRUE,FALSE,TRUE,TRUE,
  259. ***** ^ not supported yet
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. ***** ^ not supported yet
  263. 117 Window.SingleFrame,Window.White,Window.Black) );
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. ***** ^ not supported yet
  267. ***** ^ not supported yet
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. 118 i := Str.Length(Prompt);
  271. ***** ^ not supported yet
  272. ***** ^ not supported yet
  273. ***** ^ not supported yet
  274. 119 Window.Change(MenuWin,((80-i) DIV 2) -2,22, ((80-i) DIV 2) + i + 3, 24);
  275. ***** ^ not supported yet
  276. ***** ^ not supported yet
  277. ***** ^ not supported yet
  278. ***** ^ not supported yet
  279. 120 Window.SetFrame(MenuWin,Window.SingleFrame,TemplateColor,Window.Black);
  280. ***** ^ not supported yet
  281. ***** ^ not supported yet
  282. ***** ^ not supported yet
  283. ***** ^ not supported yet
  284. ***** ^ not supported yet
  285. ***** ^ not supported yet
  286. ***** ^ not supported yet
  287. ***** ^ not supported yet
  288. 121 Window.TextColor(DataColor);
  289. ***** ^ not supported yet
  290. ***** ^ not supported yet
  291. ***** ^ not supported yet
  292. 122 Window.Use(MenuWin);
  293. ***** ^ not supported yet
  294. ***** ^ not supported yet
  295. ***** ^ not supported yet
  296. 123 Window.PutOnTop(MenuWin);
  297. ***** ^ not supported yet
  298. ***** ^ not supported yet
  299. ***** ^ not supported yet
  300. 124 IO.WrStr(" ");
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. ***** ^ not supported yet
  304. 125 IO.WrStr(Prompt);
  305. ***** ^ not supported yet
  306. ***** ^ not supported yet
  307. ***** ^ not supported yet
  308. 126 OK := FALSE;
  309. 127 REPEAT
  310. 128 ch := CAP(IO.RdKey());
  311. ***** ^ undeclared identifier
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. ***** ^ not supported yet
  315. 129 IF ch IN OKChars THEN
  316. ***** ^ not supported yet
  317. 130 OK := TRUE;
  318. 131 ELSE
  319. 132 Beep();
  320. ***** ^ not supported yet
  321. ***** ^ not supported yet
  322. 133 END;
  323. 134 UNTIL OK;
  324. 135 Window.Close(MenuWin);
  325. ***** ^ not supported yet
  326. ***** ^ not supported yet
  327. ***** ^ not supported yet
  328. 136 END GetMenu;
  329. ***** ^ not supported yet
  330. 137
  331. 138
  332. 139 PROCEDURE ShowNames();
  333. 140 VAR
  334. 141 myRec : AddrRec;
  335. ***** ^ not supported yet
  336. 142 ch : CHAR;
  337. 143 row : CARDINAL;
  338. 144 switchColor : BOOLEAN;
  339. 145 BEGIN
  340. 146 Window.Clear();
  341. ***** ^ not supported yet
  342. ***** ^ not supported yet
  343. ***** ^ not supported yet
  344. 147 Btree.Reset(NameData);
  345. ***** ^ not supported yet
  346. ***** ^ not supported yet
  347. ***** ^ not supported yet
  348. 148 row := 1;
  349. 149 switchColor := TRUE;
  350. 150 WHILE Btree.Next(NameIndex,myRec) DO
  351. ***** ^ not supported yet
  352. ***** ^ not supported yet
  353. ***** ^ not supported yet
  354. ***** ^ not supported yet
  355. 151 IF switchColor THEN
  356. 152 Window.TextColor(TemplateColor);
  357. ***** ^ not supported yet
  358. ***** ^ not supported yet
  359. ***** ^ not supported yet
  360. 153 ELSE
  361. 154 Window.TextColor(DataColor);
  362. ***** ^ not supported yet
  363. ***** ^ not supported yet
  364. ***** ^ not supported yet
  365. 155 END;
  366. 156 switchColor := NOT switchColor;
  367. 157 IO.WrStrAdj(myRec.LName, -17);
  368. ***** ^ not supported yet
  369. ***** ^ not supported yet
  370. ***** ^ not supported yet
  371. ***** ^ not supported yet
  372. ***** ^ not supported yet
  373. 158 IO.WrStrAdj(myRec.FName, -12);
  374. ***** ^ not supported yet
  375. ***** ^ not supported yet
  376. ***** ^ not supported yet
  377. ***** ^ not supported yet
  378. ***** ^ not supported yet
  379. 159 IO.WrStrAdj(myRec.Phone, -15);
  380. ***** ^ not supported yet
  381. ***** ^ not supported yet
  382. ***** ^ not supported yet
  383. ***** ^ not supported yet
  384. ***** ^ not supported yet
  385. 160 IO.WrLn();
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. ***** ^ not supported yet
  389. 161 INC(row);
  390. ***** ^ undeclared identifier
  391. ***** ^ not supported yet
  392. 162 IF row>23 THEN
  393. 163 IO.WrLn();
  394. ***** ^ not supported yet
  395. ***** ^ not supported yet
  396. ***** ^ not supported yet
  397. 164 IO.WrStr("Press <ESC> to quit, any other key to continue: ");
  398. ***** ^ not supported yet
  399. ***** ^ not supported yet
  400. ***** ^ not supported yet
  401. 165 ch := IO.RdKey();
  402. ***** ^ not supported yet
  403. ***** ^ not supported yet
  404. ***** ^ not supported yet
  405. 166 IF ch = 33C THEN RETURN; END;
  406. 167 Window.Clear();
  407. ***** ^ not supported yet
  408. ***** ^ not supported yet
  409. ***** ^ not supported yet
  410. 168 row := 1;
  411. 169 END; (* if *)
  412. 170 END; (* while *)
  413. 171 END ShowNames;
  414. ***** ^ not supported yet
  415. 172
  416. 173
  417. 174 PROCEDURE FindName();
  418. 175 VAR
  419. 176 fname : AddrKey;
  420. ***** ^ not supported yet
  421. 177 myRec : AddrRec;
  422. ***** ^ not supported yet
  423. 178 ch : CHAR;
  424. 179 BEGIN
  425. 180 Window.Clear();
  426. ***** ^ not supported yet
  427. ***** ^ not supported yet
  428. ***** ^ not supported yet
  429. 181 Window.TextColor(TemplateColor);
  430. ***** ^ not supported yet
  431. ***** ^ not supported yet
  432. ***** ^ not supported yet
  433. 182 FOUND := FALSE;
  434. 183 WriteAt(3,3,"Enter name as 'Last First' (e.g. 'Smith John').");
  435. ***** ^ not supported yet
  436. ***** ^ not supported yet
  437. 184 WriteAt(4,3,"Be sure to include the space between the names.");
  438. ***** ^ not supported yet
  439. ***** ^ not supported yet
  440. 185 WriteAt(5,3,"> ");
  441. ***** ^ not supported yet
  442. ***** ^ not supported yet
  443. 186 Window.TextColor(DataColor);
  444. ***** ^ not supported yet
  445. ***** ^ not supported yet
  446. ***** ^ not supported yet
  447. 187 fname := '';
  448. ***** ^ not supported yet
  449. ***** ^ incompatible assignment
  450. 188 Misc.InputStr(fname,25);
  451. ***** ^ not supported yet
  452. ***** ^ not supported yet
  453. ***** ^ not supported yet
  454. ***** ^ not supported yet
  455. 189 Str.Caps(fname);
  456. ***** ^ not supported yet
  457. ***** ^ not supported yet
  458. ***** ^ not supported yet
  459. 190 Window.TextColor(TemplateColor);
  460. ***** ^ not supported yet
  461. ***** ^ not supported yet
  462. ***** ^ not supported yet
  463. 191 WriteAt(7,3,"Searching... ");
  464. ***** ^ not supported yet
  465. ***** ^ not supported yet
  466. 192 IF Btree.Find(NameIndex,fname,myRec) THEN
  467. ***** ^ not supported yet
  468. ***** ^ not supported yet
  469. ***** ^ not supported yet
  470. ***** ^ not supported yet
  471. ***** ^ not supported yet
  472. 193 Window.Clear();
  473. ***** ^ not supported yet
  474. ***** ^ not supported yet
  475. ***** ^ not supported yet
  476. 194 Template();
  477. ***** ^ not supported yet
  478. ***** ^ not supported yet
  479. 195 Display(myRec);
  480. ***** ^ not supported yet
  481. ***** ^ not supported yet
  482. 196 FOUND := TRUE;
  483. 197 ELSE
  484. 198 WriteAt(7,20,"done. Failed exact search. Trying closest match.");
  485. ***** ^ not supported yet
  486. ***** ^ not supported yet
  487. 199 Window.TextColor(DataColor);
  488. ***** ^ not supported yet
  489. ***** ^ not supported yet
  490. ***** ^ not supported yet
  491. 200 WriteAt(9,3,"Searching... ");
  492. ***** ^ not supported yet
  493. ***** ^ not supported yet
  494. 201 IF Btree.Search(NameIndex,fname,myRec) THEN
  495. ***** ^ not supported yet
  496. ***** ^ not supported yet
  497. ***** ^ not supported yet
  498. ***** ^ not supported yet
  499. ***** ^ not supported yet
  500. 202 Window.Clear();
  501. ***** ^ not supported yet
  502. ***** ^ not supported yet
  503. ***** ^ not supported yet
  504. 203 Template();
  505. ***** ^ not supported yet
  506. ***** ^ not supported yet
  507. 204 Display(myRec);
  508. ***** ^ not supported yet
  509. ***** ^ not supported yet
  510. 205 FOUND := TRUE;
  511. 206 REPEAT
  512. 207 GetMenu("N)ext, P)revious, or T)his one? ",
  513. ***** ^ not supported yet
  514. ***** ^ not supported yet
  515. 208 CharSet{'N','P','T'},ch);
  516. ***** ^ 'CASE' expected
  517. ***** ^ not supported yet
  518. ***** ^ not supported yet
  519. ***** ^ not supported yet
  520. 209 WriteAt(10,3," ");
  521. 210 CASE ch OF
  522. 211 'N' : IF Btree.Next(NameIndex,myRec) THEN
  523. 212 Display(blankAddr);
  524. 213 Display(myRec);
  525. 214 ELSE
  526. 215 WriteAt(10,3,"No more records found");
  527. 216 Beep();
  528. 217 Btree.Reset(NameIndex);
  529. 218 Display(blankAddr);
  530. 219 IF Btree.Prev(NameIndex,myRec) THEN
  531. 220 Display(myRec);
  532. 221 ELSE
  533. 222 FOUND := FALSE;
  534. 223 END;
  535. 224 END;
  536. 225 | 'P' : IF Btree.Prev(NameIndex,myRec) THEN
  537. 226 Display(blankAddr);
  538. 227 Display(myRec);
  539. 228 ELSE
  540. 229 WriteAt(10,3,"No more records found");
  541. 230 Beep();
  542. 231 Btree.Reset(NameIndex);
  543. 232 Display(blankAddr);
  544. 233 IF Btree.Next(NameIndex,myRec) THEN
  545. 234 Display(myRec);
  546. 235 ELSE
  547. 236 FOUND := FALSE;
  548. 237 END;
  549. 238 END;
  550. 239 ELSE
  551. 240 Beep();
  552. 241 END; (* case *)
  553. 242 UNTIL ch = 'T';
  554. 243 ELSE
  555. 244 WriteAt(9,20,"done. Failed closest match search.");
  556. 245 END; (* if *)
  557. 246 END; (* if *)
  558. 247 END FindName;
  559. 248
  560. 249
  561. 250 PROCEDURE AddName();
  562. 251 VAR
  563. 252 myRec : AddrRec;
  564. 253 ch : CHAR;
  565. 254 BEGIN
  566. 255 Window.Clear();
  567. 256 Template();
  568. 257 ch := 'N';
  569. 258 myRec := blankAddr;
  570. 259 REPEAT
  571. 260 Window.TextColor(DataColor);
  572. 261 Window.GotoXY(12,3); Misc.InputStr(myRec.FName,10);
  573. 262 Window.GotoXY(35,3); Misc.InputStr(myRec.LName,15);
  574. 263 Window.GotoXY(12,4); Misc.InputStr(myRec.Street,25);
  575. 264 Window.GotoXY(12,5); Misc.InputStr(myRec.City,15);
  576. 265 Window.GotoXY(47,5); Misc.InputStr(myRec.State,2);
  577. 266 Window.GotoXY(60,5); Misc.InputStr(myRec.Zip,5);
  578. 267 Window.GotoXY(12,6); Misc.InputStr(myRec.Phone,12);
  579. 268 GetMenu("Do these look ok? (Y/N) ",CharSet{'Y','N'},ch);
  580. 269 UNTIL ch = 'Y';
  581. 270 (* Now put it in the file *)
  582. 271 Btree.Add(NameData,myRec,SIZE(myRec));
  583. 272 END AddName;
  584. 273
  585. 274
  586. 275 PROCEDURE DeleteName();
  587. 276 VAR
  588. 277 ch : CHAR;
  589. 278 BEGIN
  590. 279 FindName();
  591. 280 IF FOUND THEN
  592. 281 GetMenu("Delete this one? (Y/N) ",CharSet{'Y','N'},ch);
  593. 282 IF ch = 'Y' THEN
  594. 283 Btree.Delete(NameData);
  595. 284 END; (* if *)
  596. 285 END; (* if *)
  597. 286 FOUND := FALSE;
  598. 287 END DeleteName;
  599. 288
  600. 289
  601. 290 BEGIN (* main program *)
  602. 291 TemplateColor := Window.LightGreen;
  603. 292 DataColor := Window.Yellow;
  604. 293 Str.Copy(blankAddr.LName," ");
  605. 294 Str.Copy(blankAddr.FName," ");
  606. 295 Str.Copy(blankAddr.Street," ");
  607. 296 Str.Copy(blankAddr.City," ");
  608. 297 Str.Copy(blankAddr.State," ");
  609. 298 Str.Copy(blankAddr.Zip," ");
  610. 299 Str.Copy(blankAddr.Phone," ");
  611. 300 Window.Clear();
  612. 301 Create := NOT FIO.Exists("Addressb.ook");
  613. 302 NameFile := Btree.Open("Addressb.ook",2,Btree.FixSize,FALSE,FALSE,Create);
  614. 303 NameData := Btree.OpenData(NameFile,1,SIZE(AddrRec),Create);
  615. 304 NameIndex := Btree.OpenIndex(NameFile,NameData,2,COMPARE,MAKEKEY,
  616. 305 SIZE(AddrKey),TRUE,Create);
  617. 306 DONE := FALSE;
  618. 307 choice := ' ';
  619. 308 REPEAT
  620. 309 GetMenu("S)howNames F)indSomeone A)ddSomeone D)eleteSomeone Q)uit :",
  621. 310 CharSet{'S','F','A','D','Q'},choice);
  622. 311 CASE choice OF
  623. 312 'S' : ShowNames();
  624. 313 | 'F' : FindName();
  625. 314 | 'A' : AddName();
  626. 315 | 'D' : DeleteName();
  627. 316 | 'Q' : DONE := TRUE;
  628. 317 ELSE
  629. 318 Beep();
  630. 319 END; (* case *)
  631. 320 UNTIL DONE;
  632. 321 Btree.Close(NameFile);
  633. 322 END Address.
  634. 310 errors