🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #27328

Re: Using S-Lang macros in slrn

#27328
From: John E. Davis
Date: Wed, 30 Oct 1996 00:00
107 lines
4101 bytes
On 25 Oct 1996 21:25:04 GMT, Vikas Agnihotri <vikas@insight.att.com>
wrote:
>I was looking at the various macros in the default slrn.sl and README.slang
>files in the slrn 0.9.1 distribution and I saw a feature I liked
>i.e. the % key-mapping to  tag articles selected based on user-inputed
>'regexp's. 
>  It works fine as written but now what if I want to save all those
>articles I just 'tagged'.
>  I see two options: Either there needs to be a feature to 'save' articles
>marked '*' i.e. tagged OR
>  the SLANG macros allowed in slrn need to be extended (specifically,
>the set_header_flags() function ) to allow the matching articles
>to be marked with a '#' i.e. numerically tagged so that then
>the default 'o' command will ask if i want to save these numerically
>tagged articles.

You have the right idea.  The example I presented marks articles with
the `*' attribute.  The thing that you want to do is to save such
articles.  To do this, you will have to move to the top of the header
list via:

   call ("art_header_bob");
   
Then you want to loop over all `*' tagged articles via the
`next_tagged_header' function, e.g.,

  while (next_tagged_header ())
    {
       % save article....
    }
    
Of course this will not work if the very first header is tagged.  So
before that add:

   if (get_header_flags () & HEADER_TAGGED)
     {
       % save article...
     }
     
I am not exactly sure how you want to save the article.  If you want
to save each article in separate files, use the `save_current_article'
function.  You will have to create a unique filename each time you call
it, e.g., by using integer that you bump up with each save.  For
example, 

define save_to_file (dir, count)
{
   variable file;
   
   file = strcat (dir, string (count));
   save_current_article (file);
}

define save_star_tagged ()
{
   variable dir, count;
   
   dir = make_home_filename ("News/Savedir/");
   
   call ("art_header_bob");
   
   
   count = 0;
   if (get_header_flags () & HEADER_TAGGED)
     {
	save_to_file (dir, count);
	count++;
     }
   
   while (next_tagged_header ())
     {
	save_to_file (dir, count);
	count++;
     }
}

   
The problem with this approach is that the save_to_file uses the
`save_current_article' intrinsic function.  This function will create
a new file with the specified name each time it is called.  This means
that it lacks the ability to append.  

If you want to append to a file you have several choices:

   1.  Wait for the next version of slrn where there will be an
       intrinsic that can append.
       
   2.  Instead of tagging the articles with a `*', use a numerical
       tag.  Then simply use the `call ("tag_header")' to numerically
       tag.  (Yuk.  Unfortunately the naming of the functions is less
       than optimal.).  After all headers have been tagged, use
       `call("save")' which will prompt you to save the tagged headers.
       
   3.  Use the low level slang functions such as fopen, fputs, fgets,
       and fclose to append the file after saving it.
       
Only a few people have requested new functions when 0.9.0 came out.
Those functions were incorporated into 0.9.1.  Hopefully you will see
more support in 0.9.2.
-- 
John E. Davis                   Center for Space Research/AXAF Science Center
617-258-8119                    MIT 37-662c, Cambridge, MA 02139
http://space.mit.edu/~davis


Technical Details
Message-ID: <slrn57fl6p.d68.davis@aluche.mit.edu>
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!not-for-mail
References: <slrn572bsb.qo3.vikas@joshua.insight.att.com>

Show Full Headers
Complete Article Headers
Message-ID: <slrn57fl6p.d68.davis@aluche.mit.edu>
Subject: Re: Using S-Lang macros in slrn
Date: Wed, 30 Oct 1996 00:00:00 +0000
From: davis@space.mit.edu (John E. Davis)
References: <slrn572bsb.qo3.vikas@joshua.insight.att.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!not-for-mail
X-Deja-AN: 193342583
Organization: Center for Space Research
Reply-to: davis@space.mit.edu
Newsgroups: news.software.readers