home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disk User Volume 3 #4 / Commodore_Disk_User_Vol.3_4_1990_-.d64 / capitals (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  2KB  |  102 lines

  1. 1 poke53280,14:poke53281,6:poke646,14
  2. 5 dimda$(100,2)
  3. 6 forl=1 to 100:da$(l,2)="0":da$(l,0)="":next
  4. 8 fr=31
  5. 10 rem *******************************
  6. 20 rem *  an example of hash tables  *
  7. 30 rem *                             *
  8. 40 rem * written by steven p burgess *
  9. 50 rem *                             *
  10. 60 rem *       copyright 1989        *
  11. 70 rem *******************************
  12. 80 rem
  13. 90 rem
  14. 95 gosub5000
  15. 100 printchr$(147);
  16. 110 print"[176][192][192][192][192][174]"
  17. 120 print"[221]menu[221]"
  18. 130 print"[173][192][192][192][192][189]"
  19. 140 print"1..add records"
  20. 150 print"2..search for record"
  21. 160 print"3..delete record"
  22. 170 print"4..end program"
  23. 180 geta$:ifa$=""then180
  24. 190 if a$<"1" or a$>"4"then180
  25. 200 if a$="1"then gosub1000
  26. 210 if a$="2"then gosub2000
  27. 220 if a$="3"then gosub3000
  28. 230 if a$="4"then printchr$(147):end
  29. 250 goto 100
  30. 260 rem***************
  31. 270 rem*hash function*
  32. 280 rem***************
  33. 290 h=0:t=0:fore=1 to len(a$):t=t+asc(mid$(a$,e,1))
  34. 300 next
  35. 310 t=t/len(a$)
  36. 320 h=int(abs(sin(t))*29)+1
  37. 330 h=int(h)
  38. 340 return
  39. 350 rem***************
  40. 360 rem*add procedure*
  41. 370 rem***************
  42. 380 ins=0:if da$(h,0)=""then da$(h,0)=a$:da$(h,1)=b$:return
  43. 390 ifda$(h,2)="0"then da$(h,2)=str$(fr):da$(fr,0)=a$:da$(fr,1)=b$:ins=1:fr=fr+1
  44. 400 if ins<>1 then h=val(da$(h,2)):goto 380
  45. 410 return
  46. 1000 rem*************
  47. 1010 rem*add records*
  48. 1020 rem*************
  49. 1030 printchr$(147);
  50. 1040 print"add records"
  51. 1050 print"";:input"enter country";a$
  52. 1060 print"";:input"enter capital";b$
  53. 1070 gosub260:gosub350
  54. 1080 return
  55. 2000 rem*************
  56. 2010 rem*search for record*
  57. 2020 rem*******************
  58. 2021 fi=0
  59. 2025 if di$<>"delete"then di$="search for"
  60. 2030 printchr$(147);
  61. 2040 printdi$+" record"
  62. 2050 print"";:input"enter country";a$
  63. 2060 gosub260
  64. 2070 if da$(h,0)=a$ then f=1
  65. 2080 if f=0 then h=val(da$(h,2))
  66. 2090 if h<>0 and f<>1 then 2070
  67. 2100 ifh=0andf=0 then print"[147]sorry but the country you entered is not present"
  68. 2105 if h=0 and f=0 then print"press any key to return to the menu"
  69. 2106 if h=0 and f=0 then geta$:ifa$=""then2106
  70. 2107 if h=0 and f=0 then return
  71. 2110 print"[147]";
  72. 2120 print"country:";da$(h,0)
  73. 2130 print"capital:";da$(h,1)
  74. 2140 print"[192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192]"
  75. 2150 print"is this the record you require"
  76. 2160 print"[192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192]"
  77. 2170 getr$:ifr$=""then2170
  78. 2180 if r$="n"thenh=val(da$(h,2)):f=0:goto 2070
  79. 2190 print"[145][145]press any key to return            "
  80. 2200 geta$:ifa$=""then 2200
  81. 2205 if di$<>"delete"then h=0:f=0
  82. 2210 return
  83. 3000 rem***************
  84. 3010 rem*delete record*
  85. 3020 rem***************
  86. 3025 di$="delete"
  87. 3030 print"[147]";
  88. 3040 print"delete record"
  89. 3050 gosub2000
  90. 3080 if h=0 and f=0 then return
  91. 3090 da$(h,0)="":da$(h,1)=""
  92. 3095 di$=""
  93. 3096 h=0:f=0
  94. 3100 return
  95. 5000 forl=1 to 5:reada$,b$
  96. 5010 gosub260
  97. 5020 gosub350
  98. 5030 next
  99. 5036 return
  100. 5040 datafrance,paris,england,london,russia,moscow,austrailia,canberra,ethiopia
  101. 5050 dataaddis ababa
  102.