/* UUdecoding Module */

address spot
options results

/* The Clip list MUST contain UUXC!!! */
/* PARAMETERS NEEDED UUDECODE PATH */

parse arg uupath

uuxc=getclip('IMP_UUXC')


'Getnumselected'

total=Result

'progressopen TITLE "Imp Master UU-Decoder" Prompt "Getting Message Numbers"'
progdat=result


'firstmessage'

/* Get message numbers of all UU mail */

current=1

do while ~(current=total+1)
	'nextmarked'
	'getmessagenum'
        finduu.current=result
	current=current+1
	'progressupdate REQ "'progdat'" CURRENT "'current'" TOTAL "'total'" PROMPT "Getting Message Numbers"'
	if rc=5 then do
		current=total+1
		'excludeflag all'
	end
end

'progressclose 'progdat


/* Lose them all */

'excludeflag all'

current=1

/* Look at each message in turn */

'progressopen TITLE "Imp Master UU-Decoder" Prompt "0 Decoded"'
progdat=result

do while ~(current=total+1)
	'gotomessage "'finduu.current'"'
	'markmessage'

	/* Save the message out as ascii */

        'saveascii TO "t:IMPUUD.UUE" NOHEADER NOTEARLINE NOORIGIN NOKLUDGES OVERWRITE'
	'markmessage clear'

	address command

	/* Create a mini script file to
		CD to the UUpath
		UU extract it
		delete the temp UU file
	*/

	'c:echo "CD 'uupath' >nil:" > t:tempuudscript'
        'c:echo "'uuxc' t:impuud.uue >nil: " >> t:tempuudscript'
	'c:echo "delete t:impuud.uue >nil: " >> t:tempuudscript'
        'c:execute t:tempuudscript >nil: '

	/* The delete the script */

	'delete t:tempuudscript >nil: '

	address SPOT

        current=current+1

	'progressupdate REQ "'progdat'" CURRENT "'current'" TOTAL "'total'" PROMPT "'current' Decoded"'
	if rc=5 then current=total+1
end

'progressclose 'progdat


EXIT total
