/*
 *            Imp Put In List
 * The Ultimate Accessory to Spot Imp Master
 *
 *         (C)1995 Steve Pearson
 *
 *          This is Tailor-Ware
 *         Edit it as YOU NEED it
 *
 *    $VER : Imp Put In List V1 (1.6.95)
 *
 */



address spot
options results

parse arg LID

upper LID

/* PutInList takes 1 parameter to jump directly imto a List ID of your choice =) */


/* Get the current messages details */

'getfrom'
from=substr(compress(result,"&%^£$:/|\*#?()"||'27'x||'22'x),1,13)
'getsubject'
subj=result
if upper(substr(subj,1,3))="RE:" then subj=strip(substr(subj,4),'B')
subj=strip(substr(compress(subj,":&%^$£/|\*#?()"||'27'x||'22'x),1,13),'B')
'getareaname'
area=result
'getmessagenum'
mnum=result

/* If I had no parameter see if we can get the user to supply one */

if lid~="" then do
	fname="MAIL:QUICKLISTS/"||lid||"/"
end
else do
        if (open('LLID','ENV:LASTLIST.IMP','r')) then do
        	lid=readln('LLID')
		call close('LLID')
	end
	'requestpath title "Imp Quick List" path MAIL:QUICKLISTS/'lid
	fname=result

	if rc~=0 then exit
	if exists('ENV:LASTLIST.IMP') then do
		address command
		'delete ENV:LASTLIST.IMP >nil:'
		address spot
	end
end

address command

'c:search file "'fname'#?" "?-'from'-'subj'#?" pattern > t:tempwibble '
'c:list t:tempwibble lformat "%l" > t:tempqlcheck'
'c:delete t:tempwibble >nil:'

address spot

if ~open('tempo','t:tempqlcheck') then do
	'requestnotify Title "Imp Put In List" Prompt "Error: Could not open a Temp File."'
	exit
end

state=upper(readln('tempo'))

call close('tempo')

address command

'c:delete t:tempqlcheck >nil:'

address spot

if state = "EMPTY" then do
	address command
	'c:echo "'area'*n'mnum'" > "'fname'A-'from'-'subj'"'
        address spot
        'requestnotify title "Imp Put In List" Prompt "Message Added To List"'
end
else do
	'requestnotify title "Imp Put In List" Prompt "Message Already in List!"'
end