home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
comm
/
fido
/
spot
/
rexx
/
uu-writer.spot
< prev
next >
Wrap
Text File
|
1993-10-30
|
8KB
|
262 lines
/*
-----------------------------------------------------------------------------
UU-Writer
This script written by Jan Van Overbeke
This script needs UUEncode V37.22 (or later if arguments are compatible).
Any remarks to Jan Van Overbeke, Fido: 2:292/603.29
Let me know if your script ends faulty, or you have trouble with this script
In that case pass your configuration of compu and what your trouble is
-----------------------------------------------------------------------------
*/
/* --- This is a file-intensive script. --- */
/* --- I learned that open(), close(), writeln() --- */
/* --- Must be perceded by CALL --- */
/* --- Like: call writeln(outputter) --- */
/* --- and: temp=readln(inputter) --- */
/* -------------------------------------------------- */
/* --- Never use '0a'x --- */
/* --- That would get your requesters into trouble --- */
/* --------------------------------------------------- */
cr='0d'x
options results
address SPOT
call addlib('rexxsupport.library',0,-30)
/* --- Put up a requester to warn user --- */
/* --------------------------------------- */
tell='UU-Writer'CR||CR
tell=tell'This fine script will enable you'CR
tell=tell'to send a file to whoever is a point'CR||CR
tell=tell'This script can divide e.g. a 10 Meg animation'CR
tell=tell'into some 10000 messages'CR
tell=tell'Theres no limit =:*]'CR||CR
tell=tell'But'CR||CR
tell=tell'YOUR BOSS AND OTHER BOSSES WILL SUFFER FROM THIS!'CR
tell=tell'Not 4 not they refuse file-attach from/to outside'CR||CR
tell=tell'A 50K file would do more than enough'CR||CR
tell=tell'UU-Writer & UU-Retriever: Written by'CR
tell=tell'Jan Van Overbeke, 2:292/603.29'
'requestnotify PROMPT "'tell'" CENTER'
/* --- Do some checking first. --- */
/* --- checking is very important --- */
/* --- so everyone can use the script --- */
/* -------------------------------------- */
if ~exists('c:UUEncode') then do
'requestnotify PROMPT "Could not find c:UUEncode (V37.22)"'
exit
end
if ~exists('c:Echo') then do
'requestnotify PROMPT "Could not find c:Echo"'
exit
end
if ~exists('c:Join') then do
'requestnotify PROMPT "Could not find c:Join"'
exit
end
if ~exists('c:Delete') then do
'requestnotify PROMPT "Could not find c:Delete"'
exit
end
if ~exists('c:rename') then do
'requestnotify PROMPT "Could not find c:Rename"'
exit
end
/* --- The area list is NOT the right place --- */
/* --- to use this script --- */
/* -------------------------------------------- */
'isarealist'
if RC=0 then do
'requestnotify PROMPT "Cannot UU-Write in area-list!"'
exit
end
/* --- Let's try to get a file here --- */
/* --- We don't want any spaces in the filename --- */
/* ------------------------------------------------ */
'requestfile TITLE "UU-Writer needs a file" PATH "spot:"'
file=result
if RC=5 then exit
if ~exists(file) then do
tell="File not found:"CR||file
'requestnotify PROMPT "' tell '" CENTER'
exit
end
help=lastpos('/',file)
if help=0 then help=pos(':',file)
filepart=delstr(file,1,help)
if pos(' ',filepart)>0 then do
tell='Spaces into the filename would seriously'CR
tell=tell'fool the UU-Retriever script'CR
tell=tell'Spaces in path is allowed'CR
tell=tell'So dont use spaces in the filename!'CR||CR||'Thank you.'
'requestnotify PROMPT "'tell'" CENTER'
exit
end
/* --- Start UU-Encoding here --- */
/* --- Arguments for UUEncode V37.22 --- */
/* --- Apply "" quotes, so Ram Disk: --- */
/* --- Will work --- */
/* ------------------------------------- */
file='"'file'"'
address command 'c:UUEncode FROM ' file ' TO t:UU-Encoded'
/* --- This is where the requester comes in --- */
/* --- To give the user much info --- */
/* -------------------------------------------- */
lines='x'
splitnr='x'
goon=1
do while goon
if lines='x' | splitnr='x' then avg='x'
else avg=trunc(lines/splitnr)
tell='UU-Encoded file:'CR||CR'Bytes: 'word(statef("t:UU-Encoded"),2)
tell=tell' Lines: 'lines||CR'Split into 'splitnr' messages'
tell=tell' ('avg' lines/message average)'
buttons='Count lines|Enter # o msgs|GO!|Exit script'
'requestresponse PROMPT "' tell '" GADGETS "' buttons '" CENTER'
if RC=0 then exit
if RC=1 then do
lines=count()
splitnr=trunc(lines/150)+1
end
if RC=2 then splitnr=asknumberofmsgs()
if (RC=3 & lines~='x' & splitnr~='x' & splitnr>0) then goon=0
end
/* --- Going to split here --- */
/* --- if # o msgs > 1 --- */
/* --------------------------- */
if splitnr>1 then do
call open(inputter,'t:UU-Encoded','R')
do current=1 to splitnr
call open(outputter,'t:Splitted'current,'W')
if current=splitnr then do
do while ~eof(inputter)
towrite=readln(inputter)
if ~eof(inputter) then call writeln(outputter,towrite)
end
end
else do
do t=1 to trunc(lines/splitnr)
call writeln(outputter,readln(inputter))
end
end
call close(outputter)
end
call close(inputter)
address command 'c:delete >nil: t:UU-Encoded'
end
else address command 'c:rename >nil: t:UU-Encoded as t:Splitted1'
/* --- Have to declare the files/vars --- */
/* -------------------------------------- */
address command 'c:echo " " >t:Blankline'
line='-------------------------------------------------------------'
address command 'c:echo "' line '" >t:Fullline'
/* --- Let SPOT create the first message, and you will edit it --- */
/* --- Fixed some trouble with "" quotes, thats the delstr --- */
/* --------------------------------------------------------------- */
call addlines(1)
file=delstr(file,length(file))
'write FILE t:ThisIsIt1 SUBJECT ' file '1/'splitnr'"'
if RC=10 then do
'requestnotify PROMPT "Could not start writing"'
exit
end
if RC=5 then do
'requestnotify PROMPT "Cancelled"'
exit
end
'lastmessage'
'getsubject'
if result~=file' 1/'splitnr then
'edit NOGUI NOEDIT SUBJECT 'file' 1/'splitnr'" NOREQ'
/* --- Now go for the rest --- */
/* --- If # o msgs>1 --- */
/* --- Use same header --- */
/* --------------------------- */
if splitnr>1 then do
'lastmessage'
'getfrom'
one=result
'getfromadrress'
two=result
'getto'
three=result
'gettoaddress'
four=result
do w=2 to splitnr
call addlines(w)
fullcommand='FILE t:ThisIsIt'w' NOEDIT NOGUI NOSIG ORIGIN " " '
fullcommand=fullcommand'SUBJECT 'file' 'w'/'splitnr'" '
fullcommand=fullcommand'TO "'three'" TOADDR "'four'" '
fullcommand=fullcommand'FROM "'one'" FROMADDR "'two'"'
'write 'fullcommand
if RC~=0 then do
'requestnotify PROMPT "SERIOUS PROBLEM! WHILE WRITING MESSAGES!"'
exit
end
'lastmessage'
end
end
/* --- Delete some nasty files --- */
/* ------------------------------- */
address command 'c:delete >nil: t:blankline t:fullline t:thisisit'splitnr
/* --- Phew --- */
'requestnotify PROMPT "Finished"'
exit
/* --- procedure to count lines in the UU-Encoded file. --- */
/* -------------------------------------------------------- */
count: procedure
call open(inputter2,'t:UU-Encoded','R')
dummy=0
do while ~eof(inputter2)
dummy=dummy+1
call readln(inputter2)
end
call close(inputter2)
return dummy
/* --- procedure to ask for a number of msgs --- */
/* --------------------------------------------- */
asknumberofmsgs: procedure
'requestnumber PROMPT "Enter number of messages" DEFAULT "10"'
if RC~=0 then return 'x'
return result
/* --- A procedure to.... --- */
/* --- Add some seperation lines here --- */
/* --- Using some clever commands with echo and join --- */
/* ----------------------------------------------------- */
addlines: procedure
arg number
doscommand='c:join t:blankline t:fullline t:Splitted'number
doscommand=doscommand || ' t:fullline t:blankline AS t:ThisIsIt'number
address command doscommand
address command 'c:delete >nil: t:UU-Encoded'number' t:splitted'number
if number>1 then address command 'c:delete >nil: t:ThisIsIt'number-1
return