PlonkWithAddress
From 40tude Dialog Wiki
Please read the Postkey script warning page before trying out this script.
Contents |
To plonk an author with his/her nick and address.
This script adds the email address to the nickname in a plonk action, with the logical "and" between them. So, in the "Score and actions" window you'll get something like:
!markread From "nickname" +"<email_address>"
The script at the end of its job shows the "Score and actions" window, so you can check the result and see if it fits your needs. Clicking OK accepts the changes, clicking Cancel leaves all unchanged.
Notes
- This script doesn't check if you currently have the headers visible or not, but: if they are not visible, it does its job and adds the address, if instead they are visible it adds only the nickname (Dialog default).
- Some people use a nickname which is itself an email address: when only that appears in the From: header, only that is added.
- A malformed address, that in the headers doesn't start with a <, is not added.
More Important Notes
- Don't compile the script with F9 (or clicking on the green triangle), but compile it with Ctr+F9 (or clicking on the gray little sheet with 10101, on the left of the green triangle) and then run it outside the script editor, with a hotkey or a dedicated button.
- Don't use the Ctrl key in your hotkey combination: the script wouldn't work well.
- The script uses the Postkey() function to send the "end" and "Ctrl+V" keystrokes to the "Score and actions" window: so be aware of that, if you have changed these keys to something else.
Tested successfully on Dialog/2.0.15.1(Beta 38)
The script
Program PlonkWithAddress; //v0.4 24/Gennaio/2005, by MLC
uses Forms, StdCtrls;
var
myForm: TForm;
myMemo: TMemo;
mail: string;
Function EmptyClipboard:boolean; external 'EmptyClipboard@user32.dll stdcall';
Function OpenClipboard(hWndNewOwner: INTEGER):boolean; external 'OpenClipboard@user32.dll stdcall';
Function CloseClipboard:boolean; external 'CloseClipboard@user32.dll stdcall';
function ItemCount(s: string; sep: char): integer;
var
i, r: integer;
stemp: string;
begin
stemp:=s;
r:=0;
i:=Pos(sep,stemp);
while i<>0 do
begin
r:=r+1;
delete(stemp, i, 1);
i:=Pos(sep,stemp);
end;
result:=r;
end;
function RevStr(s: string ): string;
var
i: integer;
s2: string;
begin
s2 := '';
for i:=1 to Length(s) do
begin
s2:=s[i]+s2;
end;
result:=s2;
end;
Procedure ClearClipboard;
Begin
OpenClipboard(0);
EmptyClipboard;
CloseClipboard;
end;
Procedure GetMsgBody;
begin
ClearClipboard;
myMemo.Clear;
ADo('ArticlePane');
ADo('SelectAll');
Ado('Copy');
myMemo.PasteFromClipboard;
end;
Function GetAddress: string;
var
i: integer;
addr: string;
begin
i:=0;
addr:='';
while (i < myMemo.Lines.count-1) do
begin
if Pos('From:', myMemo.lines.Strings[i]) = 1 then
begin
addr:=myMemo.lines.Strings[i];
break;
end
else i:=i+1;
end; //while
i:=ItemCount(addr, '<');
if (i > 0) then
begin
addr:=RevStr(addr);
i:=Pos('<',addr);
addr:=copy(addr, 1, i);
addr:=RevStr(addr);
end else addr:='';
result:=addr;
end;
Procedure BuildContainers;
begin
myMemo := tMemo.Create(myForm);
myMemo.Parent := myForm;
myMemo.Width := Application.Mainform.width;
end;
Begin
myForm := tForm.Create(nil);
lockdisplay;
try
BuildContainers;
ADo('ShowHeaders');
GetMsgBody;
ADo('ShowHeaders');
mail:=GetAddress;
if (mail='') then myMemo.text:=' '
else myMemo.text:=' +"'+mail+'"';
myMemo.SelectAll;
myMemo.CopyToClipboard;
ADoLater('AddPlonkFilter');
PostKey(35, false, false, false, false, false, false, false, false); //end
PostKey(86, false, false, true, false, false, false, false, false); //Ctrl+V
finally
unlockdisplay;
myForm.free;
end;
End.
--MariaLuisa C