Thread View: news.software.readers
3 messages
3 total messages
Started by John E. Davis
Wed, 17 Jun 1998 00:00
Re: [slrn] kill_subject_this_group macro
Author: John E. Davis
Date: Wed, 17 Jun 1998 00:00
Date: Wed, 17 Jun 1998 00:00
75 lines
2696 bytes
2696 bytes
On 16 Jun 1998 21:28:22 GMT, Dirk Bernhardt <krid+usenet+@comnets.rwth-aachen.de>
wrote:
>I have a problem with a macro. I often kill a subject in a group (mostly
>threads I'm not intersted in). My macro goes as follows:
>
>define kill_subject_this_group ()
>{
> set_input_chars("s
t
");
> call ("create_score");
>}
>definekey ("kill_subject_this_group", "$", "article");
>
>The `^M's are actually one character (in vi, CTRL-V RET). This macro does
>not work as expected. Can you help me find the error? Thanks!
You have to distinguish between prompts that solicit a single
character and a prompt that is looking for string input. The
`create_score' function uses both types of prompts. In particular, it
does the following:
1. Prompts for a single character to get the header to score on, `s'
for subject, etc...
2. Prompts for a number representing the score. This is a string.
3. Prompts for a character that represents the scope of the score,
e.g., `t' for this newsgroup.
5. Prompts for an expiration date--- this is a string.
So, you want to use:
define kill_subject_this_group ()
{
set_input_chars ("s" % score on subject
+ "t" % this newsgroup
);
set_input_string("-9999\n" % score is -9999
+ "\n" % leave expiration time blank
);
call ("create_score");
}
Note that the `set_input_chars' function is used for the single
character responses, whereas the `set_input_string' function is used
for a multi-character prompt. Perhaps I should simplify this
interface by defining some function, e.g., set_input so that you could
do:
set_input ("s-9999\rt\r");
On the other hand, you may be able to use `ungetkey':
define kill_subject_this_group ()
{
variable s = "s-9999\rt\r";
variable i = strlen (s);
while (i)
{
i--;
ungetkey (s[i]);
}
call ("create_score");
}
Note that `ungetkey' works from the end of the string.
--John
Re: [slrn] kill_subject_this_group macro
Author: Dirk Bernhardt
Date: Wed, 17 Jun 1998 00:00
Date: Wed, 17 Jun 1998 00:00
50 lines
2057 bytes
2057 bytes
Thank you for clarifying the difference between prompts that wait for
character and string input. That helped to understand the problem, which
is the first step in solving it! :)
Your first solution did not work, unfortunateley. Slrn complains and
prints an error message:
S-Lang Error: Operation undefined for type.: Unknown Error.
I guessed that the `+' isn't defined for characters and/or strings, so I
changed your example
On 17 Jun 1998 10:11:36 GMT, John E. Davis <davis@space.mit.edu> wrote:
> define kill_subject_this_group ()
> {
> set_input_chars ("s" % score on subject
> + "t" % this newsgroup
> );
>
> set_input_string("-9999\n" % score is -9999
> + "\n" % leave expiration time blank
> );
>
> call ("create_score");
> }
to this:
define kill_subject_this_group ()
{
set_input_chars ("st"); % score on subject, this group
set_input_string("-9999\n\n"); % score is -9999, blank exp.time
call ("create_score");
}
which works for me now.
> set_input ("s-9999\rt\r");
This would be an obvious and elegant thing to have. One could think of
pushing these characters on the keyboard stack.
Thanks again, for slrn and your advice!
Krid
--
PS: Feel free to correct my English, I'm always willing to learn.
Re: [slrn] kill_subject_this_group macro
Author: John E. Davis
Date: Wed, 17 Jun 1998 00:00
Date: Wed, 17 Jun 1998 00:00
32 lines
1783 bytes
1783 bytes
On 17 Jun 1998 13:17:03 GMT, Dirk Bernhardt <krid+usenet+@comnets.rwth-aachen.de>
wrote:
>I guessed that the `+' isn't defined for characters and/or strings, so I
>changed your example
You are using an older version of slrn based upon the an obsolete
version of the slang library. 1.x versions of the library support
string concatenation via the `+' operator, e.g.,
a = "hello"; b = "world"; a = a + b;
a = "hello"; b = "world"; a += b;
a = "hello"; b = "world"; a = strcat (a, b);
all result in the same value for `a'. However, unlike `strcat', the
`+' operator also works with arrays:
variable names = ["Larry", "Curly", "Moe"];
variable hello_names, i;
hello_names = "hello " + names;
for (i = 0; i < 3; i++) message (hello_names[i]);
If you write macros, then you should upgrade to the latest version of
slang because of all the improvements in the interpreter. There are
things that can be done in slang 1.0 that are impossible in 0.99-XX
such as linked lists and arrays of function pointers.
--John
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