ExpireRelative

From 40tude Dialog Wiki

Please read the Postkey script warning page before trying out this script.

ExpireRelative

Writing a plonk action, we know that the expire rule is absolute, e.g. you can't write an expire 30 days from now but you have to put for example "Expire:20040520" (where 20040520 means May 20, 2004).
With this custom script you can add a plonk rule with an expire set from the current day to the number of months you choose (default is 1 month).
You can also choose whether the plonk will be for the "From" or for the "Subject" (default is "From").
The script also automatizes the work of purging the expired items.
It works only for the selected message in the selected newsgroup: in other words, with this script you can't press the Ctrl key to have the plonk in the [*] section, i.e. for all your newsgroups, because this useful trick put the script's expire output at the end of the page and then you'll get an error.

Note:.
Write your preferences in the const section of the script and adjust for your language the Postkey commands in the end of the script.
Compile with Ctrl+F9 (not F9 or the green arrow), otherwise Postkey will put the Expire in the script editor!

Tested successfully with Dialog 2.0.12.1 (Beta 35)

Program ExpireRelative;
uses
 Forms, StdCtrls;
 
const

 action = 'plonk From';
 // if you want to plonk the subject, write 'plonk Subject' (instead of 'plonk From')

 numM = 1; // number of months you want the plonk lives (from the current day)
 
var
 myForm : TForm;
 myMemo : TMemo;	

function ExpireAfter: string;
 var today, after: TDateTime;
begin
 today:=Now;
 after:=IncMonth(today, numM);
 result:=' Expire:'+(FormatDateTime('yyyymmdd', after));
end;

begin
 try
  myForm:=TForm.Create(nil);
  myForm.Width:=300;
  myForm.Height:=40;
  myMemo:=TMemo.Create(myForm);
  myMemo.Parent:=myForm;
  myMemo.Width:=280;
  myMemo.Text:=ExpireAfter;
  myMemo.SelectAll;
  myMemo.CopyToClipboard; 
  PostKey(35, false, false, false, false, false, false, false, false); //end
  PostKey(86, false, false, true, false, false, false, false, false); //Ctrl+V

  PostKey(80, false, true, false, false, false, false, false, false);
  //Alt+P (Purge) in English and French versions
  //put 76 for Alt+L (löschen) in German version
  //put 67 for Alt+C in Italian version

  PostKey(79, false, true, false, false, false, false, false, false);
  //Alt+O (OK) in English, French and German versions
  //put 75 for Alt+K in Italian version

  if (action='plonk From') then ADo('AddPlonkFilter')
  else ADo('AddSubjectPlonkFilter');
 finally
  myForm.free;
 end;
End.

MariaLuisa C
(aka MLC)