home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug054.arc / ADDR1.DOC < prev    next >
Text File  |  1979-12-31  |  12KB  |  462 lines

  1. 8 '
  2. ==================================
  3. === Written & Copyright (c) by ===
  4. ===        John Dowdall        ===
  5. 9 ' OK  TO COPY FOR INDIVIDUAL ===
  6. === USE ONLY.COMMERCIAL RIGHTS ===
  7. ===   RESERVED  BY  MICROFLEX  ===
  8. ==================================
  9. 10 ' here we CLEAR memory and set both screen & printer widths
  10. 12 ' this USER-DEFINED function allows screen addressing
  11. 14 ' set the screen clear and some other variables
  12. 16 ' get the drive info
  13. 18 ' convert drive name to UPPER-CASE and re-check
  14. 20 ' set record length, check file, if none then initialise in 700-
  15. 22 ' otherwise get some details out of the file
  16. 24 ' set some control-key variables
  17. 26 '
  18. 28 '
  19. 30 '
  20. 32 '
  21. 34 '
  22. 36 '
  23. 38 ' set the error handler
  24. 40 ' ok now to start the actual program - so go do it !
  25. 100 REM ------------------------DISK FILE HANDLING-------------------------
  26. 102 ' open the files with specific record lengths
  27. 104 ' length of 2 means this is an INDEX file. kp% is No. of records in file
  28. 106 '
  29. 108 '
  30. 110 '
  31. 112 ' FIELD the data file record into record variables (all strings!)
  32. 114 '
  33. 116 ' copy file variables into memory variables (or 'work-variables')
  34. 118 '
  35. 120 ' set record data back into the fields to write to disk (with PUT)
  36. 122 '
  37. 124 REM
  38. 126 '
  39. 128 ' get a record (number PR%) from disk
  40. 130 '
  41. 132 ' PUT a record onto disk in position number PR%
  42. 134 '
  43. 136 ' clear work variables
  44. 138 ' get header data from file
  45.  
  46.  
  47. 140 ' put header data onto disk
  48.  
  49.  
  50. 142 '
  51. 144 ' FIELD the second INDEX
  52. 146 '
  53. 148 '
  54. 150 '
  55. 152 '
  56. 154 ' a time waster loop
  57. 200 REM --------------------KEYBOARD ENTRY ROUTINE----------------------------
  58. 202 ' clear the inkey$ variable ready for use
  59. 204 ' check inkey$. if null then try again - else->
  60. 206 ' if not null check for KEY TOGGLE (@) or backspace (DEL)
  61. 208 ' check for print labels switch (CTRL-L)
  62. 210 ' check for screen-print switch
  63. 212 ' check for <RETURN> key and CTRL-keys
  64. 214 ' check for backspace, handle as destructive (DEL)
  65.  
  66. 216 ' build input string and go back for next character
  67. 218 ' toggle PRIN% to 0 or -1 for 'screen dump' routine
  68. 220 '
  69. 222 '
  70. 224 '
  71. 226 ' GOTO 202
  72. 300 REM    ---------------------MAIN DATA-ENTRY SCREEN---------------------------
  73. 302 ' set up initial data-entry screen
  74. 304 ' set prompt variables
  75.  
  76.  
  77. 306 ' go to get key field (either NAME or CATEGORY) depending on
  78.       value of variable TOGGLE
  79. 308 ' check for EDIT
  80.       and for DELETE calls and handle them if so
  81. 310 ' check for REINDEX
  82.       and for SORT  calls and handle if so
  83. 312 ' check for forward or backward movement calls
  84.       and handle if needed
  85. 314 ' more browsing movement checks
  86.  
  87. 316 ' if the record exists,display it & set display flag, or its a new one
  88. 318 ' so set some variables
  89. 320 ' and get the address line (street)
  90. 322 ' and the city. If CTRL-K pressed then clear windows and start again
  91.  
  92. 324 ' get the postcode
  93. 326 ' get the phone
  94. 328 ' get the category
  95.  
  96. 330 ' store the new record onto the disk
  97.  
  98. 332 '
  99. 334 ' GOTO 302
  100. 400 REM    --------------------------EDITING-------------------------------------
  101. 402 ' place field numbers beside data
  102.  
  103. 404 ' prompt for field number
  104.  
  105. 406 ' make sure its not too big
  106. 408 ' clear last two lines ready for prompt
  107. 410 ' this is a 'hidden' function (for programmer, NOT operator!)
  108.  
  109. 412 ' get new street
  110.  
  111. 414 ' get new city
  112.  
  113. 416 ' get new postcode
  114.  
  115. 418 ' get new phone
  116.  
  117. 420 ' get new category
  118.  
  119. 422 ' GOTO 404
  120. 424 ' clear editing prompts and return to normal screen
  121. 450 REM    ---------------------------DELETE-------------------------------------
  122. 452 ' you're going to DELETE the displayed record
  123. 454 ' so do it !
  124. 456 '
  125. 458 ' check for previously deleted
  126. 460 '
  127. 462 '
  128. 464 '
  129. 500 REM    ---------------------------SORT---------------------------------------
  130. 502 ' re-FIELD the file to one long string & set some variables
  131.  
  132. 504 ' this is a SCHELL-METZNER  sort so its 'divide (by 2) and conquor'
  133. 506 '
  134. 508 ' when M=0 then job's done
  135. 510 '
  136. 512 '
  137. 514 '
  138. 516 ' get the two records for compare. if deleted then sort 'em to
  139. 518 ' the BOTTOM of the list ready for final oblivion
  140.  
  141. 520 ' and put 'em away
  142. 522 ' else check if <= ... and skip if so
  143. 524 ' otherwise, swap 'em
  144. 526 '
  145. 528 '
  146. 530 '
  147. 532 '
  148. 534 '
  149. 536 '
  150. 538 '
  151. 540 ' heres where tose deleted records finally get lost
  152. 542 '
  153. 544 '
  154. 546 ' 25 beeps at rapid-fire rate then go RE-INDEX
  155. 600 REM    ----------------------------REKEY INDEX-------------------------------
  156. 602 ' re-FIELD to normal
  157. 604 '
  158. 606 ' null out the main (NAME) index
  159.  
  160. 608 ' get the record
  161. 610 ' HASH the key field (NAME) for index position
  162. 612 ' check that the position is unused
  163. 614 ' if it was deleted then mark it negative else positive
  164. 616 ' if it was in use, get the next one
  165. 618 ' put it away
  166. 620 ' next record until done, then do the CATEGORY INDEX
  167. 622 '
  168. 624 '
  169. 650 REM -----------REKEY CATEGORY INDEX----------
  170. 652 ' exactly the same procedure as for NAME INDEX
  171. 654 '
  172. 656 '
  173.  
  174. 658 '
  175. 660 '
  176. 662 '
  177. 664 '
  178. 666 '
  179. 668 '
  180. 670 '
  181. 700 REM    ----------------------INITIALISE NEW FILE-----------------------------
  182. 702 ' screen header
  183. 704 ' get company name for file header
  184.       but re-RUN if its an asterisk
  185. 706 ' get address
  186. 708 ' some redundant code here
  187. 710 '
  188. 712 '
  189. 714 '
  190. 716 '
  191. 718 ' get paper lngth
  192. 720 ' set maximum number of records for a single disk
  193.  
  194. 722 '
  195. 724 ' make sure its all OK
  196.  
  197. 726 ' but if not go get it all again
  198. 728 ' put it away if OK
  199.  
  200.  
  201. 730 '
  202. 732 '
  203. 734 '
  204. 736 '
  205. 738 '
  206. 740 ' and re-RUN from the start
  207. 798 REM =======================GENERAL SUB-ROUTINES===========================
  208. 800 REM -------------------------PROGRAM EXIT SCREEN--------------------------
  209. 802 ' this is where files are closed and program ends
  210. 900 REM ------------------------KEYBOARD INPUT OF KEY-------------------------
  211. 902 ' set up screen
  212. 904 ' get input and check for EXIT or ? or TOGGLE (@)
  213.  
  214. 906 ' if its a valid record number then get it
  215.  
  216. 908 ' if its a CTRL-key then go back to handle it
  217. 910 ' if its a name then get HASH and check if OK
  218. 912 ' get the indicated record & check
  219.  
  220. 914 ' check for match set p1=0 if not
  221. 916 ' and try again if no match, else skip if deleted
  222.  
  223. 918 ' back to display if a valid record
  224. 920 ' or to get new data if 'NOT FOUND'
  225. 922 '
  226. 924 ' move the record pointer if a movement is requested with CTRL-key
  227.  
  228.  
  229. 926 '
  230.  
  231. 928 ' make sure pointer is in range
  232. 930 ' get  the record
  233. 932 '
  234.  
  235. 934 '
  236. 936 '
  237. 938 ' update the category index
  238. 940 '
  239. 942 '
  240. 944 '
  241. 1000 REM -------------------------PRINT '?' LISTING---------------------------
  242. 1002 ' this routine responds if the operator command is '?'
  243. 1004 '
  244. 1006 '
  245. 1008 '
  246. 1100 REM -----------------------------HASHING ALGORITHM-----------------------
  247. 1102 ' calculate HASH number
  248. 1104 ' using ASCII values of all the letters in the name
  249. 1106 '
  250. 1108 ' make sure its big enough
  251. 1110 ' calculate position & get the number (its sort of random-ish!)
  252.  
  253. 1112 ' get it into range & return
  254. 1150 REM -------------------CATEGORY HASH-----------------
  255. 1152 ' same as above except for category
  256. 1154 '
  257. 1156 '
  258. 1158 '
  259. 1160 '
  260.  
  261. 1162 '
  262. 1200 REM -------------------------DATE CHECKING & CONVERSION-------------------
  263. 1202 ' accept any separator for date (in DD/MM/YY format)
  264.        and change back to '/'
  265. 1204 ' now check for DD/MM/YY or D/M/YY or DD/M/YY or D/MM/YY etc
  266.  
  267. 1206 '
  268. 1208 '
  269. 1210 ' if it ain't the right size after  all that then its an error!
  270. 1212 ' now check number of days in the month and handle if
  271.        in error
  272. 1214 '
  273.  
  274. 1216 ' set the error flag to 0 if no errors
  275. 1218 ' or to 1 if its wrong
  276. 1220 ' now compress the date to 4 characters for disk storage
  277.  
  278. 1222 '
  279. 1224 ' this bit DE-compresses the disk form into DD/MM/YY
  280.  
  281. 1226 '
  282.  
  283. 1228 '
  284. 1300 REM --------------------------SCREEN HEADER-----------------------------
  285. 1302 ' clear the screen & put the heading on
  286.  
  287. 1304 ' set the screen dump flag on the screen if set
  288.  
  289. 1306 ' and return
  290. 1400 REM -----------------------PRESS <RETURN> PROMPTS----------------------
  291. 1402 ' printing routine required
  292.  
  293. 1404 ' if it's labels, then see if only a count required
  294.  
  295. 1406 '
  296. 1408 ' some more printer prompts
  297. 1410 '
  298. 1412 '
  299. 1414 '
  300. 1416 '
  301. 1418 '
  302. 1420 ' screen set-up for 900 and 1800 routines
  303.  
  304. 1422 '
  305.  
  306. 1424 '
  307. 1500 REM -------------------DATA ENTRY WINDOWS-------------------------------
  308. 1502 ' set out the data-entry windows
  309.  
  310. 1504 '
  311. 1506 '
  312. 1508 '
  313. 1510 '
  314. 1512 '
  315. 1514 '
  316. 1516 ' put bottom lines on screen
  317. 1518 '
  318. 1600 REM -------------------FILL WINDOWS AFTER 'FIND'-------------------------
  319. 1602 ' fill the windows with the 'FOUND' record
  320.  
  321.  
  322. 1604 ' and print it if needed
  323. 1606 '
  324. 1700 REM -----------------------------ERROR TRAP------------------------------
  325. 1702 ' display error message
  326. 1704 '
  327. 1706 '
  328. 1800 REM -------------------------get record by category----------------------
  329. 1802 ' this routine is  the same
  330. 1804 ' as the one in the 900's
  331.  
  332.  
  333. 1806 '
  334. 1808 '
  335.  
  336. 1810 '
  337.  
  338. 1812 '
  339. 1814 '
  340. 1816 '
  341.  
  342. 1818 '
  343. 1820 '
  344.  
  345. 1822 '
  346.  
  347. 1824 '
  348. 1826 '
  349. 1900 REM ---------------------------IS THIS THE ONE ??-----------------------
  350. 1902 ' is this the one yoyu wanted???
  351.  
  352.  
  353. 1904 ' clear the line
  354. 1906 '
  355. 2000 REM ---------------------------ADJUST TOGGLE FOR KEY FIELD--------------
  356. 2002 IF TOGGLE IS 0 THEN GET NAME ELSE GET CATEGORY
  357. 2004 '
  358. 2100 REM ........................PRINT LABELS..................................
  359. 2102 ' get & check options
  360.  
  361.  
  362. 2104 ' and act on 'em
  363. 2106 ' this one is for printed address labels
  364. 2108 ' so do them
  365. 2110 ' but skip if deleted
  366. 2112 ' and skip if the CATEGORY doesn't match
  367. 2114 ' else print
  368. 2116 '
  369. 2118 '
  370. 2150 REM ----------------------COUNT FOR CATEGORY SELECTED------------------
  371. 2152 ' this option is for just counting
  372.  
  373. 2154 ' but otherwise its the same as printing
  374. 2156 '
  375. 2158 '
  376. 2160 '
  377. 2162 '
  378. 2164 ' display count
  379.  
  380. 2166 '
  381. 2168 ' and return
  382. 2200 REM .......................PRINT 'BOOK'...................................
  383. 2202 ' this is the address book - 20 addresses to the page
  384. 2204 ' print the heading
  385.  
  386. 2206 ' start the record count
  387. 2208 ' print them all if not deleted
  388. 2210 ' this method allows blanks in second column if not enough addresses
  389. 2212 '
  390. 2214 '
  391. 2216 '
  392. 2218 '
  393. 2220 '
  394. 2222 '
  395. 2224 '
  396. 2226 ' form feed
  397. 2300 REM .................DETERMINE STATE FROM POSTCODE........................
  398. 2302 ' AUST POST lays em out like this
  399.  
  400. 2304 '
  401.  
  402. 2306 '
  403. 2308 '
  404. 2310 '
  405. 2312 '
  406. 2314 '
  407. 2316 '
  408. 2318 '
  409. 2400 REM ....................CHECK CATEGORY FOR MATCH..........................
  410. 2402 ' the '~' is an anything character
  411.  
  412. 2404 '
  413. 2406 '
  414. 2408 '
  415.  
  416. 2410 '
  417.  
  418. 2412 '
  419. 2414 '
  420. 2416 '
  421. 2500 REM ....................GET CATEGORY FOR LABELS...........................
  422. 2502 ' get the category required...use '~' for 'don't care'
  423. 2504 '
  424. 2506 '
  425. 2508 ' check for valid characters
  426. 2510 '
  427. 2512 '
  428. 2600 REM ..........................GET SORT FIELD..............................
  429. 2602 ' which field to sort on???
  430.  
  431. 2604 ' check for valid field
  432. 2606 ' set the field positions
  433.  
  434.  
  435. 2608 '
  436. 2700 REM ......................PART OF CATEGORY CHECK..........................
  437. 2702 ' these check for special vaalues in the category fields
  438. 2704 ' for further details, see the README file
  439. 2706 '
  440. 2708 '
  441. 2710 '
  442. 2712 '
  443. 2714 '
  444. 2716 '
  445. 2718 '
  446. 2720 '
  447. 2722 '
  448. 2724 '
  449. 2726 '
  450. 2728 '
  451. 2730 '
  452. 2732 '
  453. 2800 REM ........................PRINT COPY OF WINDOW..........................
  454. 2802 ' this is the pseudo screen dump routine
  455. 2804 '
  456. 2806 '
  457. 2808 '
  458. ........PRINT COPY OF WINDOW..........................
  459. 2802 ' this is the pseudo screen dump routine
  460. 2804 '
  461. 2806 '
  462. 28