🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #261670

Re: Request help with 40tude dialog program syntax

#261670
From: Stijn De Jong
Date: Fri, 06 Jan 2017 22:35
127 lines
6587 bytes
On Fri, 6 Jan 2017 16:57:31 +0700, you wrote:

> Good to know that it works for you.

Thank you JJ for rewriting the script so that it's useful!
You are a great Usenet citizen in that you give back to the group.

I realized, in my tests, that there was some funny stuff going on, but I
wasn't sure what the funny stuff was. 

So a few mistakes I made were:
a. I couldn't get the string match on multiple newsgroups working
   (Now I know why, based on what you wrote below!)
b. I couldn't add certain headers (e.g., NNTP-Posting-Host).
   (I suspect that's an NNTP RFC spec that prevents that from working)
c. I couldn't get a WriteLn(Add_Header) to write to the message window.
   (The WriteToLog worked but it wrote to the log file instead.)

It's clear you tested the script well since your logic is more flexible
than the original two scripts were.

1. You placed the remove_headers variable in both a syntactically correct
and logically correct location!
2. You added the capability to crosscheck based on any one, two, or three
combinations of identity, and/or server, and/or newsgroup.
3. You added the ability to add headers (and you resolved the non-intuitive
requirement for pound13-pound10 CR+LF syntax), particularly for multiple
headers being added.
4. You added variables so that reasonable defaults exist if someone does
not wish to change any of the variables.
5. And you provided useful working syntactical examples, so that noobs
(like I am) can more easily intuit settings that are syntactically correct!

Overall, your efforts should help anyone, and particularly those who have
different requirements for news/email for personal versus business needs.

> One thing you should know is that the `StrMatch()` function compares the
> `Pattern` argument against the start of the `str` argument. So when you use
> the function to compare the `newsgroup` argument in the
> `NewsGroup2Identity()` function, and the message was posted to multiple
> newsgroups, that function can only check the first listed newsgroup.

Thank you for pointing that out because that string-match was driving me
nuts!

So are you saying that, functionally, these two command are, in effect,
exactly the same functionality?
A.   if (StrMatch (newsgroup, 'news.software.readers') or 
         StrMatch (newsgroup, 'alt.free.newsservers')) then
         result := 'id1'
B.   if StrMatch(newsgroup, 'news.software.readers') then
         result := 'id1'

Is it that both A & B above will only set the result to "id1" if
"news.software.readers" is the first newsgroup in the outgoing Newsgroups:
header?

Asked another way, are you saying that only the first outgoing header line
below will be matched by either of the two commands above?
 Newsgroups: news.software.readers,alt.free.newsservers
 Newsgroups: alt.free.newsservers,news.software.readers

> For example, suppose you're using the function like so:
> 
>   if StrMatch(newsgroup, 'news.software.readers') then //...
> 
> If the contents of the newsgroup variable is:
> 
>   alt.test, news.software.readers
> 
> Then the above check will never match.

I see. You just answered my questions above!
Thank you for being clear. 
I have now modified the comments so that others aren't confused like I was.
 
> For the sake of flexibility, here's a function that work like `StrMatch()`
> but the pattern can match anywhere in the string being searched. i.e. the
> pattern can be at start, at middle, or at end. String comparison is case
> sensitive, just like `StrMatch()` does.
> 
>   function StrContains(const Str: string; const Pattern: string): boolean;
>   begin
>     result:= pos(Pattern, Str) > 0;
>   end;
> 
> Insert it into anywhere in the script outside of any other function and use
> it just like `StrMatch()`. e.g.
> 
>   if StrContains(newsgroup, 'news.software.readers') or
>     StrContains(newsgroup, 'alt.windows7.general') then //...

I just added your new "string contains" function, and a call to it as
follows. If this post works, then the vignette below worked.

function StrContains(const Str: string; const Pattern: string): boolean;
begin
   result:= pos(Pattern, Str) > 0;
end;

function NewsGroup2Identity(newsgroup: String): String;    
// WARNING: The StrMatch function can only check the first listed
newsgroup!  
// Define a StrContains function if you want to match either/or newsgroups!   
// function StrContains(const Str: string; const Pattern: string): boolean;
// begin
//    result:= pos(Pattern, Str) > 0;
// end;
// EXAMPLE: This StrMatch will only match the first newsgroup in the
outgoing Newsgroup header!  
// if (StrMatch (newsgroup, 'news.software.readers') or StrMatch(newsgroup,
'alt.free.newsservers')) then
// If defined, this StrContains will match either newsgroup or both in the
outgoing Newsgroup header:   
// if StrContains(newsgroup, 'news.software.readers') or
StrContains(newsgroup, 'alt.free.newssservers') then 
begin
    if StrContains(newsgroup, 'news.software.readers') or
StrContains(newsgroup, 'alt.free.newssservers') then 
    result := 'id1'
  else if StrMatch(newsgroup, 'alt.comp.os.windows-10') then
    result := 'id2'
  else if StrMatch(newsgroup, 'alt.os.linux') then
    result := 'id3'
  else
    result := '';
end;    
Technical Details
Message-ID: <o4p63d$1jiv$1@gioia.aioe.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.(126883).mbox.7z!not-for-mail
References: <o491jh$7jr$1@gioia.aioe.org> <o4926s$933$1@gioia.aioe.org> <o492qg$a9k$1@gioia.aioe.org> <1ibo1gzmbqy5b.33119bupvh2q.dlg@40tude.net> <o4h57j$hhe$6@news.mixmin.net> <o4jr33$u80$1@news.mixmin.net> <7vpx5y09pu98.1sukl5d600sda$.dlg@40tude.net> <o4mllr$1tes$1@gioia.aioe.org> <o4mmls$1ufs$1@gioia.aioe.org> <o4mp2u$1mp$1@gioia.aioe.org> <o4mqdl$3dn$1@gioia.aioe.org> <18a15xlqpx8bu$.p7s6f5qnpimv$.dlg@40tude.net>

Show Full Headers
Complete Article Headers
Message-ID: <o4p63d$1jiv$1@gioia.aioe.org>
Subject: Re: Request help with 40tude dialog program syntax
Date: Fri, 06 Jan 2017 22:35:25 +0000
From: Stijn De Jong <stijndekoning@nlnet.nl>
References: <o491jh$7jr$1@gioia.aioe.org> <o4926s$933$1@gioia.aioe.org> <o492qg$a9k$1@gioia.aioe.org> <1ibo1gzmbqy5b.33119bupvh2q.dlg@40tude.net> <o4h57j$hhe$6@news.mixmin.net> <o4jr33$u80$1@news.mixmin.net> <7vpx5y09pu98.1sukl5d600sda$.dlg@40tude.net> <o4mllr$1tes$1@gioia.aioe.org> <o4mmls$1ufs$1@gioia.aioe.org> <o4mp2u$1mp$1@gioia.aioe.org> <o4mqdl$3dn$1@gioia.aioe.org> <18a15xlqpx8bu$.p7s6f5qnpimv$.dlg@40tude.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.(126883).mbox.7z!not-for-mail
Newsgroups: news.software.readers,alt.windows7.general,alt.os.linux
Organization: Aioe.org NNTP Server
Lines: 127
NNTP-Posting-Host: qZAErkZZi/JIiFPU0VdZBw.user.gioia.aioe.org
X-Complaints-To: abuse@aioe.org
X-Notice: Filtered by postfilter v. 0.8.2
X-Received-Body-CRC: 829745519
X-Received-Bytes: 6479