home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / comm / Fido / Spot / Rexx / UU-Writer.spot < prev    next >
Text File  |  1993-10-30  |  8KB  |  262 lines

  1.  
  2. /*
  3. -----------------------------------------------------------------------------
  4. UU-Writer
  5.  
  6. This script written by Jan Van Overbeke
  7.  
  8. This script needs UUEncode V37.22 (or later if arguments are compatible).
  9.  
  10. Any remarks to Jan Van Overbeke, Fido: 2:292/603.29
  11. Let me know if your script ends faulty, or you have trouble with this script
  12. In that case pass your configuration of compu and what your trouble is
  13. -----------------------------------------------------------------------------
  14. */
  15.  
  16. /* ---      This is a file-intensive script.      --- */
  17. /* ---  I learned that open(), close(), writeln() --- */
  18. /* ---          Must be perceded by CALL          --- */
  19. /* ---  Like: call writeln(outputter)             --- */
  20. /* ---  and:  temp=readln(inputter)               --- */
  21. /* -------------------------------------------------- */
  22.  
  23. /* ---               Never use '0a'x               --- */
  24. /* --- That would get your requesters into trouble --- */
  25. /* --------------------------------------------------- */
  26. cr='0d'x
  27. options results
  28. address SPOT
  29. call addlib('rexxsupport.library',0,-30)
  30.  
  31. /* --- Put up a requester to warn user --- */
  32. /* --------------------------------------- */
  33. tell='UU-Writer'CR||CR
  34. tell=tell'This fine script will enable you'CR
  35. tell=tell'to send a file to whoever is a point'CR||CR
  36. tell=tell'This script can divide e.g. a 10 Meg animation'CR
  37. tell=tell'into some 10000 messages'CR
  38. tell=tell'Theres no limit =:*]'CR||CR
  39. tell=tell'But'CR||CR
  40. tell=tell'YOUR BOSS AND OTHER BOSSES WILL SUFFER FROM THIS!'CR
  41. tell=tell'Not 4 not they refuse file-attach from/to outside'CR||CR
  42. tell=tell'A 50K file would do more than enough'CR||CR
  43. tell=tell'UU-Writer & UU-Retriever: Written by'CR
  44. tell=tell'Jan Van Overbeke, 2:292/603.29'
  45. 'requestnotify PROMPT "'tell'" CENTER'
  46.  
  47. /* ---     Do some checking first.    --- */
  48. /* ---   checking is very important   --- */
  49. /* --- so everyone can use the script --- */
  50. /* -------------------------------------- */
  51. if ~exists('c:UUEncode') then do
  52.     'requestnotify PROMPT "Could not find c:UUEncode (V37.22)"'
  53.     exit
  54.     end
  55. if ~exists('c:Echo') then do
  56.     'requestnotify PROMPT "Could not find c:Echo"'
  57.     exit
  58.     end
  59. if ~exists('c:Join') then do
  60.     'requestnotify PROMPT "Could not find c:Join"'
  61.     exit
  62.     end
  63. if ~exists('c:Delete') then do
  64.     'requestnotify PROMPT "Could not find c:Delete"'
  65.     exit
  66.     end
  67. if ~exists('c:rename') then do
  68.     'requestnotify PROMPT "Could not find c:Rename"'
  69.     exit
  70.     end
  71.  
  72. /* --- The area list is NOT the right place --- */
  73. /* ---          to use this script          --- */
  74. /* -------------------------------------------- */
  75. 'isarealist'
  76. if RC=0 then do
  77.     'requestnotify PROMPT "Cannot UU-Write in area-list!"'
  78.     exit
  79.     end
  80.  
  81. /* ---       Let's try to get a file here       --- */
  82. /* --- We don't want any spaces in the filename --- */
  83. /* ------------------------------------------------ */
  84. 'requestfile TITLE "UU-Writer needs a file" PATH "spot:"'
  85. file=result
  86. if RC=5 then exit
  87. if ~exists(file) then do
  88.     tell="File not found:"CR||file
  89.     'requestnotify PROMPT "' tell '" CENTER'
  90.     exit
  91.     end
  92. help=lastpos('/',file)
  93. if help=0 then help=pos(':',file)
  94. filepart=delstr(file,1,help)
  95. if pos(' ',filepart)>0 then do
  96.     tell='Spaces into the filename would seriously'CR
  97.     tell=tell'fool the UU-Retriever script'CR
  98.     tell=tell'Spaces in path is allowed'CR
  99.     tell=tell'So dont use spaces in the filename!'CR||CR||'Thank you.'
  100.     'requestnotify PROMPT "'tell'" CENTER'
  101.     exit
  102.     end
  103.  
  104. /* ---     Start UU-Encoding here     --- */
  105. /* --- Arguments for UUEncode V37.22 --- */
  106. /* --- Apply "" quotes, so Ram Disk: --- */
  107. /* ---            Will work          --- */
  108. /* ------------------------------------- */
  109. file='"'file'"'
  110. address command 'c:UUEncode FROM ' file ' TO t:UU-Encoded'
  111.  
  112. /* --- This is where the requester comes in --- */
  113. /* ---      To give the user much info      --- */
  114. /* -------------------------------------------- */
  115. lines='x'
  116. splitnr='x'
  117. goon=1
  118. do while goon
  119.     if lines='x' | splitnr='x' then avg='x'
  120.                                else avg=trunc(lines/splitnr)
  121.     tell='UU-Encoded file:'CR||CR'Bytes: 'word(statef("t:UU-Encoded"),2)
  122.     tell=tell'   Lines: 'lines||CR'Split into 'splitnr' messages'
  123.     tell=tell' ('avg' lines/message average)'
  124.     buttons='Count lines|Enter # o msgs|GO!|Exit script'
  125.     'requestresponse PROMPT "' tell '" GADGETS "' buttons '" CENTER'
  126.     if RC=0 then exit
  127.     if RC=1 then do
  128.         lines=count()
  129.         splitnr=trunc(lines/150)+1
  130.         end
  131.     if RC=2 then splitnr=asknumberofmsgs()
  132.     if (RC=3 & lines~='x' & splitnr~='x' & splitnr>0) then goon=0
  133.     end
  134.  
  135. /* --- Going to split here --- */
  136. /* ---   if # o msgs > 1   --- */
  137. /* --------------------------- */
  138. if splitnr>1 then do
  139.     call open(inputter,'t:UU-Encoded','R')
  140.     do current=1 to splitnr
  141.         call open(outputter,'t:Splitted'current,'W')
  142.         if current=splitnr then do
  143.             do while ~eof(inputter)
  144.                 towrite=readln(inputter)
  145.                 if ~eof(inputter) then call writeln(outputter,towrite)
  146.                 end
  147.             end
  148.             else do
  149.                 do t=1 to trunc(lines/splitnr)
  150.                     call writeln(outputter,readln(inputter))
  151.                     end
  152.                 end
  153.         call close(outputter)
  154.         end
  155.     call close(inputter)
  156.     address command 'c:delete >nil: t:UU-Encoded'
  157.     end
  158.     else address command 'c:rename >nil: t:UU-Encoded as t:Splitted1'
  159.  
  160. /* --- Have to declare the files/vars --- */
  161. /* -------------------------------------- */
  162. address command 'c:echo " " >t:Blankline'
  163. line='-------------------------------------------------------------'
  164. address command 'c:echo "' line '" >t:Fullline'
  165.  
  166. /* --- Let SPOT create the first message, and you will edit it --- */
  167. /* ---   Fixed some trouble with "" quotes, thats the delstr   --- */
  168. /* --------------------------------------------------------------- */
  169. call addlines(1)
  170. file=delstr(file,length(file))
  171. 'write FILE t:ThisIsIt1 SUBJECT ' file '1/'splitnr'"'
  172. if RC=10 then do
  173.     'requestnotify PROMPT "Could not start writing"'
  174.     exit
  175.     end
  176. if RC=5 then do
  177.     'requestnotify PROMPT "Cancelled"'
  178.     exit
  179.     end
  180. 'lastmessage'
  181. 'getsubject'
  182. if result~=file' 1/'splitnr then
  183.     'edit NOGUI NOEDIT SUBJECT 'file' 1/'splitnr'" NOREQ'
  184.  
  185. /* --- Now go for the rest --- */
  186. /* ---    If # o msgs>1    --- */
  187. /* ---   Use same header   --- */
  188. /* --------------------------- */
  189. if splitnr>1 then do
  190. 'lastmessage'
  191. 'getfrom'
  192. one=result
  193. 'getfromadrress'
  194. two=result
  195. 'getto'
  196. three=result
  197. 'gettoaddress'
  198. four=result
  199. do w=2 to splitnr
  200.     call addlines(w)
  201.     fullcommand='FILE t:ThisIsIt'w' NOEDIT NOGUI NOSIG ORIGIN " " '
  202.     fullcommand=fullcommand'SUBJECT 'file' 'w'/'splitnr'" '
  203.     fullcommand=fullcommand'TO "'three'" TOADDR "'four'" '
  204.     fullcommand=fullcommand'FROM "'one'" FROMADDR "'two'"'
  205.     'write 'fullcommand
  206.     if RC~=0 then do
  207.         'requestnotify PROMPT "SERIOUS PROBLEM! WHILE WRITING MESSAGES!"'
  208.         exit
  209.         end
  210.     'lastmessage'
  211.     end
  212. end
  213.  
  214. /* --- Delete some nasty files --- */
  215. /* ------------------------------- */
  216. address command 'c:delete >nil: t:blankline t:fullline t:thisisit'splitnr
  217.  
  218.  
  219. /* --- Phew --- */
  220. 'requestnotify PROMPT "Finished"'
  221. exit
  222.  
  223.  
  224.  
  225.  
  226.  
  227. /* --- procedure to count lines in the UU-Encoded file. --- */
  228. /* -------------------------------------------------------- */
  229. count: procedure
  230.     call open(inputter2,'t:UU-Encoded','R')
  231.     dummy=0
  232.     do while ~eof(inputter2)
  233.         dummy=dummy+1
  234.         call readln(inputter2)
  235.         end
  236.     call close(inputter2)
  237.     return dummy
  238.  
  239. /* --- procedure to ask for a number of msgs --- */
  240. /* --------------------------------------------- */
  241. asknumberofmsgs: procedure
  242.     'requestnumber PROMPT "Enter number of messages" DEFAULT "10"'
  243.     if RC~=0 then return 'x'
  244.     return result
  245.  
  246. /* ---              A procedure to....               --- */
  247. /* ---        Add some seperation lines here         --- */
  248. /* --- Using some clever commands with echo and join --- */
  249. /* ----------------------------------------------------- */
  250. addlines: procedure
  251.     arg number
  252.     doscommand='c:join t:blankline t:fullline t:Splitted'number
  253.     doscommand=doscommand || ' t:fullline t:blankline AS t:ThisIsIt'number
  254.     address command doscommand
  255.     address command 'c:delete >nil: t:UU-Encoded'number' t:splitted'number
  256.     if number>1 then address command 'c:delete >nil: t:ThisIsIt'number-1
  257.     return
  258.  
  259.  
  260.  
  261.  
  262.