home *** CD-ROM | disk | FTP | other *** search
/ UpTime Volume 1 #3 / utv1n3s1.d64 / database (.txt) < prev    next >
Commodore BASIC  |  2022-08-28  |  6KB  |  231 lines

  1. 1 rem (c) 1987 uptime magazine
  2. 2 rem (c) 1987 softdisk publishing inc.
  3. 3 :
  4. 4 rem author: noel nyman
  5. 5 :
  6. 10 print chr$(142)chr$(8): clr: goto100
  7. 15 :
  8. 20 *****************************************
  9. 25 *          ram based database           *
  10. 30 *            by noel nyman              *
  11. 35 *                                       *
  12. 40 * the data for this database are all    *
  13. 45 * held in data statements, which are    *
  14. 50 * moved into array variables for fast   *
  15. 55 * searching and display.  new records   *
  16. 60 * are added using the "dynamic screen"  *
  17. 65 * technique.  the added data are saved  *
  18. 70 * with the program if the "q" option    *
  19. 75 * is selected at the main menu.         *
  20. 80 *****************************************
  21. 85 :
  22. 100 rem --- initialize variables ---
  23. 110 :
  24. 120 poke 1023, peek(646): rem store text color
  25. 130 :
  26. 140 rem --- don't change the next two line numbers! ---
  27. 150 z= 4
  28. 160 dd= 2240
  29. 170 :
  30. 180 poke 646, peek(1023): rem get the text color back
  31. 190 dim n$(z), a$(z), c$(z), p$(z), pt(z)
  32. 200 :
  33. 210 for x=1 to z
  34. 220 :   read n$(x), a$(x), c$(x), p$(x)
  35. 230 next
  36. 240 :
  37. 250 rem --- clear pointer array, main menu ---
  38. 260 :
  39. 270 for x=1 to z
  40. 280 :   pt(x)=0: rem points to records selected during match searches
  41. 290 next
  42. 300 :
  43. 305 print "[147]           dynamic database "
  44. 310 print"do you want to---
  45. 320 [153]"1)  print by record number
  46. 330 print"2)  search by name
  47. 340 [153]"3)  search by address
  48. 350 print"4)  search by phone
  49. 360 [153]"5)  add a name
  50. 370 print"6)  quit
  51. 380 [153]"f8) return to uptime
  52. 385 print "--published by softdisk publishing inc--";
  53. 390 :
  54. 400 rem --- get menu selection ---
  55. 410 :
  56. 420 get x$: if x$="" goto420
  57. 430 if x$="[140]" goto2100
  58. 440 x=val(x$)
  59. 450 if x<1 or x>6 goto420
  60. 460 :
  61. 470 on x goto510,670,870,980,1420,1090
  62. 480 :
  63. 490 rem --- search by record number ---
  64. 500 :
  65. 510 print"[147]enter record number to search for:"
  66. 520 gosub1360
  67. 530 x=val(n$)
  68. 540 if x<1 or x>z then print "record number not in use": gosub1300: goto270
  69. 550 gosub590: gosub1300: goto270
  70. 560 :
  71. 570 rem --- print record ---
  72. 580 :
  73. 590 print: print n$(x)
  74. 600 print a$(x)
  75. 610 print c$(x)
  76. 620 print p$(x)
  77. 630 return
  78. 640 :
  79. 650 rem --- search by name ---
  80. 660 :
  81. 670 print"[147]enter name to search for:"
  82. 680 gosub1360
  83. 690 w=0
  84. 700 for x=1 to z
  85. 710 :   if left$(n$(x),len(n$))=n$ then w=1: pt(x)=x
  86. 720 next
  87. 730 :
  88. 740 rem --- locate matched records ---
  89. 750 :
  90. 760 if w=0 then print "no match found": gosub1300: goto270
  91. 770 :
  92. 780 w=0
  93. 790 for y=1 to z
  94. 800 :   if pt(y)>0 then x=pt(y): gosub590: w=w+1
  95. 810 :   if w=4 then w=0: gosub1300: print"[147]";
  96. 820 next
  97. 830 gosub1300: goto270
  98. 840 :
  99. 850 rem --- search by address ---
  100. 860 :
  101. 870 print"[147]enter address to search for:"
  102. 880 gosub1360
  103. 890 w=0
  104. 900 for x=1 to z
  105. 910 :   if left$(a$(x),len(n$))=n$ then w=1: pt(x)=x
  106. 920 next
  107. 930 :
  108. 940 goto760
  109. 950 :
  110. 960 rem --- search by phone ---
  111. 970 :
  112. 980 print"[147]enter phone to search for:"
  113. 990 gosub1360
  114. 1000 w=0
  115. 1010 for x=1 to z
  116. 1020 :   if left$(p$(x),len(n$))=n$ then w=1: pt(x)=x
  117. 1030 next
  118. 1040 :
  119. 1050 goto760
  120. 1060 :
  121. 1070 rem --- save program to disk ---
  122. 1080 :
  123. 1090 print "[147]place program disk in drive--"
  124. 1100 gosub1300
  125. 1110 gosub2000: rem check for uptime disk
  126. 1120 if a=0 goto1240
  127. 1130 if a<>62 then print "[147]disk error"a;a$;t;s: gosub1300: goto270
  128. 1140 open15,8,15,"s0:database.old": rem scratch old version
  129. 1150 print#15,"r0:database.old=database": rem make current version old version
  130. 1160 close15
  131. 1170 :
  132. 1180 save "database",8
  133. 1190 :
  134. 1200 print chr$(9): goto 2100
  135. 1210 :
  136. 1220 rem --- uptime disk in drive ---
  137. 1230 :
  138. 1240 print"[147]     *** do not use uptime disk ***
  139. 1250 [153]" *** insert a blank formatted disk ***
  140. 1260 gosub1300: goto270
  141. 1270 :
  142. 1280 rem --- press any key prompt ---
  143. 1290 :
  144. 1300 print"    --- press any key to continue ---"
  145. 1310 get x$: if x$="" goto1310
  146. 1320 return
  147. 1330 :
  148. 1340 rem --- input without "?" ---
  149. 1350 :
  150. 1360 open 9,0: input#9,n$: close 9
  151. 1370 print "[147]";
  152. 1380 return
  153. 1390 :
  154. 1400 rem --- new record ---
  155. 1410 :
  156. 1420 open 9,0
  157. 1430 print "[147]enter new name:"
  158. 1440 input#9,nn$
  159. 1450 print: print "enter new address:"
  160. 1460 input#9,aa$
  161. 1470 print: print "enter new city/state/zip:"
  162. 1480 input#9,cc$
  163. 1490 print: print "enter new phone:"
  164. 1500 input#9,pp$
  165. 1510 close9
  166. 1520 z=z+1: dd=dd + 10
  167. 1530 x=peek(53281) and 15
  168. 1540 :
  169. 1550 print "[147]             saving new data"
  170. 1560 :
  171. 1570 rem to make the dynamic screen technique invisible to the user, we change
  172. 1580 rem the text color to screen background color.  we need to save the text
  173. 1590 rem color so we can change back when we re-run the program.  a program
  174. 1600 rem variable won't do, because they are all reset with the "run" command.
  175. 1610 rem so, we poke it to location 1023 which is just beyond the screen memory
  176. 1620 rem line #180 in the main program gets it back.st beyond the screen memory
  177. 1630 rem so you can see the process, we've used a "rem" in line #1670.
  178. 1640 rem when you've seen how it works, remove the word "rem" and the dynamic
  179. 1650 rem screen will be invisible.
  180. 1660 :
  181. 1670 print "";: rem poke 1023,peek(646): poke 646,x
  182. 1680 :
  183. 1690 rem next we print a new line #150 on the screen. when the program is re-run
  184. 1700 rem the variable "z" will be set to the new number of records.
  185. 1710 :
  186. 1720 print "150 z=";z
  187. 1730 :
  188. 1740 rem next we print a new line #160, which holds the line number of the
  189. 1750 rem new data statement.
  190. 1760 :
  191. 1770 print "160 dd="; dd
  192. 1780 :
  193. 1790 rem now the new data statement
  194. 1800 :
  195. 1810 print dd;"data ";nn$;",";aa$;",";cc$;",";pp$
  196. 1820 :
  197. 1830 rem last, the command that re-runs the program starting at line #150
  198. 1840 :
  199. 1850 print "run 150": print ""
  200. 1860 :
  201. 1870 rem now we poke four "return's" into the keyboard buffer
  202. 1880 :
  203. 1890 poke 631,13: poke 632,13: poke 633, 13: poke 634, 13
  204. 1900 :
  205. 1910 rem and poke 4 to the index counter for the 4 "return" codes in the buffer
  206. 1920 :
  207. 1930 poke 198,4
  208. 1940 :
  209. 1950 rem the four returns add the lines and re-run the program just as if the
  210. 1960 rem user had typed the commands in direct mode.
  211. 1970 :
  212. 1980 end
  213. 1990 :
  214. 2000 rem --- check for uptime disk ---
  215. 2010 :
  216. 2020 close15: open15,8,15
  217. 2030 open2,8,2,"0:uptime,p,r"
  218. 2040 input#15,a,a$,t,s
  219. 2050 close2:close15
  220. 2060 return
  221. 2070 :
  222. 2080 rem --- return to uptime ---
  223. 2090 :
  224. 2100 poke 186,8
  225. 2110 sys (8*4096)+4
  226. 2120 :
  227. 2200 data uptime,po box 30008,shreveport la  71130-0008,318 221-5134
  228. 2220 data noel nyman,po box 58587,seattle wa  98188,
  229. 2230 data commodore,1200 wilson drive,west chester pa  19380,
  230. 2240 data compuserve,5000 arlington centre blvd,columbus oh  43220, 800 848-8990
  231.