cagordon@watnot.UUCP (Chris Gordon ) (10/23/86)
For all of you out there who could use uuencode or uudecode on your Commodore
128, here is a BASIC (no comments please!) program to do it. Regrettably, this
program only works on the 128. It should be fairly simple to convert it to work
on the 64. If you want it for the 64 and don't feel up to changing it, I'd be
happy to.
Otherwise ... enjoy!
---cut here and at the end (.signature)--------
10 dim hu(2),ch(3)
15 print
20 print"[DOWN][DOWN][DOWN][RIGHT][RIGHT]uu[RVS_ON]e[RVS_OFF]ncode
30 print"[RIGHT][RIGHT]uu[RVS_ON]d[RVS_OFF]ecode
40 print"[RIGHT][RIGHT][RVS_ON]q[RVS_OFF]uit
50 print"[DOWN][DOWN][RIGHT][RIGHT]which?
60 getkeya$:ifinstr("edqp",a$)=0then60
70 ifa$="q"thenclr:end
80 ifa$="e"then1000
85 ifa$="p"then10000
90 goto2000
1000 print:print:print
1005 input"input file";fi$
1006 fo$=fi$+".uue":iflen(fo$)>16thenfo$=right$(fo$,16)
1010 print"output file (default '"fo$"')";:inputfo$
1015 fh$="":fori=1tolen(fi$):ifmid$(fi$,i,1)<>" "thenfh$=fh$+mid$(fi$,i,1)
1016 next
1020 print"filename in header (default '"fh$"')";:inputfh$:ifinstr(fh$," ")<>0thenprint"filename must not contain spaces":goto1015
1022 mo$="644":print"mode in header (default '"mo$"')";:inputmo$
1025 open15,8,15
1030 open1,8,8,fi$+",p,r":s1=st
1035 ifds=0then1050
1040 close1:open1,8,8,fi$+",s,r":s1=st
1045 ifds=0then1050
1046 m$="can't open '"+fi$+"': "+ds$:goto3900
1050 open2,8,3,fo$+",s,w"
1055 ifds=0then1080
1060 ifds<>63thenm$="can't open '"+fo$+"': "+ds$:goto3900
1065 print"overwrite existing '"fo$"'? [y/n] ";
1070 getkeya$:ifa$<>"y"anda$<>"n"then1070
1075 ifa$="y"thenprint"yes":print#15,"s:"fo$:close2:goto1050
1076 print"no":m$="overwrite cancelled":goto3900
1080 fast:print#2,"begin "mo$" "fh$
1085 if64ands1then1400
1088 gosub1800:li=0:iflen(li$)=0then1400
1090 lo$=chr$(len(li$)+32)
1095 do while (len(li$)<>3*int(len(li$)/3)):li$=li$+chr$(0):loop
1100 forj=1tolen(li$)/3
1105 fori=0to2:li=li+1:hu(i)=asc(mid$(li$,li,1)):nexti
1110 ch(0)=hu(0)/4
1115 ch(1)=(hu(0)*16+hu(1)/16)and63
1120 ch(2)=(hu(1)*4+hu(2)/64)and63
1125 ch(3)=hu(2)and63
1130 fori=0to3:lo$=lo$+chr$(ch(i)+32):nexti
1135 nextj
1136 print".";
1140 print#2,lo$
1145 goto1085
1400 print#2," "
1405 print#2,"end"
1410 close1:close2:close15:slow:run10
1800 li$="":lo$=""
1805 forii=1to45
1810 get#1,z$:s1=st:ifz$=""thenz$=chr$(0)
1820 li$=li$+z$:if64ands1thenii=45
1825 nextii:return
2000 print:print:print:ln=0
2005 open15,8,15
2010 input"filename";ff$
2015 open1,8,3,ff$+",s,r":s1=st
2020 ifds=0then2030
2028 m$="cannot open '"+ff$+"': "+ds$:goto3900
2030 if64ands1thendclose:m$="nothing to decode":goto3900
2040 gosub3000:ifleft$(ln$,6)="begin "then2060
2045 goto2030
2060 ii=7:ln$=ln$+" ":fo$=""
2061 gosub2065:gosub2065:fo$=wo$:goto2100
2065 wo$="":do while mid$(ln$,ii,1)=" "
2070 ii=ii+1:ifii>len(ln$)thenm$="incomplete header":goto3900
2075 loop
2080 do while mid$(ln$,ii,1)<>" ":wo$=wo$+mid$(ln$,ii,1)
2085 ii=ii+1:ifii>len(ln$)thenm$="incomplete header":goto3900
2090 loop
2095 return
2100 print"destination: '"fo$"'"
2105 print"program or sequential? [p/s] ";
2110 getkeyft$:ifft$<>"p"andft$<>"s"then2110
2115 ifft$="p"thenprint"program":elseprint"sequential
2120 open2,8,2,fo$+","+ft$+",w":s2=st
2125 ifds=0then2150
2130 ifds<>63thenm$="unable to open '"+fo$+"': "+ds$:goto3900
2135 print"overwrite existing '"fo$"'? [y/n] ";
2140 getkeya$:ifa$<>"y"anda$<>"n"then2140
2145 ifa$="y"thenprint"yes":print#15,"s:"fo$:close2:goto2120
2146 print"no":m$="overwrite cancelled":goto3900
2150 fast:gosub3000:li=0:bn=3
2155 gosub3100:co=asc(ch$)-32:ifco=0then2230
2160 forj=1toco
2165 ifbn<3then2200
2170 fori=0to3:gosub3100:ch(i)=asc(ch$)-32:next
2175 hu(0)=(ch(0)*4+ch(1)/16)and255
2180 hu(1)=(ch(1)*16+ch(2)/4)and255
2185 hu(2)=(ch(2)*64+ch(3))and255
2190 bn=0
2200 print#2,chr$(hu(bn));
2205 bn=bn+1
2210 nextj
2220 goto2150
2230 gosub3000
2240 ifln$<>"end"thenm$="abnormal end":goto3900
2250 close1:close2:close15:slow:run10
3000 ln$="":print".";:ln=ln+1
3005 get#1,z$:s1=st:ifz$=""thenz$=chr$(0)
3010 ifz$=chr$(13)then3035
3020 ln$=ln$+z$:if64ands1then3035
3030 goto3005
3035 iflen(ln$)=0thenprint"blank line in file":dclose:run10
3040 return
3100 li=li+1:ifli>len(ln$)thenm$="line too short":goto3900
3105 ch$=mid$(ln$,li,1)
3110 ifch$<" "orasc(ch$)>96thenm$="illegal character in line: "+ch$:goto3900
3120 ifch$=chr$(96)thench$=" "
3130 return
3900 slow:ifln>0thenprintusing"line ####: ";ln;
3910 printm$:dclose:run10
10000 open15,8,15
10005 input"filename";f$
10010 open8,8,8,f$:ss=st
10015 ifds<>0thenprintds$:dclose:end
10020 if64andssthendclose:end
10025 get#8,a$:ss=st:poke244,1:poke245,1:printchr$(asc(a$));:goto10020
---- cut here ------------
--
-------------------------------------------------------------------------------
Chris Gordon UUCP: {abunchasystems}!watmath!watnot!cagordon
U of Waterloo, Ont CompuServe: Don't know yet
-------------------------------------------------------------------------------
"...Life...in the fast lane... (AND bits of egg!)"