🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #128719

Re: [Dialog] Customising Posts

#128719
From: Alain GUERIN
Date: Wed, 16 Jul 2003 03:59
218 lines
9391 bytes
Hello,

On Tue, 15 Jul 2003 22:37:09 +0200, Jarrod Cifer wrote:

> Alain GUERIN, upon reaching Nirvana, postulated:
> 
>> I believed only you is asking for it :-) 
> 
>> But, as buggy scripts are, perhaps, more difficult to copy into Wiki (after
>> my own experience), I prefer wait a bit, just to be sure there is no big
>> bug.
> 
> I finally got around to testing(Sorry for taking so long), but while trying
> to compile I get an error message in this line
> 
>> IF Odd(maxlength) THEN
> 
>> Failed when compiling
>> [Error] (57:12): Unknown identifier 'Odd'
> 
> Suggestions?

Add this function in your script before the procedure Buildquotedbox.


function Odd(Value:integer): boolean;
begin
   result := value mod 2 <>  0
end;

and also a new version that do not treat a single marked line, One title
alone on an empty box has no reason (or at least can be build by hand) and
it avoids to build this kind of empty box  only because, you use the "magic"
character in the beginning of a line in a post without any whish to have a
box. (I has this "bug" in a post where I emphasized a word with square
brackets '['...']' and has the surprise to see many stars  around and under
the word ;-) 


procedure Buildquotedbox(VAR MessageQB : TStringlist);

var
   firstline : integer;
   lastline : integer;
   LineIndex : integer;
   BoxIndex : integer;
   linelength : integer;
   maxlength : integer;
   spaces : integer;
   newline : string;
   CenterCustomQuoteChar : CHAR;                           
   LeftAlignCustomQuoteChar : CHAR;
   HorizontalborderChar : CHAR;  
   VerticalBorderChar : CHAR;
   LeftTopBottomRightChar : CHAR;
   RightTopBottomLeftChar : CHAR;
   Proceed : boolean;
            
   
BEGIN
   LineIndex:=0;
   CenterCustomQuoteChar := '|';
   HorizontalborderChar := '*';
   VerticalBorderChar := '*';
   LeftTopBottomRightChar := '*';
   RightTopBottomLeftChar := '*';
   WHILE LineIndex < MessageQB.count DO
   BEGIN
      IF pos(CenterCustomQuoteChar, MessageQB.Strings[LineIndex])=1 THEN
      BEGIN
      	 firstline:=LineIndex;
      	 maxlength :=length(MessageQB.Strings[LineIndex]);
      	 LineIndex:=LineIndex+1;                 
         Proceed := LineIndex < MessageQB.count;
      	 IF Proceed THEN
      	    Proceed := (pos(CenterCustomQuoteChar,
MessageQB.Strings[LineIndex])=1);
      	 WHILE Proceed DO
      	 BEGIN
      	    IF length(MessageQB.Strings[LineIndex]) > maxlength THEN
      	       maxlength :=length(MessageQB.Strings[LineIndex]);
            LineIndex:=LineIndex+1;
      	    Proceed := LineIndex < MessageQB.count;
      	    IF Proceed THEN
      	       Proceed := (pos(CenterCustomQuoteChar,
MessageQB.Strings[LineIndex])=1)
      	 END;
      	 lastline := LineIndex-1;
      	 IF lastline <> firstline THEN
         BEGIN
            spaces := (maxlength+1) div 2;
      	{proceed title}
            newline := MessageQB.Strings[firstline];
      	    {delete custom char}
            delete(newline,1,1);
            linelength := length(newline);
            IF Odd(linelength) THEN                                                                   
               newline :=
LeftTopBottomRightChar+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2)+
                           newline+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2 +2)+RightTopBottomLeftChar
            ELSE
               newline :=
LeftTopBottomRightChar+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2)+
                           newline+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2+1)+RightTopBottomLeftChar;         
            MessageQB.delete(firstline);
            MessageQB.insert(firstline,newline);
        {procrrd box}
            FOR BoxIndex := firstline+1 to lastline DO
            BEGIN
               newline := MessageQB.Strings[BoxIndex];
               delete(newline,1,1);
               linelength := length(newline);
         	    IF Odd(linelength) THEN
      	          newline := padr(newline,linelength+(spaces-(linelength div
2)))
      	       ELSE
         	       newline := padr(newline,linelength+spaces-(linelength div
2)+1);
         	    newline := VerticalBorderChar+padl(newline, spaces-(linelength
div 2))+VerticalBorderChar;
               MessageQB.delete(BoxIndex);
               MessageQB.insert(BoxIndex,newline);
      	     END;
      	{proceed last box line}
         	IF Odd(maxlength) THEN
               newline :=
RightTopBottomLeftChar+Stringofchar(HorizontalborderChar,maxlength+2)+LeftTo
pBottomRightChar
            ELSE
               newline :=
RightTopBottomLeftChar+Stringofchar(HorizontalborderChar,maxlength+1)+LeftTo
pBottomRightChar;
            MessageQB.insert(lastline+1,newline);
         END
      END;
      LineIndex := LineIndex+1;
   END;
   LeftAlignCustomQuoteChar := '[';   
   LineIndex:=0;
   WHILE LineIndex < MessageQB.count DO
   BEGIN
      IF pos(LeftAlignCustomQuoteChar, MessageQB.Strings[LineIndex])=1 THEN
      BEGIN
      	 firstline:=LineIndex;
      	 maxlength :=length(MessageQB.Strings[LineIndex]);
      	 LineIndex:=LineIndex+1;                 
         Proceed := LineIndex < MessageQB.count;
      	 IF Proceed THEN
      	    Proceed := (pos(LeftAlignCustomQuoteChar,
MessageQB.Strings[LineIndex])=1);
      	 WHILE Proceed DO
      	 BEGIN
      	    IF length(MessageQB.Strings[LineIndex]) > maxlength THEN
      	       maxlength :=length(MessageQB.Strings[LineIndex]);
            LineIndex:=LineIndex+1;
      	    Proceed := LineIndex < MessageQB.count;
      	    IF Proceed THEN
      	       Proceed := (pos(LeftAlignCustomQuoteChar,
MessageQB.Strings[LineIndex])=1)
      	 END;
      	 lastline := LineIndex-1;
      	 IF lastline <> firstline THEN
      	 BEGIN
      	{proceed title}
       	    newline := MessageQB.Strings[firstline];
      	 {delete custom char}
      	    delete(newline,1,1);
      	    linelength := length(newline);
      	    IF Odd(linelength) THEN                                                                   
               newline :=
LeftTopBottomRightChar+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2)+
                        newline+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2)+RightTopBottomLeftChar
            ELSE
               newline :=
LeftTopBottomRightChar+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2)+
                        newline+StringOfChar(HorizontalborderChar,
(Spaces*2-length(newline))DIV 2-1)+RightTopBottomLeftChar;
            MessageQB.delete(firstline);
            MessageQB.insert(firstline,newline);
        {procrrd box}
            FOR BoxIndex := firstline+1 to lastline DO
            BEGIN
               newline := MessageQB.Strings[BoxIndex];
               delete(newline,1,1);
               linelength := length(newline);
 	       newline :=
VerticalBorderChar+padr(newline,linelength+spaces*2-linelength-1)+VerticalBo
rderChar;
               MessageQB.delete(BoxIndex);
               MessageQB.insert(BoxIndex,newline);
            END;
      	{proceed last box line}
      	    IF Odd(maxlength) THEN
               newline :=
RightTopBottomLeftChar+Stringofchar(HorizontalborderChar,maxlength)+LeftTopB
ottomRightChar
            ELSE
               newline :=
RightTopBottomLeftChar+Stringofchar(HorizontalborderChar,maxlength+1)+LeftTo
pBottomRightChar;
            MessageQB.insert(lastline+1,newline);
         END
      END;
      LineIndex := LineIndex+1;
   END;
END;


-- 
A.G.
Technical Details
Message-ID: <3f14cdc0$0$4590$626a54ce@news.free.fr>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!easynet-thlon3!easynet-monga!easynet.net!proxad.net!proxad.net!feeder2-1.proxad.net!news3-1.free.fr!not-for-mail
References: <3f03353e$0$5400$626a54ce@news.free.fr> <3f03484e$0$5442$626a54ce@news.free.fr> <6tudnRrDCvmRMJ6iU-KYuQ@giganews.com> <3f03c01d$0$12435$626a54ce@news.free.fr> <QwSdnS7w_MKaep6iXTWJkQ@giganews.com> <3f05573c$0$5262$626a54ce@news.free.fr> <aWmdnTmOtq9JcZiiXTWJjw@giganews.com> <3f0683cc$0$12429$626a54ce@news.free.fr> <p-udnXlQLIyJ-4miRTvUpQ@giganews.com>

Show Full Headers
Complete Article Headers
Message-ID: <3f14cdc0$0$4590$626a54ce@news.free.fr>
Subject: Re: [Dialog] Customising Posts
Date: Wed, 16 Jul 2003 05:59:54 +0200
From: Alain GUERIN <news40@spamout-alain-guerin.com.invalid>
References: <3f03353e$0$5400$626a54ce@news.free.fr> <3f03484e$0$5442$626a54ce@news.free.fr> <6tudnRrDCvmRMJ6iU-KYuQ@giganews.com> <3f03c01d$0$12435$626a54ce@news.free.fr> <QwSdnS7w_MKaep6iXTWJkQ@giganews.com> <3f05573c$0$5262$626a54ce@news.free.fr> <aWmdnTmOtq9JcZiiXTWJjw@giganews.com> <3f0683cc$0$12429$626a54ce@news.free.fr> <p-udnXlQLIyJ-4miRTvUpQ@giganews.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.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!easynet-thlon3!easynet-monga!easynet.net!proxad.net!proxad.net!feeder2-1.proxad.net!news3-1.free.fr!not-for-mail
Newsgroups: news.software.readers
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Reply-To: news40@alain-guerin.com
Organization: NA
X-Face: '*&f@caq/y%f)QY'BcSO`EQH}'>nCphQ%q>YfG1"zCmQAa]-,^B1-<u0)r)}QS_wzU)5`a` %|NRB0OU/Q><ozTuEx.M+[fx'?9U\Ojwtt>FBPmKGeE=.(/%Gv4+w/T9UqY}e]~jQzpXe&"V84G%al +i$O,EHjhE.c[7qzp+C4VL<
User-Agent: 40tude_Dialog/2.0.5.1
Lines: 217
NNTP-Posting-Date: 16 Jul 2003 06:00:00 MEST
NNTP-Posting-Host: 81.57.20.30
X-Trace: 1058328000 news3-1.free.fr 4590 81.57.20.30:2093
X-Complaints-To: abuse@proxad.net