Thread View: news.software.readers
15 messages
15 total messages
Started by Rejo Zenger
Thu, 06 Jan 2000 00:00
[slrn] howto update counter in hook?
Author: Rejo Zenger
Date: Thu, 06 Jan 2000 00:00
Date: Thu, 06 Jan 2000 00:00
68 lines
3026 bytes
3026 bytes
Hi,
I'm trying to have an address in my header that is uniq at every post
that i do. I thunk i can get this by having sa number in file that gets
increased every time i do a post. The number is inserted in my address i
use to post. So, just tried a thing and came to the following, but i
have two problems...
variable Default_username;
variable Default_replyto;
Default_username = get_variable_value ("username");
Default_replyto = get_variable_value ("replyto");
define post_hook ()
{
variable cache_file = "/home/rejo/news/cache.txt";
variable file_open = fopen (cache_file, "r");
variable x;
variable y = expr x + 1;
if (file_open == NULL)
{
() = fprintf (stderr, "Unable to open %s\n", cache_file);
return -1;
}
while (-1 != fgets (&x, file_open))
{
variable a;
a = Default_username;
a = sprintf ("rejo.f"+y, a);
set_string_variable ("username", a);
variable b;
b = Default_replyto;
b = sprintf ("rejo.r"+y, b);
set_string_variable ("replyto", b);
}
() = fputs (y, file_open);
() = fclose (file_open);
return 0;
}
In the first place, how can i increase that variable in the file (see
the line "variable y = expr x + 1;" above)? Do i have to do something
externally? I tried to use expr, but that (not a surprise) didn't work.
What should i use?
And how can i get this variable inserted in the address? I now have
a = sprintf ("rejo.f"+y, a);
but that doesn't work, i guess because of the quoting. I tried all
three, but i just cannot figure out what i need...
Someone know what i should do now?
-Rejo.
--
= Rejo Zenger [Sister Ray Crisiscentrum] rejo@sisterray.xs4all.nl
= http://mediaport.org/~sister (and my_urls.html) PGP: see headers
--------------------------------------------------------------------------------
Destroy a spamhaus! http://www.xs4all.nl/~sister/mirror/sengir/spam_sites.html
Re: [slrn] howto update counter in hook?
Author: John E. Davis
Date: Thu, 06 Jan 2000 00:00
Date: Thu, 06 Jan 2000 00:00
41 lines
1938 bytes
1938 bytes
On 6 Jan 2000 23:19:50 GMT, Rejo Zenger <rejo.f0001nim@sisterray.xs4all.nl>
wrote:
>I'm trying to have an address in my header that is uniq at every post
>that i do. I thunk i can get this by having sa number in file that gets
>increased every time i do a post. The number is inserted in my address i
What about using the current time?
> variable file_open = fopen (cache_file, "r");
> variable x;
> variable y = expr x + 1;
At this point, x has no value and the statement involving y is
syntactically incorrect.
> while (-1 != fgets (&x, file_open))
> {
Perhaps you want:
y = integer (x) + 1;
> variable a;
> a = Default_username;
> a = sprintf ("rejo.f"+y, a);
Do you mean:
a = sprintf ("rejo.f%d%s", y, a);
>Someone know what i should do now?
I think that you should read the slang user's guide and study the
intrinsic function reference. You are missing some basic concepts.
See http://space.mit.edu/%7Edavis/slang1.4-doc.html for more
information.
Good luck,
--John
Re: [slrn] howto update counter in hook?
Author: Thomas Schultz
Date: Fri, 07 Jan 2000 00:00
Date: Fri, 07 Jan 2000 00:00
14 lines
1290 bytes
1290 bytes
On 07 January 2000 at 09:17 GMT, Rejo Zenger <rejo@sisterray.xs4all.nl> wrote:
> So, what i think i will do now is to have a cron entry putting the
> output of 'date +%s' in a cache-file. Then i want that output to be
> inserted in my address whenever i do a post.
This cache-file is not really necessary -- if you have a recent
version of slang, you can open a pipe to "date" (using the popen()
command) and read from it instead.
--
Kind regards,
Thomas Schultz
Re: [slrn] howto update counter in hook?
Author: Rejo Zenger
Date: Fri, 07 Jan 2000 00:00
Date: Fri, 07 Jan 2000 00:00
79 lines
3463 bytes
3463 bytes
++ <slrn87aa5f.nas.davis@aluche.mit.edu>; John E. Davis:
>>I'm trying to have an address in my header that is uniq at every post
>>that i do. I thunk i can get this by having sa number in file that gets
>>increased every time i do a post. The number is inserted in my address i
>
>What about using the current time?
Well, at first i did not think it was a good idea, however i have
changed my mind and i'm trying to get the date and time in my address.
So, what i think i will do now is to have a cron entry putting the
output of 'date +%s' in a cache-file. Then i want that output to be
inserted in my address whenever i do a post.
Instead of rejo+f@sisterray.xs4all.nl, the address should be something
like rejo+f947236200@sisterray.xs4all.nl. The editted script i have now
is:
---------------------------------------------------------------------------
variable Default_username;
variable Default_replyto;
Default_username = get_variable_value ("username");
Default_replyto = get_variable_value ("replyto");
define post_hook ()
{
variable cache_file = "/home/rejo/news/cache.txt";
variable file_open = fopen (cache_file, "r");
variable x;
if (file_open == NULL)
{
() = fprintf (stderr, "Unable to open %s\n", cache_file);
return -1;
}
while (-1 != fgets (&x, file_open))
{
variable a;
a = Default_username;
a = sprintf ("rejo.f%d%s", x, a);
set_string_variable ("username", a);
}
() = fclose (file_open);
return 0;
}
---------------------------------------------------------------------------
> Do you mean:
>
> a = sprintf ("rejo.f%d%s", y, a);
I'mn not sure here as i don't understand exactly what this will do, i
will try to look it up in the manual first before replying to this one.
>See http://space.mit.edu/%7Edavis/slang1.4-doc.html for more
>information.
Which is, i guess, the same as /usr/doc/package/slang/slang.txt?
Thanks a lot for your help... it's pretty hard to read stuff for someone
that doesn't have any experience with coding... :-)
-Rejo.
--
= Rejo Zenger [Sister Ray Crisiscentrum] rejo@sisterray.xs4all.nl
= http://mediaport.org/~sister (and my_urls.html) PGP: see headers
--------------------------------------------------------------------------------
Destroy a spamhaus! http://www.xs4all.nl/~sister/mirror/sengir/spam_sites.html
Re: [slrn] howto update counter in hook?
Author: Thomas Schultz
Date: Sat, 08 Jan 2000 00:00
Date: Sat, 08 Jan 2000 00:00
17 lines
1716 bytes
1716 bytes
On 08 January 2000 at 05:17 GMT, John E. Davis <davis@space.mit.edu> wrote: > On 7 Jan 2000 16:58:27 GMT, Thomas Schultz <tststs@gmx.de> wrote: >> This cache-file is not really necessary -- if you have a recent >> version of slang, you can open a pipe to "date" (using the popen() >> command) and read from it instead. > Using the _time () intrinsic function is better. Other alternatives > include gmtime() and localtime(). Thank you for pointing this out. The last time I needed a similar function in one of my macros, the gmtime() and localtime() intrinsics did not yet exist, so I decided it would be easier to use "date" than to break down the output of _time() myself. I probably should look at changes.txt more carefully when updating slang. -- Thomas Schultz <tststs@gmx.de>
Re: [slrn] howto update counter in hook?
Author: Tomasz 'tsca' Sienicki
Date: Sat, 08 Jan 2000 00:00
Date: Sat, 08 Jan 2000 00:00
12 lines
1121 bytes
1121 bytes
Rejo Zenger wrote [in <slrn87a8om.16h.rejo.f0001nim@sisterray.xs4all.nl>]: > I thunk i can get this by having sa number in file that gets increased > every time i do a post. I once tried this. See <http://www.geocities.com/tsca.geo/slang.html#counter> -- tsca
Re: [slrn] howto update counter in hook?
Author: John E. Davis
Date: Sat, 08 Jan 2000 00:00
Date: Sat, 08 Jan 2000 00:00
12 lines
1439 bytes
1439 bytes
On 8 Jan 2000 08:30:59 GMT, Rejo Zenger <rejo@sisterray.xs4all.nl> wrote: >But, for what i would need it, i would probably have to use unix_ctime. unix_ctime does not exist in more recent versions of slang. It has been renamed to ctime. The 1.3.x versions support the following time functions: _time, ctime, gmtime, localtime, time, times, as well as tic, and toc. --John
Re: [slrn] howto update counter in hook?
Author: John E. Davis
Date: Sat, 08 Jan 2000 00:00
Date: Sat, 08 Jan 2000 00:00
12 lines
1188 bytes
1188 bytes
On 7 Jan 2000 16:58:27 GMT, Thomas Schultz <tststs@gmx.de> wrote: >This cache-file is not really necessary -- if you have a recent >version of slang, you can open a pipe to "date" (using the popen() >command) and read from it instead. Using the _time () intrinsic function is better. Other alternatives include gmtime() and localtime(). --John
Re: [slrn] howto update counter in hook?
Author: Rejo Zenger
Date: Sat, 08 Jan 2000 00:00
Date: Sat, 08 Jan 2000 00:00
41 lines
2522 bytes
2522 bytes
++ <slrn87f64r.sh9.davis@aluche.mit.edu>; John E. Davis:
>>But, for what i would need it, i would probably have to use unix_ctime.
>
>unix_ctime does not exist in more recent versions of slang. It has
>been renamed to ctime. The 1.3.x versions support the following time
>functions: _time, ctime, gmtime, localtime, time, times, as well as
>tic, and toc.
Ok. Still i have a problem:
S-Lang Error: Type Mismatch: Expecting Integer_Type, found String_Type
As this is what i have:
variable Default_username;
Default_username = get_variable_value ("username");
define _time ();
define post_hook ()
{
set_string_variable ("username", sprintf ("rejo+f%d", _time ()));
}
I did have a look at slang.txt and slangfun.txt, but still don't see
what i should use here. I guess it goed wrong in the part after sprintf,
but slangfun.txt tells me there should be a String_Type there, but the
error is talking about Integer_Type. So what to do now?
-Rejo.
--
= Rejo Zenger [Sister Ray Crisiscentrum] rejo@sisterray.xs4all.nl
= http://mediaport.org/~sister (and my_urls.html) PGP: see headers
--------------------------------------------------------------------------------
Destroy a spamhaus! http://www.xs4all.nl/~sister/mirror/sengir/spam_sites.html
Re: [slrn] howto update counter in hook?
Author: Rejo Zenger
Date: Sat, 08 Jan 2000 00:00
Date: Sat, 08 Jan 2000 00:00
21 lines
1996 bytes
1996 bytes
++ <slrn87di3e.qtm.davis@aluche.mit.edu>; John E. Davis: >>This cache-file is not really necessary -- if you have a recent >>version of slang, you can open a pipe to "date" (using the popen() >>command) and read from it instead. > >Using the _time () intrinsic function is better. Other alternatives >include gmtime() and localtime(). But, for what i would need it, i would probably have to use unix_ctime. As it the output will be used in an address and should be uniq everytime, i guess a notation of seconds from 1970 would fit best. -Rejo. -- = Rejo Zenger [Sister Ray Crisiscentrum] rejo@sisterray.xs4all.nl = http://mediaport.org/~sister (and my_urls.html) PGP: see headers -------------------------------------------------------------------------------- Destroy a spamhaus! http://www.xs4all.nl/~sister/mirror/sengir/spam_sites.html
Re: [slrn] howto update counter in hook?
Author: John E. Davis
Date: Sun, 09 Jan 2000 00:00
Date: Sun, 09 Jan 2000 00:00
15 lines
1608 bytes
1608 bytes
On 9 Jan 2000 10:44:06 GMT, Rejo Zenger <rejo@sisterray.xs4all.nl>
wrote:
> set_string_variable ("replyto", sprintf ("rejo+f%d%s",
> _time, "@sisterray.xs4all.nl" ()));
The problem is that you are treating the literal string
"@sisterray.xs4all.nl" as a function call. Change this to:
set_string_variable ("replyto", sprintf ("rejo+f%d%s",
_time (),
"@sisterray.xs4all.nl"));
--John
Re: [slrn] howto update counter in hook?
Author: Rejo Zenger
Date: Sun, 09 Jan 2000 00:00
Date: Sun, 09 Jan 2000 00:00
18 lines
2165 bytes
2165 bytes
++ <slrn87hmle.hu.davis@aluche.mit.edu>; John E. Davis: >The problem is that you are treating the literal string >"@sisterray.xs4all.nl" as a function call. Change this to: [...] Sometimes i feel stupid. I read about the functions and the variables that can be included within the parenthesis, but just didn't realize that was the problem i had. Thanks a lot. -Rejo. -- = Rejo Zenger [Sister Ray Crisiscentrum] rejo@sisterray.xs4all.nl = http://mediaport.org/~sister (and my_urls.html) PGP: see headers -------------------------------------------------------------------------------- Destroy a spamhaus! http://www.xs4all.nl/~sister/mirror/sengir/spam_sites.html
Re: [slrn] howto update counter in hook?
Author: John E. Davis
Date: Sun, 09 Jan 2000 00:00
Date: Sun, 09 Jan 2000 00:00
17 lines
1535 bytes
1535 bytes
On 8 Jan 2000 23:38:10 GMT, Rejo Zenger <rejo@sisterray.xs4all.nl>
wrote:
> define _time ();
> define post_hook ()
> {
> set_string_variable ("username", sprintf ("rejo+f%d", _time ()));
> }
The version of slang that you are using does not support the _time
intrinsic. What you are doing above is defining a function called
_time that does nothing and then you are using it as if it returns an
integer. My advice is to upgrade to the latest version of slang
(1.3.10) and then omit the `define _time ();' line.
--John
Re: [slrn] howto update counter in hook?
Author: Rejo Zenger
Date: Sun, 09 Jan 2000 00:00
Date: Sun, 09 Jan 2000 00:00
34 lines
2669 bytes
2669 bytes
++ <slrn87gmub.5a0.rejo@sisterray.xs4all.nl>; Rejo Zenger:
>Yes! That did the trick. I will probably still have several things to
>check, but the main thing is working. Upgrading to 1.3.10 and
>re-compiling slrn did it. Thanks for your help and patience.
One last thing... it works for the 'username' field, but hwo can i do
the same for the 'replyto'? This is not working:
set_string_variable ("replyto", sprintf ("rejo+f%d%s", _time, "@sisterray.xs4all.nl" ()));
and it will give me the error
S-Lang Error: Syntax Error: Expecting ')': found '(', line 10, file: /home/rejo/news/addresses.sl
S-Lang Error: Syntax Error: called from line 10, file: /home/rejo/news/addresses.sl
Can't i have those two items next to each other?
Also, i read (that goes without saying) about the Sprintf and sprintf
functions. I do understand the difference, but i don't understand the
reason for this difference. Why would one want to specify the exact
numbers of those items?
Thanks a lot in advane, -Rejo.
--
= Rejo Zenger [Sister Ray Crisiscentrum] rejo@sisterray.xs4all.nl
= http://mediaport.org/~sister (and my_urls.html) PGP: see headers
--------------------------------------------------------------------------------
Destroy a spamhaus! http://www.xs4all.nl/~sister/mirror/sengir/spam_sites.html
Re: [slrn] howto update counter in hook?
Author: Rejo Zenger
Date: Sun, 09 Jan 2000 00:00
Date: Sun, 09 Jan 2000 00:00
17 lines
1983 bytes
1983 bytes
++ <slrn87gc68.tln.davis@aluche.mit.edu>; John E. Davis: >integer. My advice is to upgrade to the latest version of slang >(1.3.10) and then omit the `define _time ();' line. Yes! That did the trick. I will probably still have several things to check, but the main thing is working. Upgrading to 1.3.10 and re-compiling slrn did it. Thanks for your help and patience. -Rejo. -- = Rejo Zenger [Sister Ray Crisiscentrum] rejo@sisterray.xs4all.nl = http://mediaport.org/~sister (and my_urls.html) PGP: see headers -------------------------------------------------------------------------------- Destroy a spamhaus! http://www.xs4all.nl/~sister/mirror/sengir/spam_sites.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads