home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1991 January
/
1991-01.d64
/
diredit
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
91 lines
10 rem diredit 260390
20 print "[147]renames files f001, f002 ... etc.":print
30 dim type$(6)
40 data "del","seq","prg","usr","rel","cbm"
50 for i=0 to 5:read type$(i):next
60 input"which drive device # (eg 8 or 9)";u
70 open15,u,15,"i0":input#15,a,b$,c,d:close15:if a= 0 then goto100
80 :print"problem with disk":print a;b$;c;d:print"please check disk and drive"
90 :stop
100 print:print"(1) 1541":print"(2) 1571":print"(3) 1581"
110 input"which drive type (1/2/3)";dm
120 if dm<1 or dm>3 then goto100
130 if dm=1 then d$="1541":dtrk=18:dsct=1
140 if dm=2 then d$="1571":dtrk=18:dsct=1
150 if dm=3 then d$="1581":dtrk=40:dsct=3
160 print:print"edit directory of ";d$;"[146] drive."
170 print"directory starts on track ";dtrk
180 print"at sector ";dsct:print
190 input"is this correct (y/n)";y$
200 if y$<>"y" then print "abort program": stop
210 if d$="1571" then open15,u,15,"u0>m1":close15
220 print:print"enter range of file numbers to examine:":print
230 input"first file number";i1
240 input"last file number";i2
250 print:print"press <return> to leave directory entry unchanged.":print
260 for i=i1 to i2
270 :gosub490 :f$="f"+t$ :rem f$ is the existing file name
280 :print"---------------------------":print "";f$;"[146]";:gosub530
290 :n$="":input"> new file name:";n$
300 :if n$="" then goto380 :rem skip this file
310 : rem now rename the file
320 : open15,u,15,"r0:"+n$+"="+dname$
330 : print "r0:";n$;"=";dname$
340 : rem check the disk error status
350 : input#15,a,b$,c,d:print a;b$;c;d
360 : close15
370 : if a<>0 goto280: rem error, so try again this file
380 :t$="":input"new type (del,seq,prg,usr,rel,cbm)";t$
390 :if t$="" then goto450 : rem skip
400 : rem now change file type
410 : tn=999:for tl=0 to 5:if t$=type$(tl) then tn=128+tl:goto430
420 : next tl
430 : if tn<128 or tn>133 then goto380 : rem file type not recognised
440 : gosub790 : rem set type
450 next i
460 end
470 rem ::::::::::::::::::::::::::::::
480 rem subroutine
490 rem to create a string number with leading zeros: converts i to t$, 3 chars
500 s$=str$(i):l=len(s$)
510 t$=left$("0000",4-l)+right$(s$,l-1)
520 return
530 rem :::::::::::::::::::::::::::::
540 rem subroutine to convert file # into track, sector and byte address
550 track=dtrk:sect=int((i-1)/8)+dsct:byte=(i-8*int((i-1)/8)-1)*32+2
560 rem print track;sect;byte
570 open15,u,15:input#15,a,b$,c,d:if a<>0 then close15:printa;b$;c;d:stop
580 open5,u,5,"#"
590 print#15,"u1";5;0;track;sect
600 print#15,"b-p";5;byte
610 get#5,tn$:type=0:if tn$<>"" then type=asc(tn$)
620 if type=0 then ty$="none"
630 tp=(type and 63)
640 if tp>=0 and tp<=5 then ty$=type$(tp)
650 get#5,tn$:get#5,tn$:rem this gets us to the file name
660 dname$="":nb=3
670 for jj=3 to 18:
680 get#5,tn$:nb=nb+1:if tn$=chr$(160) then goto720
690 dname$=dname$+tn$
700 next
710 if dname$="" then goto770
720 print": <";dname$;"[146]> on disk"
730 for ib=nb to 28:get#5,tn$:next
740 lb=asc(tn$+chr$(0)):get#5,tn$:hb=asc(tn$+chr$(0))
750 blocks=256*hb+lb
760 print blocks;"blocks: type=";ty$;"[146]"
770 close 5:close15
780 return
790 rem ::::::::::::::::::::::::::::::
800 rem subroutine to set file type in directory, given track,sect,byte,tn
810 open15,u,15
820 input#15,a,b$,c,d:if a<>0 then print a;b$;c;d:close15 stop
830 open5,u,5,"#"
840 print#15,"u1";5;0;track,sect
850 print#15,"b-p";5;byte
860 print#5,chr$(tn);:rem write the new type into the disk buffer
870 print#15,"u2";5;0;track,sect
880 close5
890 close15
900 return