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

  1. 10 rem     lincatc                260390
  2. 20 print"[147]program  lincatc":print
  3. 30 dim f$(400),t(400),s(400),nb(400)
  4. 40 input "which disk drive number (8/9/10/11)";u
  5. 50 open15,u,15
  6. 60 print"put the work disk with the filelist[146] data into drive #";u;"."
  7. 70 input"ok to proceed (y/n)";z$
  8. 80 if z$<>"y" then close15:stop
  9. 90 open1,u,2,"filelist,s,r"
  10. 100 input#15,a,b$,c,d:print a;b$;c;d
  11. 110 if a<>0 then print"'filelist' not found. abort.":close1:close15:stop
  12. 120 d$="":for i=1 to 4:get#1,e$:d$=d$+e$:next i
  13. 130 print"filelist[146]  drive type ";d$;"[146]"
  14. 140 if d$="1541" or d$="1571" then dtrk=18:dsct=1:   goto170 
  15. 150 if d$="1581" then dtrk=40:dsct=3   :goto170 
  16. 160 print"drive type not recognised. aborting.":close1:close15:stop
  17. 170 print"directory track is";dtrk
  18. 180 print"starting sector is";dsct
  19. 190 nf=0
  20. 200 print"filename,track,sector,size:"
  21. 210 input#1,a$,b,c,d
  22. 220 print a$;b;c;d
  23. 230 nf=nf+1
  24. 240 f$(nf)=a$:t(nf)=b:s(nf)=c:nb(nf)=d
  25. 250 rem set file name, track & sector start, block size.
  26. 260 if a$<>"end" goto210
  27. 270 nf=nf-1
  28. 280 close1
  29. 290 print"found ";nf;"directory file entries."
  30. 300 rem now write the directory out to the directory track
  31. 310 print:print"change disk[146]: put corrupted disk in drive"
  32. 320 input"ok to proceed (y/n)";z$
  33. 330 if z$<>"y" then close15:stop
  34. 340 print"about to overwrite the entire directory":print"track #";dtrk;"."
  35. 350 input"shall i continue (y/n)";z$
  36. 360 if z$<>"y" then close15:stop
  37. 370 print#15,"i0":rem init drive:nb must    have disk header and id already set
  38. 380 if d$="1571" then print#15,"u0>m1":rem make sure in 1571 mode, if need be.
  39. 390 t1=dtrk:s1=dsct:rem starting track,sector       for the directory rewrite
  40. 400 sp$=chr$(160):fori=1to11:sp$=sp$+chr$(160):next i
  41. 410 z$=chr$(0)
  42. 420 for i=1 to nf step 8
  43. 430 :open4,u,4,"#"
  44. 440 :print#15,"b-p";4;0 :rem set pointer      in 1541/1571/1581 buffer area
  45. 450 :if (i+7)<nf then print#4,chr$(t1);chr$(s1+1);      :rem normal dir. block
  46. 460 :if (i+7)>=nf then print#4,chr$(0);chr$(255);      :rem last directory block
  47. 470 :print "t/s: ";i;t1;s1+1;"[146]"
  48. 480 :rem link to next sector
  49. 490 :for k=0 to 7
  50. 500 : ff=i+k:if ff>nf then for l=1to(8-k)*32-2:print#4,z$;:nextl:goto620 
  51. 510 : print#4,chr$(130);:rem assume type                         pgm file
  52. 520 : print#4,chr$(t(ff));chr$(s(ff));
  53. 530 :  fi$=left$(f$(ff),4)+sp$
  54. 540 : print#4,fi$;
  55. 550 : for z=1to9:print#4,z$;:next z
  56. 560 :  b2=int(nb(ff)/256):b1=nb(ff)-256*b2
  57. 570 : print#4,chr$(b1);chr$(b2);
  58. 580 : if k<7 then print#4,z$;z$;
  59. 590 :  print ff;t(ff);s(ff);"<";fi$;">"
  60. 600 :  print b1;b2
  61. 610 : next k
  62. 620 :print#15,"u2";4;0;t1;s1
  63. 630 :input#15,a,b$,c,d:if a=0 then goto670 
  64. 640 : print: printa;b$;c;d:print"problem writing to disk. please check"
  65. 650 : print"correct disk is in drive, write enabled"
  66. 660 : print"aborting program.":close4:close15:stop
  67. 670 :s1=s1+1:rem set for next sector
  68. 680 :close4
  69. 690 next i
  70. 700 close15
  71. 710 print:print"directory written. end of lincatc."
  72. 720 print"now check directory, identify files and"
  73. 730 print"rename where necessary."
  74.