Path: utzoo!utgpu!attcan!uunet!cbmvax!fred From: fred@cbmvax.UUCP (Fred Bowen) Newsgroups: comp.sys.cbm Subject: Re: Can REL files be copied? Message-ID: <6662@cbmvax.UUCP> Date: 21 Apr 89 13:56:51 GMT References: <2063.244810B4@isishq.FIDONET.ORG> <2156@csd4.milw.wisc.edu> Reply-To: fred@cbmvax.UUCP (Fred Bowen) Organization: Commodore Technology, West Chester, PA Lines: 57 In article <2156@csd4.milw.wisc.edu> Joe Greco writes: >In article <2063.244810B4@isishq.FIDONET.ORG> Geoffrey Welsh wrote: >] > Also note that one of the better ways of finding the max record length >] > is to open the physical directory file and LOOK. That has the >] > disadvantage of not working with RAMDOS and some less than compatible >] > disk drives. >] >]The method discussed finds the number of records in the file, not the >]number of bytes per record (which I think we'd all agree should be fetched >]from the directory file). > >fetching the number of bytes per record should not necessarily be >fetched from the directory file! Anyone have a FOOLPROOF method? The best way is, to me anyway, the most obvious and straightforward- find the end of the record by moving the record/byte pointer through the record until the DOS returns an error. This is how FILECOPY works. The code from FILECOPY (f$ and n$(i) are the filename, sc and dc are the source and destination channels, and sysba is some simple ML which reads/writes blocks to minimize talker/attention turn around time): 5000 rem copy rel file 5010 print "scanning ";f$ 5020 open8,su,8,n$(i): u=sc: gosub 8000: if s then return 5030 l=0: for rn=7 to 0 step-1: rg=2^rn: rem binary scan for reclen 5040 : r=1:l=l+rg:gosub 6000: if s then l=l-rg 5050 : next 5060 r=0: for rn=15 to 0step-1: rg=2^rn: rem binary scan for numrec 5070 : r=r+rg: gosub 6000: if s then r=r-rg 5080 : next 5100 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 print "copying ";f$ 5210 for rn=1 to r: sysba: next 5220 close8: close9: u=dc: gosub 8000 5230 return 5240 : 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: rem get disk stat & return 6030 : 8000 input#u,a$,b$,c$,d$: s=val(a$): s$=a$+e$+b$+e$+c$+e$+d$ :return -- -- Fred Bowen uucp: {uunet|rutgers|pyramid}!cbmvax!fred arpa: cbmvax!fred@uunet.uu.net tele: 215 431-9100 Commodore Electronics, Ltd., 1200 Wilson Drive, West Chester, PA, 19380