Article View: news.software.readers
Article #45160Re: [slrn] save.sl/selector.sl problems.
From: blue... Dawn Owens-Nicholson
Date: Sat, 05 Dec 1998 00:00
Date: Sat, 05 Dec 1998 00:00
117 lines
4750 bytes
4750 bytes
[I added the crosspost to news.software.readers since it's about slrn and
some people don't get alt.lang.s-lang.]
ras2 wrote:
> From: remov...@gmx.net (ras2)
Please ask your ISP to get a real MTA so you can filter spam and use
From: & Reply-To: as they were meant to be used.
> I feel a bit badly about asking this, but getting a clue about
> S-lang seems impossible for me, so I didn't see any other options.
The text file in slang/doc/slang.txt has been updated in the S-Lang
snapshots, and slang/doc/UPGRADE.txt file is also good.
> I often get this error: "S-Lang Error: Stack Underflow: Error
> while executing my_save", but I assume that's a platform specific
> problem and thus not relevant here.
The source of that error is the pop() in get_file_for_group(). But you
don't really need get_file_for_group() because...
> What I would like to do is to skip the group part completely, i.e.
> to not have special names for the save files, but just use the
> full group name in the same way as slrn does by default
variable
ng = current_newsgroup (),
slrn_save_name = get_variable_value ("save_directory") +
char (toupper (ng[0])) +
substr (ng, 2, -1));
should work to set that up in the variable slrn_save_name.
> (the reason I have so many groups in there, is that I often get errors when
> trying to save an article in a group that's not in the script).
Now you shouldn't.
> The only part I really need is the one that saves posts by certain authors
> into specific files [...]
I've commented on each part as it appeared in your post:
> define append_article_save (file)
> {
> [...]
I know the author of this function, and I've seen this function copied
around. Here's J.B.'s comment:
Had I known this would be used in a drop-in way, I would have handled the
questions that aren't properly handled here (try call("save") on a
collapsed thread or when there are numeric tags in the header list).
Doing all the prep work to answer these questions clutters the simplicity
quite a lot, unfortunately. If there's interest in a useful drop-in
replacement, I can write one, but otherwise just be prepared to answer
some questions sometimes.
> define get_file_for_group (group)
> {
> switch (group)
> [...]
> {pop (); group;}
Change this line to "{ group; }"--recent S-Lang versions don't need the
pop() in the default case. But the trick is you don't really need
get_file_for_group() at all.
> define my_save ()
> {
There are many ways to do what you want. I suggest a simpler version, one
possible solution:
define my_save ()
{
variable
ng = current_newsgroup (),
file = char (toupper (ng[0])) + substr (ng, 2, -1),
author = extract_article_header ("From"),
regex_file_map = Assoc_Type[String_Type],
regex = "";
% Add as many of these as you want:
% regex_file_map["author regex"] = "filename";
regex_file_map["nnnn"] = "nnnn";
regex_file_map["ras2"] = "x";
foreach (regex_file_map) using ("keys")
{
regex = ();
if (string_match (author, regex, 1))
{
file = regex_file_map[regex];
break;
}
}
file = get_variable_value ("save_directory") + "/" + file;
file = read_mini ("Append to file", file, "");
append_article_save (file);
}
definekey ("my_save", "o", "article");
Set save_directory in your slrn.rc to "/slrnsave" and this should work as
you seem to want in your posted code. In case save_directory ends in "/",
the double slash probably won't hurt.
> (hoping that this made just a bit of sense).
In the future, it might help to start with a clean slate and try to tell
other people what you want your program to do--most of the code you used
wasn't really needed. You really only needed slrn, the most recent S-Lang
snapshot (which supports associative arrays and foreach()),
append_article_save() and my_save().
Technical Details
Message-ID:
<slrn76ht7l.9s9.bluemoon@ux6.cso.uiuc.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mailReferences:
<qZ%92.84$jW4.548@news.get2net.dk>Show Full Headers
Complete Article Headers
Message-ID: <slrn76ht7l.9s9.bluemoon@ux6.cso.uiuc.edu> Subject: Re: [slrn] save.sl/selector.sl problems. Date: Sat, 05 Dec 1998 00:00:00 +0000 From: blue...@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) References: <qZ%92.84$jW4.548@news.get2net.dk> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mail X-Deja-AN: 419238824 Organization: University of Illinois at Urbana-Champaign User-Agent: slrn/0.9.5.4 (UNIX) Newsgroups: alt.lang.s-lang,news.software.readers