Article View: news.software.readers
Article #261680Re: Request help with 40tude dialog program syntax
From: Stijn De Jong
Date: Sat, 07 Jan 2017 22:57
Date: Sat, 07 Jan 2017 22:57
115 lines
6348 bytes
6348 bytes
On Sun, 8 Jan 2017 04:00:31 +0700, you wrote:
>> 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)
>
> That's correct. The server may also place additional restrictions on which
> headers and their contents. e.g. the email in the "From" header must match
> with the email used to register an account from a newsgroups provider.
Thank you JJ for confirming, as anyone who is a noob (like I am) would have
similar questions as I have, so, it's great to flesh them out for the deja
news record (should others search in the future for this topic).
>> 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.)
>
> This is a technical problem which is not well explained in Dialog's
> "Scripting" documentation page. There's a line that says "Only available in
> script called from the main GUI thread for thread safety" which refers to
> the `Application`, `Screen`, `Timer1`, and `Timer2` global variables, but
> actually, the WriteLn() function is one of them too. i.e. they are usable
> from the main thread, and the OnBeforeSendingMessage, OnBeforeSavingMessage,
> etc., are executed from a (separate) worker thread, which isn't the main
> thread.
OMG. That's complicated. I think I'll take the simple road, which is to
just remove the WriteLn altogether! :)
I just wanted to see what was happening real time without having to dig
into the log file.
I looked for an option to at least change the location of the log file.
http://dialog.datalist.org/faq/frequently_asked_questions.html
But I gave up as it doesn't seem to be an option to change the location of
the log file, and nobody else seems to have asked that question yet.
> [A] will set the result to "id1" if the first newsgroup in the Newsgroups
> header is "news.software.readers" or "alt.free.newsservers".
>
> [B] will set the result to "id1" if the first newsgroup in the Newsgroups
> header is "news.software.readers".
Oh. I get it. < slaps head >
It's amazing how you interpret differently what I interpret, but your
interpretation makes much more programming sense than does mine!
> Here's some simpler examples for the basic of StrMatch().
> These will return `true`:
> StrMatch('abc', 'abc') //"abc" is at start of "abc"
> StrMatch('abc', 'ab') //"ab" is at start of "abc"
> StrMatch('abc', 'a') //"a" is at start of "abc"
> These will return `false`:
> StrMatch('abc', 'abcd') //"abcd" is not at start of "abc"
> StrMatch('abc', 'bc') //"bc" is not at start of "abc"
> StrMatch('abc', 'b') //"b" is not at start of "abc"
> StrMatch('abc', 'c') //"c" is not at start of "abc"
Thanks for those illustrative examples, which make sense.
I added them, verbatim, a comments to my version of the code, for future
reference.
>> I just added your new "string contains" function, and a call to it as
>> follows. If this post works, then the vignette below worked.
> [snip]
>> 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 := '';
>
> The first if-then statement (or command) would work as expected, but the
> second and the third ones may fail if a message is posted to multiple
> newsgroups because they still use the StrMatch() function. i.e.
Thanks for that clarification and correction that StrMatch is problematic
even if it only contains one newsgroup because it depends on the order of
the newsgroups in the Newsgroup: header line.
I'll modify my version of the code so that it uses StrContains instead of
StrMatch (which seems far too limited for this purpose so I wonder why the
original contained StrMatch in the first place).
function StrContains(const Str: string; const Pattern: string): boolean;
begin
result:= pos(Pattern, Str) > 0;
end;
function NewsGroup2Identity(newsgroup: String): String;
begin
if StrContains(newsgroup, 'news.software.readers') or
StrContains(newsgroup, 'alt.free.newssservers') then
result := 'id1'
else if StrContains(newsgroup, 'alt.comp.os.windows-10') then
result := 'id2'
else if StrContains(newsgroup, 'alt.os.linux') then
result := 'id3'
else
result := '';
end;
> PS) The scripting language used by Dialog is Delphi which is based on the
> Pascal programming language. You can use Free Pascal Compiler (FPC)
> documentations if you have any interest on understanding the Pascal
> programming language. You can also ask Pascal/Delphi related question to
> comp.lang.pascal.delphi.misc.
Thank you for that advice.
I've added it as a comment to the code I maintain for future use.
Technical Details
Message-ID:
<o4rrp6$1uh9$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-mailReferences:
<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> <o4p63d$1jiv$1@gioia.aioe.org> <2nmhjmd7yn5z.7aee9qvl2s4h.dlg@40tude.net>Show Full Headers
Complete Article Headers
Message-ID: <o4rrp6$1uh9$1@gioia.aioe.org> Subject: Re: Request help with 40tude dialog program syntax Date: Sat, 07 Jan 2017 22:57:43 +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> <o4p63d$1jiv$1@gioia.aioe.org> <2nmhjmd7yn5z.7aee9qvl2s4h.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: 115 NNTP-Posting-Host: hfOAoZlqGeFs4SUbLxBJ8Q.user.gioia.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Received-Body-CRC: 934408708 X-Received-Bytes: 6275