home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1991 January / 1991-01.d64 / diredit (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  91 lines

  1. 10 rem         diredit            260390
  2. 20 print "[147]renames files f001, f002 ... etc.":print
  3. 30 dim type$(6)
  4. 40 data "del","seq","prg","usr","rel","cbm"
  5. 50 for i=0 to 5:read type$(i):next
  6. 60 input"which drive device # (eg 8 or 9)";u
  7. 70 open15,u,15,"i0":input#15,a,b$,c,d:close15:if a= 0 then goto100
  8. 80 :print"problem with disk":print a;b$;c;d:print"please check disk and drive"
  9. 90 :stop
  10. 100 print:print"(1)  1541":print"(2)  1571":print"(3)  1581"
  11. 110 input"which drive type  (1/2/3)";dm
  12. 120 if dm<1 or dm>3 then goto100
  13. 130 if dm=1 then d$="1541":dtrk=18:dsct=1
  14. 140 if dm=2 then d$="1571":dtrk=18:dsct=1
  15. 150 if dm=3 then d$="1581":dtrk=40:dsct=3
  16. 160 print:print"edit directory of ";d$;"[146] drive."
  17. 170 print"directory starts on track ";dtrk
  18. 180 print"at sector ";dsct:print
  19. 190 input"is this correct (y/n)";y$
  20. 200 if y$<>"y" then print "abort program":     stop
  21. 210 if d$="1571" then open15,u,15,"u0>m1":close15
  22. 220 print:print"enter range of file numbers to examine:":print
  23. 230 input"first file number";i1
  24. 240 input"last file number";i2
  25. 250 print:print"press <return> to leave directory entry unchanged.":print
  26. 260 for i=i1 to i2
  27. 270 :gosub490 :f$="f"+t$  :rem f$ is the existing file name
  28. 280 :print"---------------------------":print "";f$;"[146]";:gosub530
  29. 290 :n$="":input"> new file name:";n$
  30. 300 :if n$="" then goto380  :rem skip this file
  31. 310 : rem now rename the file
  32. 320 : open15,u,15,"r0:"+n$+"="+dname$
  33. 330 : print "r0:";n$;"=";dname$
  34. 340 : rem check the disk error status
  35. 350 : input#15,a,b$,c,d:print a;b$;c;d
  36. 360 : close15
  37. 370 : if a<>0 goto280:                         rem error, so try again this file
  38. 380 :t$="":input"new type (del,seq,prg,usr,rel,cbm)";t$
  39. 390 :if t$="" then goto450 :   rem skip
  40. 400 :        rem now change file type
  41. 410 : tn=999:for tl=0 to 5:if t$=type$(tl) then tn=128+tl:goto430 
  42. 420 : next tl
  43. 430 : if tn<128 or tn>133 then goto380 :           rem file type not recognised
  44. 440 : gosub790 :          rem set type
  45. 450 next i
  46. 460 end
  47. 470 rem ::::::::::::::::::::::::::::::
  48. 480 rem subroutine
  49. 490 rem to create a string number with leading zeros: converts i to t$, 3 chars
  50. 500 s$=str$(i):l=len(s$)
  51. 510 t$=left$("0000",4-l)+right$(s$,l-1)
  52. 520 return
  53. 530 rem :::::::::::::::::::::::::::::
  54. 540 rem subroutine to convert file # into track, sector and byte address
  55. 550 track=dtrk:sect=int((i-1)/8)+dsct:byte=(i-8*int((i-1)/8)-1)*32+2
  56. 560 rem print track;sect;byte
  57. 570 open15,u,15:input#15,a,b$,c,d:if a<>0 then close15:printa;b$;c;d:stop
  58. 580 open5,u,5,"#"
  59. 590 print#15,"u1";5;0;track;sect
  60. 600 print#15,"b-p";5;byte
  61. 610 get#5,tn$:type=0:if tn$<>"" then type=asc(tn$)
  62. 620 if type=0 then ty$="none"
  63. 630 tp=(type and 63)
  64. 640 if tp>=0 and tp<=5 then ty$=type$(tp)
  65. 650 get#5,tn$:get#5,tn$:rem this gets us to the file name
  66. 660 dname$="":nb=3
  67. 670 for jj=3 to 18:
  68. 680 get#5,tn$:nb=nb+1:if tn$=chr$(160) then goto720
  69. 690 dname$=dname$+tn$
  70. 700 next
  71. 710 if dname$="" then goto770 
  72. 720 print":      <";dname$;"[146]> on disk"
  73. 730 for ib=nb to 28:get#5,tn$:next
  74. 740 lb=asc(tn$+chr$(0)):get#5,tn$:hb=asc(tn$+chr$(0))
  75. 750 blocks=256*hb+lb
  76. 760 print blocks;"blocks:    type=";ty$;"[146]"
  77. 770 close 5:close15
  78. 780 return
  79. 790 rem ::::::::::::::::::::::::::::::
  80. 800 rem subroutine to set file type in directory, given track,sect,byte,tn
  81. 810 open15,u,15
  82. 820 input#15,a,b$,c,d:if a<>0 then print a;b$;c;d:close15 stop
  83. 830 open5,u,5,"#"
  84. 840 print#15,"u1";5;0;track,sect
  85. 850 print#15,"b-p";5;byte
  86. 860 print#5,chr$(tn);:rem write the new type into the disk buffer
  87. 870 print#15,"u2";5;0;track,sect
  88. 880 close5
  89. 890 close15
  90. 900 return
  91.