home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
demodisks
/
drives
/
1581-demo.lzh
/
filecopy
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
1994-10-19
|
4KB
|
111 lines
11 f$="filecopy.bin":u=8
13 gosub9100:gosub9050
14 if f=0 then load f$,u,1:goto25
20 (NULL)1,1
21 (NULL)(f$),p(ba)onu(u):if(NULL)(0)<5then(NULL)0
25 gosub9000
40 input "[155]your source disk unit[146] 8[157][157][157]";su
50 input "[155]destination disk unit[146] 9[157][157][157]";du:print
60 : if su<4 or su>31 or du<4 or du>31 or su=du then 10
70 print "[155] enter template or <return> [146] ";:m$="":inputm$
72 w=0:ww=0:for i=1tolen(m$):if "*"=mid$(m$,i,1) then w=i:ww=ww+1
73 next: if ww>1 then print"[155]bad template": goto 120
74 w$=right$(m$,len(m$)-w)
80 dim n$(200),t$(200),ce(200):q$=chr$(34):e$=","
90 open14,su,15,"i": sc=14:u=sc: gosub8000: ifs then print"[155]"su":";s$: goto120
95 open15,du,15,"i": dc=15:u=dc: gosub8000: if s then print""du":";s$: goto120
100 gosub 9000: gosub 1000: gosub 2000
110 if k then gosub 9000: gosub 3000
120 print:print" more (y/n) ? [146] ";:gosub4000: if a$="n" then clr: end
130 clr:gosub9100:goto25
1000 rem read directory into n$,t$: n=num files+1
1010 print "[155]reading directory.";
1020 n=0: f$="$": if len(m$)<>0 then f$="$:"+m$
1030 open 8,su,0,f$: u=sc: gosub8000
1035 : if s then print: print"";s$: close8: return
1040 get#8,a$,b$
1050 : get#8,a$,a$,a$,a$ :print ".";
1060 : get#8,a$: if len(a$)=0 or st then 1130
1065 : if asc(a$)=0 then 1130
1070 : if a$<>q$ then 1060
1080 : get#8,a$: if a$<>q$ and st=0 then n$(n)=n$(n)+a$: goto 1080
1090 : get#8,a$: if a$=" " then 1090
1100 : t$(n)=t$(n)+a$: get#8,a$: if a$<>" " and st=0 then 1100
1110 : get#8,a$:a$=a$+chr$(0):if asc(a$)<>0 and st=0 then 1110
1116 : if n=0 or w=0 then 1120
1117 : if len(n$(n)) < (w-1+len(w$)) then n$(n)="":t$(n)="": goto 1050
1119 : if w$<>right$(n$(n), len(w$)) then n$(n)="":t$(n)="":goto1050
1120 : n=n+1: goto1050
1130 print:close 8: gosub8000: if s then print"...";s$
1140 print:print n-1;"files targeted" :print : return
2000 rem display files & ask user which ones to copy
2010 k=0: if n<2 then print" no files found.":return
2020 for i=1ton-1:ce(i)=0
2030 : print q$;n$(i);q$;tab(19);t$(i);tab(25);: if m$<>"*" then 2070
2040 : print:ce(i)=1: k=k+1: next: print
2050 print " continue (y/n) ? [146] ";: gosub4000 :if a$="y" then return
2060 k=0: return
2070 print "copy ? (y/n) ";:gosub4000 :if a$="y" then ce(i)=1: k=k+1
2080 : next: return
3000 rem copy the files
3010 for i=1ton-1:if ce(i)=0 then next: return
3020 :t$(i) = left$(t$(i),1): f$=q$+n$(i)+q$
3030 open9,du,9,n$(i): u=dc: gosub8000: close9
3040 : if s=62 then 3100
3050 : print f$;" exists, replace? ";: gosub4000:gosub 4500
3060 : if a$="n" then print f$;" not copied":next:return
3070 : print "scratching old ";f$
3080 : print#15,"s0:";n$(i): gosub8000:gosub 4500:if s>1 then 3170
3090 : goto 3030
3100 : if t$(i)="r" then gosub 5000:goto 3170:rem copy rel files
3110 : print "now copying ";f$
3120 : open9,du,1,n$(i)+","+t$(i)+",w": u=dc: gosub8000 : if s then 3170
3140 : open8,su,0,n$(i)+","+t$(i)+",r": u=sc: gosub8000 : if s then 3170
3160 : sys ba: close 8: close 9:u=dc:gosub 8000
3170 : if s then print "copy failed: [146]";s$ : goto 3180
3175 : u=sc:gosub 8000
3176 : if s then print "copy failed: [146]";s$
3180 next: return
4000 get a$: if a$<>"y" and a$<>"n" then 4000
4010 printa$: return
4500 print "[145] "+chr$(13)+"[145]";:return
5000 rem copy rel files.
5010 print "scanning ";f$
5020 open8,su,8,n$(i): u=sc: gosub 8000: if s then return
5030 l=0:for rn=7to0step-1:rg=2^rn: rem scan for reclen
5040 : r=1:l=l+rg:gosub 6000:if s then l=l-rg
5050 : next
5060 r=0:forrn=15to0step-1:rg=2^rn: rem scan for numrec
5070 : r=r+rg: gosub 6000: if s then r=r-rg
5080 : next
5100 gosub 4500:print "creating ";f$
5110 open9,du,9,n$(i)+",l,"+chr$(l)
5120 : u=dc: gosub 8000: if s then return
5130 a$="p"+chr$(96+8)+chr$(1)+chr$(0)+chr$(1): print#14,a$: print#14,a$
5140 : u=sc: gosub 8000: if s then return
5150 a$="p"+chr$(96+9)+chr$(rl)+chr$(rh)+chr$(1): print#15,a$: print#15,a$
5160 : print#9,chr$(255);: rem write end record
5170 a$="p"+chr$(96+9)+chr$(1)+chr$(0)+chr$(1): print#15,a$: print#15,a$
5180 : u=dc: gosub 8000: if s then return
5200 gosub 4500:print "now copying ";f$
5210 for rn=1tor: sysba: next
5220 close8: close9: u=dc: gosub 8000
5230 return
6000 rh=int(r/256):rl=r-rh*256 :rem send src p cmd. r=rec#, l=offset
6010 a$="p"+chr$(96+8)+chr$(rl)+chr$(rh)+chr$(l): print#14,a$: print#14,a$
6020 : u=sc: goto8000 :rem get disk stat and return
8000 input#u,a$,b$,c$,d$: s=val(a$): s$=a$+e$+b$+e$+c$+e$+d$ :return
9000 poke53280,0:poke53281,0:print"[147]";
9010 print"[155][176][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][174]
9020 [153]"list(NULL) openfilecopy utility - v021887list (NULL)
9030 print"[173][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][189]":print
9040 return
9045 ifu=12thenprint"[155]"f$" "b$:end
9050 open15,u,15:open2,u,2,f$+",p,r":close2:input#15,a,b$,c,d
9055 close15:ifa>19thenu=u+1:goto9045
9060 return
9100 f=abs(peek(65533)=255) :rem f=0 if c64, f=1 if c128
9101 if f=0 and ba=0 then ba=12*4096
9102 if f=1 and ba=0 then ba=(NULL)("c00")
9103 return