ScriptGoToParent
From 40tude Dialog Wiki
A nice script written by a nice lady. Maria Luisa C. posted this in n.s.r. The script allows you to jump to the parent message of the post you have selected. Very useful if you're not using a threaded view. Put it in your custom scripts list and assign a keyboard shortcut you prefer.
On 3rd January 2004 it has been enhanced thanks to an idea of Alan Ford. Please read the Postkey script warning page before trying out this script.
Program GoToParent;
uses
Forms,
StdCtrls;
var
myForm: TForm;
myMemo: TMemo;
Refs: string;
ParentID: 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';
PROCEDURE ClearCLipboard;
BEGIN
OpenClipboard(0);
EmptyClipboard;
CloseClipboard;
END;
PROCEDURE GetMessBody (var LocMymemo: tMemo);
BEGIN
LocMyMemo.Clear;
ClearCLipboard;
ADo('ArticlePane');
ADo('SelectAll');
Ado('Copy');
LocMyMemo.PasteFromClipboard;
END;
FUNCTION RefsExtract( HeaderTag: String; var LocMymemo: tmemo): string;
var
index : integer;
allrefs: string;
BEGIN
index := 0;
allrefs := '';
WHILE (index < LocMymemo.Lines.count-1) AND (allrefs = '') DO
BEGIN
IF POS(HeaderTag,LocMymemo.lines.Strings[index]) = 1 THEN
BEGIN
allrefs := LocMymemo.lines.Strings[index];
index := index+1;
WHILE (index < LocMymemo.Lines.count-1)
AND (POS('<',LocMymemo.lines.Strings[index])=1) DO
BEGIN
allrefs := allrefs + LocMymemo.lines.Strings[index];
index := index+1;
END
END
index := index+1;
END;
result:=allrefs;
END;
FUNCTION GetHeaderInfo(HeaderTag : string; var LocMymemo : tMemo): string;
BEGIN
Result := RefsExtract(HeaderTag, LocMymemo);
delete(Result, 1, length(HeaderTag));
END;
FUNCTION GetRefs(var LocMymemo : tMemo): string;
BEGIN
result := GetHeaderInfo('References: ', LocMymemo);
END;
FUNCTION GetParent(var LocRefs: string): string;
var
tag: string;
index: integer;
posiz, lung : integer;
BEGIN
tag := '<';
index := length(LocRefs)-1;
result := '';
posiz := 0;
while (index > 0) and (posiz = 0) do
begin
if Pos(tag, LocRefs[index])=0 then
index:=index-1
else
posiz := index;
lung:=length(LocRefs)-posiz+1;
result := copy(LocRefs, posiz, lung);
end
END;
FUNCTION AreHeadersHid(var LocMymemo : tMemo): boolean;
var
index: integer;
temp: boolean;
BEGIN
temp := true;
IF LocMyMemo.Lines.count > 10 THEN
BEGIN
index := 0;
WHILE (Index < LocMyMemo.Lines.count -1) and temp DO
BEGIN
index := index+1;
temp := Pos('Newsgroups: ', LocMyMemo.Lines.strings[index]) = 0;
END;
END;
result := temp;
END;
Begin
myForm := tForm.Create(nil);
myForm.width:=800;
myForm.Height:=600;
myMemo := tMemo.Create(myForm);
myMemo.Parent := myForm;
myMemo.Width := myForm.width;
myMemo.Height := myForm.Height;
try
GetMessBody(myMemo);
if AreHeadersHid(myMemo) then
ADo('ShowHeaders');
GetMessBody(myMemo);
Refs := GetRefs(myMemo);
myMemo.Clear;
myMemo.Lines.Add(Refs);
ParentID := GetParent(Refs);
ClearClipboard;
myMemo.Clear;
myMemo.Lines.Add(ParentID);
myMemo.SelectAll;
myMemo.CopyToClipboard;
if AreHeadersHid(myMemo) then
ADo('ShowHeaders');
finally
myform.free;
PostKey(Ord('V'),false,false,true,false,false,false,false,false);
//comment out the following line if you want to see the Find Message-ID window:
PostKey(13,false,false,false,false,false,false,false,false);
Ado('FindMessageID');
end;
End.