🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
4 messages
4 total messages Started by Michel Drach Mon, 07 Jun 2004 15:11
[Dialog] Scrip that is not working??!
#149502
Author: Michel Drach
Date: Mon, 07 Jun 2004 15:11
234 lines
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 
Re: [Dialog] Scrip that is not working??!
#149508
Author: MLC
Date: Mon, 07 Jun 2004 18:31
20 lines
2077 bytes
lunedì 07/giu/2004 _Michel Drach_ ha scritto:

> 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?

Hi,
it is supposed to work one by one. In other words, you can't select many
messages and have they saved all at once. You have to press your
hotkey/button for the script on every message yoy want to save.
However, messages with the same subject will be saved in the same file if
yor choice is fileUnique=1.

I'm sorry but I'm not able to keep track of a multiple selection.

-- 
Maria Luisa C - 07/06/04 20.17.26
Re: [Dialog] Scrip that is not working??!
#149513
Author: Michel Drach
Date: Mon, 07 Jun 2004 19:57
25 lines
2284 bytes
On Mon, 7 Jun 2004 20:31:16 +0200, MLC wrote:

> lunedì 07/giu/2004 _Michel Drach_ ha scritto:
> 
>> 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?
> 
> Hi,
> it is supposed to work one by one. In other words, you can't select many
> messages and have they saved all at once. You have to press your
> hotkey/button for the script on every message yoy want to save.
> However, messages with the same subject will be saved in the same file if
> yor choice is fileUnique=1.
> 
> I'm sorry but I'm not able to keep track of a multiple selection.

First of all, thank you for your answer! :-) I think you did great job by
writing this script. My admiration,.. maybe I ask to much!!!

Sincerely,
MD
Re: [Dialog] Scrip that is not working??!
#149514
Author: MLC
Date: Mon, 07 Jun 2004 20:29
8 lines
1577 bytes
lunedì 07/giu/2004 _Michel Drach_ ha scritto:

> First of all, thank you for your answer! :-) I think you did great job by
> writing this script. My admiration,.. maybe I ask to much!!!

You're welcome, thank you :-)
-- 
Maria Luisa C - 07/06/04 22.28.08
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads