/* UUDecode.spot written by François Helsen    */
/* Thanks to David Nouls and Alex Van Boxel    */
/*         for their inspiration               */
/* Install as 'UUDecode...' in the ARexx menu. */
/* $VER: UUDecode.spot 1.7 (27.12.93)          */
/* Again modified by David Nouls               */

address spot
options results

'ismessages'
if rc = 5 then do
   'requestnotify "Use in message window only!"'
   exit
   end

call AddLib('rexxsupport.library',0,-30,0)

saveascii 't:spotuu.tmp' overwrite

if open(in,'t:spotuu.tmp','r') then do
   if checkcoded(in)=1 then do
      call close(in)

/* You may have to change this path into your own path, or make it empty */

      'requestpath title "Pick a directory" path "RAM:"'
      if rc = 0 then do
         dirname = result
         olddir = pragma('d', dirname)
         ADDRESS COMMAND 'UUdecode >NIL: t:spotuu.tmp'
         call pragma('d', olddir)
         'requestnotify "File decoded..."'
         end
      end
   else do
      call close(In)
      'requestnotify "This message does not contain UUEncoded Data"'
      end
   call Delete('t:spotuu.tmp')
   end

exit /* done here */

checkcoded: procedure
   PARSE ARG In
   do while ~eof(in)
   if word(readln(in),1)='begin' then
      return 1
      end
   return 0
