home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1985 June / 1985-06.d64 / relative (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  84 lines

  1. 0 rem create relative file
  2. 1 sys65517:ifpeek(781)=40thenmt$="":goto3
  3. 2 mt$=""
  4. 3 printmt$"[147] this disk is write":print" protected[146]. please"
  5. 4 print" insert a different":print" disk to save the"
  6. 5 print" files created with"
  7. 6 print" this program.":print" press any key to":print"     continue"
  8. 9 wait198,1:poke198,0
  9. 10 printmt$"[147]length of record":input rl:rl=rl+1
  10. 20 print"total number of":input"records";rn:rn=rn+1
  11. 30 hb=int(rn/256)
  12. 40 lb=rn-hb*256
  13. 50 open15,8,15
  14. 60 open1,8,2,"rel.file,l,"+chr$(rl)
  15. 70 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(1)
  16. 80 print#1,"end"
  17. 90 close1
  18. 95 input#15,e,e$:print"disk status:":printe$:close15
  19. 99 rem prepare to write file
  20. 100 rc=rc+1
  21. 110 rc$=""
  22. 120 sp$="                              "
  23. 130 print"first name":inputnf$
  24. 140 print"middle name":inputmn$
  25. 150 print"last name":inputln$
  26. 160 print"street address":inputsa$
  27. 170 print"city":inputci$
  28. 180 print"state":inputst$
  29. 190 print"zip code":inputzi$
  30. 200 print"phone number":inputph$
  31. 210 rc$=rc$+left$(nf$+sp$,15)
  32. 220 rc$=rc$+left$(mn$+sp$,15)
  33. 230 rc$=rc$+left$(ln$+sp$,15)
  34. 240 rc$=rc$+left$(sa$+sp$,30)
  35. 250 rc$=rc$+left$(ci$+sp$,25)
  36. 260 rc$=rc$+left$(st$+sp$,3)
  37. 270 rc$=rc$+left$(zi$+sp$,5)
  38. 280 rc$=rc$+left$(ph$+sp$,12)
  39. 299 rem write to file
  40. 300 open15,8,15
  41. 310 open1,8,2,"rel.file"
  42. 320 hb=int(rc/256)
  43. 330 lb=rc-hb*256
  44. 340 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(1)
  45. 350 print#1,rc$
  46. 360 close1
  47. 370 input#15,e,e$:print"disk status:":printe$:close15
  48. 380 print:print"another entry?"
  49. 390 getg$:ifg$=""then390
  50. 400 ifg$="n"then500
  51. 410 ifg$="y"then100
  52. 420 goto390
  53. 499 rem read relative file in order
  54. 500 fora=1torc:rc$="":print"record #";a
  55. 510 open15,8,15
  56. 520 open1,8,2,"rel.file"
  57. 530 hb=int(a/256)
  58. 540 lb=a-hb*256
  59. 550 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(1)
  60. 560 forb=1to120:get#1,a$:rc$=rc$+a$:next
  61. 570 close1:close15
  62. 580 printmid$(rc$,1,15)
  63. 590 printmid$(rc$,16,15)
  64. 600 printmid$(rc$,31,15)
  65. 610 printmid$(rc$,46,30)
  66. 620 printmid$(rc$,76,25)
  67. 630 printmid$(rc$,101,3)
  68. 640 printmid$(rc$,104,5)
  69. 650 printmid$(rc$,109,12)
  70. 660 next
  71. 699 rem read individual record
  72. 700 print"record # to read":inputre
  73. 710 print"starting at position":inputpo
  74. 720 hb=int(re/256):lb=re-hb*256
  75. 730 open15,8,15
  76. 740 open1,8,2,"rel.file"
  77. 750 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(po)
  78. 760 fora=poto120:get#1,a$:printa$;:next
  79. 770 input#15,e,e$:print"disk status:":printe$
  80. 780 close1:close15
  81. 790 print"press any key to continue"
  82. 800 getg$:ifg$=""then800
  83. 810 goto700
  84.