home *** CD-ROM | disk | FTP | other *** search
- 1 poke53280,14:poke53281,6:poke646,14
- 5 dimda$(100,2)
- 6 forl=1 to 100:da$(l,2)="0":da$(l,0)="":next
- 8 fr=31
- 10 rem *******************************
- 20 rem * an example of hash tables *
- 30 rem * *
- 40 rem * written by steven p burgess *
- 50 rem * *
- 60 rem * copyright 1989 *
- 70 rem *******************************
- 80 rem
- 90 rem
- 95 gosub5000
- 100 printchr$(147);
- 110 print"[176][192][192][192][192][174]"
- 120 print"[221]menu[221]"
- 130 print"[173][192][192][192][192][189]"
- 140 print"1..add records"
- 150 print"2..search for record"
- 160 print"3..delete record"
- 170 print"4..end program"
- 180 geta$:ifa$=""then180
- 190 if a$<"1" or a$>"4"then180
- 200 if a$="1"then gosub1000
- 210 if a$="2"then gosub2000
- 220 if a$="3"then gosub3000
- 230 if a$="4"then printchr$(147):end
- 250 goto 100
- 260 rem***************
- 270 rem*hash function*
- 280 rem***************
- 290 h=0:t=0:fore=1 to len(a$):t=t+asc(mid$(a$,e,1))
- 300 next
- 310 t=t/len(a$)
- 320 h=int(abs(sin(t))*29)+1
- 330 h=int(h)
- 340 return
- 350 rem***************
- 360 rem*add procedure*
- 370 rem***************
- 380 ins=0:if da$(h,0)=""then da$(h,0)=a$:da$(h,1)=b$:return
- 390 ifda$(h,2)="0"then da$(h,2)=str$(fr):da$(fr,0)=a$:da$(fr,1)=b$:ins=1:fr=fr+1
- 400 if ins<>1 then h=val(da$(h,2)):goto 380
- 410 return
- 1000 rem*************
- 1010 rem*add records*
- 1020 rem*************
- 1030 printchr$(147);
- 1040 print"add records"
- 1050 print"";:input"enter country";a$
- 1060 print"";:input"enter capital";b$
- 1070 gosub260:gosub350
- 1080 return
- 2000 rem*************
- 2010 rem*search for record*
- 2020 rem*******************
- 2021 fi=0
- 2025 if di$<>"delete"then di$="search for"
- 2030 printchr$(147);
- 2040 printdi$+" record"
- 2050 print"";:input"enter country";a$
- 2060 gosub260
- 2070 if da$(h,0)=a$ then f=1
- 2080 if f=0 then h=val(da$(h,2))
- 2090 if h<>0 and f<>1 then 2070
- 2100 ifh=0andf=0 then print"[147]sorry but the country you entered is not present"
- 2105 if h=0 and f=0 then print"press any key to return to the menu"
- 2106 if h=0 and f=0 then geta$:ifa$=""then2106
- 2107 if h=0 and f=0 then return
- 2110 print"[147]";
- 2120 print"country:";da$(h,0)
- 2130 print"capital:";da$(h,1)
- 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]"
- 2150 print"is this the record you require"
- 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]"
- 2170 getr$:ifr$=""then2170
- 2180 if r$="n"thenh=val(da$(h,2)):f=0:goto 2070
- 2190 print"[145][145]press any key to return "
- 2200 geta$:ifa$=""then 2200
- 2205 if di$<>"delete"then h=0:f=0
- 2210 return
- 3000 rem***************
- 3010 rem*delete record*
- 3020 rem***************
- 3025 di$="delete"
- 3030 print"[147]";
- 3040 print"delete record"
- 3050 gosub2000
- 3080 if h=0 and f=0 then return
- 3090 da$(h,0)="":da$(h,1)=""
- 3095 di$=""
- 3096 h=0:f=0
- 3100 return
- 5000 forl=1 to 5:reada$,b$
- 5010 gosub260
- 5020 gosub350
- 5030 next
- 5036 return
- 5040 datafrance,paris,england,london,russia,moscow,austrailia,canberra,ethiopia
- 5050 dataaddis ababa
-