Article View: news.software.readers
Article #149502[Dialog] Scrip that is not working??!
From: Michel Drach
Date: Mon, 07 Jun 2004 15:11
Date: Mon, 07 Jun 2004 15:11
234 lines
7023 bytes
7023 bytes
I have inserted this script (see***) under Custom Scripts. I have marked 3
posts from the thread and than run the script but I as a result I get only
first message from the thread saved. For the fileUnique I put 1 and for
allHeaders = false; I expected to get one long text file for all messages
from the thread that I marked merged in one file. But I get only first
message from thread! What is wrong?
Please help,
MD
(***)
Program FileSubject; //v0.2 by MLC
uses Forms, StdCtrls, Textfile;
//---------------------------- Settings
---------------------------------//
const
path = 'C:\Save\';
// write the path of the folder where you want the file to be created
// notice that the last character must be a back slash \
fileUnique = 1; // possible values: 1 or 0
// If fileUnique = 1 every Subject will have a unique file
// and every follow-up will be added in this same file.
// if fileUnique = 0 every message will be saved in a different file
// (Subject.txt, Subject[01].txt, Subject[02].txt,...).
allHeaders = false; // all headers saved? true/false.
// If false the saved headers are only From, Subject, Newsgroups, Date,
Message-ID.
//------------------------ End of Settings -----------------------------//
//(you don't need to change anything else in this script)
type
TNoChars=set of Char;
var
FileHandle: Integer;
fileName, temp: string;
areHid: boolean;
myForm: TForm;
myMemo: TMemo;
function GetMsgBody: string;
begin
lockdisplay;
try
myMemo.Clear;
ADo('ArticlePane');
ADo('SelectAll');
Ado('Copy');
myMemo.PasteFromClipboard;
finally
unlockdisplay;
end;
result:=myMemo.Text;
end;
function GetMsgInfo(field: string): string;
var
i: integer;
begin
i:=0;
result:='';
while i < myMemo.Lines.count-1 do
begin
if pos(field, myMemo.Lines[i])>0 then break;
i:=i+1;
end; //while
result:=myMemo.Lines[i];
end;
function GetMsgSubject: string;
var
i: integer;
begin
i:=0;
result:='';
while i < myMemo.Lines.count-1 do
begin
if pos('Subject:', myMemo.Lines[i])>0 then break;
i:=i+1;
end; //while
result:=copy(myMemo.Lines[i],10,length(myMemo.Lines[i]));
end;
function DelSign(sSign : string; sString : string): string;
begin
result:=StringReplace(sString, sSign, '', [rfReplaceAll]);
end;
function Adjust(s: string): string;
var
i: integer;
noChars: TNoChars;
begin
if copy(s,1,3)='Re:' then
s:=copy(s, 5, length(s)-1)
else if (copy(s,1,2)='R:') then
s:=copy(s, 4, length(s)-1);
noChars:=[':', '/', '\', '*', '|', '<', '>', '?', '"'];
i:=1;
while (i<=length(s)) do
begin
if s[i] in noChars then
begin
s:=DelSign(s[i], s);
continue;
end;
i:=i+1;
end;
result:=s;
end;
function ChangeName(var file: string): string;
var
len, digits: integer;
fn, base, digitsStr: string;
begin
fn:=ExtractFileName(file);
len:=length(fn);
base:=copy(fn, 1, len-7);
digitsStr:='';
digitsStr:=copy(fn, len-6, 2);
digits:=StrToInt(digitsStr);
digits:=digits+1;
if length(IntToStr(digits))=1 then digitsStr:='0'+IntToStr(digits)
else digitsStr:=IntToStr(digits);
file:=path+base+digitsStr+'].txt';
if FileExists(file) then result:=ChangeName(file)
else result:=file;
end;
function AreHeadHid: boolean;
var i: integer;
begin
result := true;
if myMemo.Lines.count > 10 then
begin
i:=0;
while (i < myMemo.Lines.count-1) and result do
begin
i:= i+1;
result := pos('Newsgroups: ', myMemo.Lines.strings[i])=0;
end; //while
end; //if
end;
procedure BuildMyMemo;
begin
myMemo:=tMemo.Create(myForm);
myMemo.parent:=myForm;
myMemo.width := Application.Mainform.width;
end;
procedure WriteF;
var
ps: string;
f: TextFile;
begin
temp:=Adjust(GetMsgSubject);
ps:=path;
if (ps[length(ps)]<>'\') then
begin
writeln(ps[length(ps)-1]);
Application.MessageBox('your path doesn''t end with \ ', 'Error !',
1);
exit;
end;
if DirectoryExists(path) then
fileName:=path+temp+'.txt'
else
begin
Application.MessageBox('your path doesn''t exist!', 'Error !', 1);
exit;
end;
case fileUnique of
1:
begin
myMemo.Lines.Add(#13+#10+StringOfChar('*', 75)+#13+#10+#13+#10);
AssignFile(f, fileName);
if fileexists(filename) then append(f)
else rewrite(f);
TextWrite(f, myMemo.text);
CloseFile(f);
end;
0:
begin
if (FileExists(fileName)) then
begin
fileName:=path+temp+'[00].txt';
fileName:=ChangeName(fileName);
end;
FileHandle := FileCreate(fileName);
FileWrite(FileHandle, myMemo.text, length(myMemo.text));
FileClose(FileHandle);
end;
else
Application.MessageBox('fileUnique must be 0 or 1', 'Error !', 1);
end;
end;
Begin
myForm:=TForm.Create(nil);
temp:='';
lockdisplay;
try
BuildMyMemo;
GetMsgBody;
areHid:=AreHeadHid;
if areHid then ADo('ShowHeaders');
GetMsgBody;
if not allHeaders then
begin
temp:=GetMsgInfo('From:')+#13#10+GetMsgInfo('Subject:')+#13#10+GetMsgInfo('Newsgroups:');
temp:=temp+#13#10+GetMsgInfo('Date:')+#13#10+GetMsgInfo('Message-ID:')+#13#10+#13#10;
ADo('ShowHeaders');
temp:=temp+GetMsgBody;
myMemo.Text:=temp;
ADo('ShowHeaders');
end;
WriteF;
if areHid then Ado('ShowHeaders');
finally
unlockdisplay;
myForm.free;
end;
End.
--MariaLuisa C
Technical Details
Message-ID:
<yztpgbchluwh$.a4ho88tstomb.dlg@40tude.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.sjc.giganews.com!border2.nntp.sjc.giganews.com!border1.nntp.sjc.giganews.com!nntp.giganews.com!news.moat.net!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!CARNet.hr!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <yztpgbchluwh$.a4ho88tstomb.dlg@40tude.net> Subject: [Dialog] Scrip that is not working??! Date: Mon, 7 Jun 2004 17:11:04 +0200 From: Michel Drach <mursa5@hotmail.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.sjc.giganews.com!border2.nntp.sjc.giganews.com!border1.nntp.sjc.giganews.com!nntp.giganews.com!news.moat.net!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!CARNet.hr!not-for-mail Newsgroups: news.software.readers Organization: CARNet, CROATIA Lines: 234 NNTP-Posting-Host: cmung1318.cmu.carnet.hr Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: bagan.srce.hr 1086621281 30916 193.198.133.48 (7 Jun 2004 15:14:41 GMT) X-Complaints-To: abuse@carnet.hr NNTP-Posting-Date: Mon, 7 Jun 2004 15:14:41 +0000 (UTC) User-Agent: 40tude_Dialog/2.0.12.1