! RSX-to-DOS format text convertor, like RT-11 TCONV, 1986. ! By Nicholas Zymaris, 23-Feb-1999 function recsz(block$) let recsz=ord(block$[1:1])+(256*(ord(block$[2:2]))) end function function errp$(p$) input#3, prompt p$: temp$ select case ucase$(temp$[1:1]) case "Q" stop case else !retry end select let errp$=temp$ end function ! initialize variables used as constants let crlf$=chr$(13)&chr$(10) let null$=chr$(0) let s$="######### bytes out of ######### Line #######" ! Main code begins let upper=0.09 ! upper bound of lower window !let upper=0.39 ! upper bound of lower window (for debugging) open #3: screen 0,1,0,upper print#3: "TCONV for DOS V1.0 -- by Nicholas Zymaris 24-Feb-1999" when error in input#3, prompt "RSX File? > ":infile$ open #1: name infile$, access input, create old, org byte use let p$="Error opening file. Enter RSX input filename, or Q to quit: " let infile$=errp$(p$) retry end when when error in input#3, prompt "DOS-format output file? (or CON or TI:) > ":outfile$ if ucase$(outfile$)<>"CON" and ucase$(outfile$)<>"TI:" then open #2: name outfile$, access output, create new, org byte let scr=0 else open #2: screen 0,1,upper+.01,1 set color "yellow" let scr=1 end if use let p$="Error opening file. Enter DOS output filename, or Q to quit: " let outfile$=errp$(p$) ! if ucase$(outfile$)="CON" or ucase$(outfile$)="TI:" then ! run retry end when ! Filesize is rounded up to next highest block if F.FFBY not respected by transfer program ask #1: filesize s ! total filesize let written=0 ! bytes written let line=0 ! current line do while more #1 read #1, bytes 2: c$ let count=recsz(c$) let line=line+1 !if count<>0 then ! not needed; a read of 0 bytes means L$ := "" read #1, bytes count: L$ !else !let L$="" !end if if len(L$)/2<>int(len(L$)/2) then let L1$=L$&null$ read #1, bytes 1: L0$ else let L1$=L$ end if if line<>1 then let L1$=crlf$&L$ ! no spurious CRLF before first line let writtn=writtn+len(L1$) select case scr case 0 write #2: L1$ ! write to file including CRLF and possible null case 1 print #2: L$ ! write to screen (internal file, can't use WRITE) end select ask cursor x,y set cursor 2,1 let sofar=round((100*writtn/s),0) if sofar<10 then print #3: " "; else if sofar<100 then print #3: " "; end if print #3: str$(sofar);"% done "; print #3, using s$: writtn,s,line when error in write #2: "" ! set to window 2 use print #2:; end when set cursor x,y loop !print #3:" ("; ! if on same line (end parenthesis with next statement) print #3: infile$;": All done." close #2 close #1 close #3 end