Thread View: news.software.readers
14 messages
14 total messages
Started by Pardoz
Tue, 15 Jul 1997 00:00
[SLRN] Help w/macro please
Author: Pardoz
Date: Tue, 15 Jul 1997 00:00
Date: Tue, 15 Jul 1997 00:00
48 lines
2066 bytes
2066 bytes
I'm trying to write a slrn macro using select_list_box to set the
non_Xbrowser variable - I want to be able to choose between starting up
my Web browser, appending the URL to a file to feed into my offline Web
browser, or appending the URL to my bookmark file, defaulting to
'append to bookmark file'.
What I've got so far looks like this:
%URL picker
define picker ()
{
variable browservbl;
variable rsp;
variable status = get_variable_value ("non_Xbrowser");
rsp = select_list_box ("Select Browser:",
"Lynx", "Bookmark", "Download", 3,
2);
if ((rsp = "Lynx")) browservbl = "lynx2.cmd %s";
if ((rsp = "Bookmark")) browservbl = "echo %s | geturl.cmd > nul";
if ((rsp = "Download")) browservbl = "echo %s | downurl.cmd > nul";
set_string_variable ("non_Xbrowser", browservbl);
call ("browse_url");
set_string_variable ("non_Xbrowser", status);
}
definekey ("picker", "U", "article");
Unfortunately it doesn't work - it pops up the "Select Browser"
box fine, but after I pick a response I get this error message: "S-Lang
Error: picker: Stack Underflow".
I'm using slrn 0.9.4.3 for OS/2.
Thanks in advance for any help.
--
RIOT, n. A popular entertainment given to the military by innocent
bystanders. (A. Bierce, _The Devil's Dictionary_)
http://www.io.com/~pardoz (Liaden Universe mailing list home page)
http://www.io.com/~pardoz/mythos.html (Mythos Adventure Archive)
Re: [SLRN] Help w/macro please
Author: Bjoern Frantzen
Date: Wed, 16 Jul 1997 00:00
Date: Wed, 16 Jul 1997 00:00
38 lines
1739 bytes
1739 bytes
Pardoz <pardoz@io.com> wrote:
> I'm trying to write a slrn macro using select_list_box to set the
>non_Xbrowser variable - I want to be able to choose between starting up
A very good idea!
> Unfortunately it doesn't work - it pops up the "Select Browser"
>box fine, but after I pick a response I get this error message: "S-Lang
>Error: picker: Stack Underflow".
You're trying to compare strings the same way you compare integers,
something like this should work;
define picker () {
variable browservbl;
variable rsp;
variable status = get_variable_value ("non_Xbrowser");
rsp = select_list_box ("Select Browser:",
"Lynx", "Bookmark", "Download", 3, 2);
if (strncmp (rsp, "Lynx", 4) == 0)
browservbl = "lynx2.cmd %s";
if (strncmp (rsp, "Bookmark", 8) == 0)
browservbl = "echo %s | geturl.cmd > nul";
if (strncmp (rsp, "Download", 8) == 0)
browservbl = "echo %s | downurl.cmd > nul";
set_string_variable ("non_Xbrowser", browservbl);
call ("browse_url");
set_string_variable ("non_Xbrowser", status);
} definekey ("picker", "U", "article");
--
-< Bj�rn >-
Re: [SLRN] Help w/macro please
Author: Pardoz
Date: Wed, 16 Jul 1997 00:00
Date: Wed, 16 Jul 1997 00:00
82 lines
4445 bytes
4445 bytes
On 16 Jul 97 02:11:20 GMT, J.B. Nicholson-Owens
<jbn@pop-a-wheelie.midwest.net> wrote:
>Pardoz <pardoz@io.com> wrote:
>> if ((rsp = "Lynx")) browservbl = "lynx2.cmd %s";
>> if ((rsp = "Bookmark")) browservbl = "echo %s | geturl.cmd > nul";
>> if ((rsp = "Download")) browservbl = "echo %s | downurl.cmd > nul";
>
>Here are some thoughts that came to my mind when I saw this code:
>
>1. I don't think you want to use double parentheses. Out of curiosity, what
> programming language uses double parentheses in the way you're using them
> here?
S-Lang apparently - at least it stopped giving me syntax errors
when I switched from a single to a double parenthesis.
>2. In S-Lang, you can't compare strings using an assignment equals sign
> ("="). You also can't use the comparative equals ("==") for strings.
> case() works on all types or you can use some string compare like
> strcmp() or string_match(). In this instance, I prefer switch()-case().
I hit on that myself when I finally dug up a recent copy of TFM to
R.
>3. You don't need to test three times since 'rsp' is not changing between
> comparisons. Once one test succeeds, make the assignment to 'rsp' and
> move on. Also, if it's not "Lynx" or "Bookmark", there's no need to test
> for "Download" since that is the only remaining choice.
At the moment, yes. It's designed to be easily extended,
particularly by people who don't necessarily know what they're doing.
>4. 'browservbl' is obviously a variable ("vbl"). You could call it
> 'browser' and it would retain all self-documenting functionality.
True. I hit on 'browservbl' to avoid potential variable name
conflicts.
>There are other ways of doing this, of course, but this jumps to my mind
>right now. By the way, are you sure you have to pipe the URL to the geturl
>and downurl commands; do they take arguments?
They do, indeed - they're a pair of REXX scripts that take an
argument from stdin and write the result to a file (geturl tarts it up
with a bit of HTML and appends it to a Lynx bookmark file, downurl just
writes to a plain text file to be fed into an offline Web page
retriever). Invoking them with 'script %s' doesn't work - you have to
pipe in the URL (based on experience with the way slrn passes mail
filenames to sendmail_command, I suspect that the culprit is slrn
appending a leading space to the URL, which confuses the REXX
'linein()' function; one of these days I'll get around to testing this
by stripping the first character of the input argument and seeing if it
works that way.)
>Also, on Unix, you are taking
>the geturl and downurl stdout output and redirecting it to a file called
>"nul" (overwriting that file each time), *not* sending unwanted output to
>the null device.
In OS/2 too. In this case both scripts use the REXX lineout
function to append the stream to a file instead of stdout, so the only
output going to stdout is result codes from the scripts.
>I highly recommend using Jed (the editor) for S-Lang programming. The most
>updated S-Lang API documentation is found there and the S-Lang mode will
>give you nice formatting (aka "pretty printing"). Finally, I suggest
>checking out the S-Lang docs in the S-Lang distribution.
Thanks for the tip - I'll grab a copy of Jed. I've also dropped a
note to the person maintaining the OS/2 binary slrn distribution
suggesting adding a copy of the latest S-Lang docs to the distribution
file.
--
RIOT, n. A popular entertainment given to the military by innocent
bystanders. (A. Bierce, _The Devil's Dictionary_)
http://www.io.com/~pardoz (Liaden Universe mailing list home page)
http://www.io.com/~pardoz/mythos.html (Mythos Adventure Archive)
[slrn][slang] Using Jed for S-Lang editing ? (was Re: [SLRN] Help w/macro please)
Author: Hubert Canon
Date: Wed, 16 Jul 1997 00:00
Date: Wed, 16 Jul 1997 00:00
13 lines
1140 bytes
1140 bytes
J.B. Nicholson-Owens ecrivait : > I highly recommend using Jed (the editor) for S-Lang programming. The most > updated S-Lang API documentation is found there and the S-Lang mode will > give you nice formatting (aka "pretty printing"). Finally, I suggest > checking out the S-Lang docs in the S-Lang distribution. Is there a S-Lang mode for Emacs ? -- Hubert Canon
Re: [SLRN] Help w/macro please
Author: Pardoz
Date: Wed, 16 Jul 1997 00:00
Date: Wed, 16 Jul 1997 00:00
48 lines
2278 bytes
2278 bytes
On Wed, 16 Jul 1997 03:42:18 +0200, Bjoern Frantzen <bjoff@bgnett.no> wrote:
>Pardoz <pardoz@io.com> wrote:
>
>> I'm trying to write a slrn macro using select_list_box to set the
>>non_Xbrowser variable - I want to be able to choose between starting up
>
>A very good idea!
Here's a working version of the macro to do it (I hammered it out
last night after digging up an up to date copy of the slang docs). It
is, I think, reasonably self-documenting and easily extensible if you
want to add more browser choices, and it would be easy enough to modify
to select an X browser instead. (Figuring out how to make it test for
X and present an appropriate menu based on mode is beyond me, however.)
%URL picker
define picker ()
{
variable browservbl;
variable rsp;
variable status = get_variable_value ("non_Xbrowser");
rsp = select_list_box ("Select Browser:",
"Lynx", "Bookmark", "Download", 3,
2);
switch (rsp)
{ case "Lynx" : browservbl = "lynx2.cmd %s" }
{ case "Bookmark" : browservbl = "echo %s | geturl.cmd > nul" }
{ case "Download" : browservbl = "echo %s | downurl.cmd > nul" }
set_string_variable ("non_Xbrowser", browservbl);
call ("browse_url");
set_string_variable ("non_Xbrowser", status);
}
definekey ("picker", "U", "article");
--
RIOT, n. A popular entertainment given to the military by innocent
bystanders. (A. Bierce, _The Devil's Dictionary_)
http://www.io.com/~pardoz (Liaden Universe mailing list home page)
http://www.io.com/~pardoz/mythos.html (Mythos Adventure Archive)
Re: [SLRN] Help w/macro please
Author: Pardoz
Date: Thu, 17 Jul 1997 00:00
Date: Thu, 17 Jul 1997 00:00
18 lines
1411 bytes
1411 bytes
On Thu, 17 Jul 1997 04:31:21 +0200, Bjoern Frantzen <bjoff@bgnett.no> wrote: >Talking about Xbrowsers, should the OS/2 port distinguish between >running in a in a window and fullscreen with regards to which browser >it should use (Xbrowser and non_Xbrowser)? The current default to non_Xbrowser works fine, IMO. Question - what would happen if such a patch were implemented and you actually *were* running X (say using XFree86/OS2)? -- RIOT, n. A popular entertainment given to the military by innocent bystanders. (A. Bierce, _The Devil's Dictionary_) http://www.io.com/~pardoz (Liaden Universe mailing list home page) http://www.io.com/~pardoz/mythos.html (Mythos Adventure Archive)
Re: [SLRN] Help w/macro please
Author: Daniel Price
Date: Thu, 17 Jul 1997 00:00
Date: Thu, 17 Jul 1997 00:00
17 lines
1255 bytes
1255 bytes
On 16 Jul 1997 17:36:30 GMT, Pardoz <pardoz@io.com> wrote:
>to select an X browser instead. (Figuring out how to make it test for
>X and present an appropriate menu based on mode is beyond me, however.)
You can just use getenv("DISPLAY") to find out if the DISPLAY
environment variable was set. If so, launch your favorite GUI browser,
otherwise, lynx or whatever. In fact, looking at art.c in the slrn
source, you can see that this function just calls getenv("DISPLAY") from C
in order to decide whether to launch Slrn_NonX_Browser, or Slrn_X_Browser.
-dp
--
Daniel Price -- dp@nospam.cs.brown.edu
Re: [SLRN] Help w/macro please
Author: Bjoern Frantzen
Date: Thu, 17 Jul 1997 00:00
Date: Thu, 17 Jul 1997 00:00
17 lines
1167 bytes
1167 bytes
Pardoz <pardoz@io.com> wrote:
>want to add more browser choices, and it would be easy enough to modify
>to select an X browser instead. (Figuring out how to make it test for
>X and present an appropriate menu based on mode is beyond me, however.)
Talking about Xbrowsers, should the OS/2 port distinguish between
running in a in a window and fullscreen with regards to which browser
it should use (Xbrowser and non_Xbrowser)?
Or is the current behavior, which always use non_Xbrowser ok?
--
-< Bj�rn >-
Re: [SLRN] Help w/macro please
Author: Olly Betts
Date: Fri, 18 Jul 1997 00:00
Date: Fri, 18 Jul 1997 00:00
34 lines
1715 bytes
1715 bytes
In article <slrn5spep7.26.pardoz@io.com>, Pardoz wrote:
>On 16 Jul 97 02:11:20 GMT, J.B. Nicholson-Owens
><jbn@pop-a-wheelie.midwest.net> wrote:
>>1. I don't think you want to use double parentheses. Out of curiosity, what
>> programming language uses double parentheses in the way you're using them
>> here?
>
> S-Lang apparently - at least it stopped giving me syntax errors
>when I switched from a single to a double parenthesis.
Double brackets are a way of telling slang you really wanted to use an
assignment in an if statement (a similar construct works for suppressing a
similar warning with some C compilers).
In this case, you clearly don't want to assign, you want to test equality,
so you should be writing something like:
!if (strcmp(rsp,"Lynx")) browservbl = "lynx2.cmd %s";
Not:
if ((rsp = "Lynx")) browservbl = "lynx2.cmd %s";
which is roughly equivalent to:
rsp = "Lynx";
if (rsp) browservbl = "lynx2.cmd %s";
Olly
--
Don't send a man to do a buoy's job.
Re: [SLRN] Help w/macro please
Author: Bjoern Frantzen
Date: Fri, 18 Jul 1997 00:00
Date: Fri, 18 Jul 1997 00:00
18 lines
1193 bytes
1193 bytes
Pardoz <pardoz@io.com> wrote:
> The current default to non_Xbrowser works fine, IMO. Question -
>what would happen if such a patch were implemented and you actually
>*were* running X (say using XFree86/OS2)?
Then Xbrowser should be used as well as when running in a window under
PM, only fullscreen sessions should get the non_Xbrowser.
But I can see problems here, as I guess running a PM application under
X and vice versa probably wont work.
--
-< Bj�rn >-
Re: [SLRN] Detecting X (was: [SLRN] Help w/macro please)
Author: A. Deckers
Date: Fri, 18 Jul 1997 00:00
Date: Fri, 18 Jul 1997 00:00
21 lines
1406 bytes
1406 bytes
In <slrn5stj2h.4e.bjoff@bgnett.no>, Bjoern Frantzen <bjoff@bgnett.no> wrote: >I've seen the code in art.c, but I'm wondering if that code is so >good. On the *nix accounts I have I always declare DISPLAY in my >loginscripts as the display usually is on another machines. > >When I test this now, I find that slrn (Linux) always want to run >Xbrowser even if I'm just telnetting in to that machine, no X at all. > >Or maybe it's just my setups that are a bit uncommon... ;-) Well, yes, I wouldn't consider setting DISPLAY in the login script a good policy in most cases (if you move around at all, that is). Alain -- I-hate-cyber-promo@man.ac.uk (Alain Deckers)
[SLRN] Detecting X (was: [SLRN] Help w/macro please)
Author: Bjoern Frantzen
Date: Fri, 18 Jul 1997 00:00
Date: Fri, 18 Jul 1997 00:00
23 lines
1510 bytes
1510 bytes
Daniel Price <dp@cs.brown.edu> wrote:
>On 16 Jul 1997 17:36:30 GMT, Pardoz <pardoz@io.com> wrote:
>>to select an X browser instead. (Figuring out how to make it test for
>>X and present an appropriate menu based on mode is beyond me, however.)
>You can just use getenv("DISPLAY") to find out if the DISPLAY
>environment variable was set. If so, launch your favorite GUI browser,
I've seen the code in art.c, but I'm wondering if that code is so
good. On the *nix accounts I have I always declare DISPLAY in my
loginscripts as the display usually is on another machines.
When I test this now, I find that slrn (Linux) always want to run
Xbrowser even if I'm just telnetting in to that machine, no X at all.
Or maybe it's just my setups that are a bit uncommon... ;-)
--
-< Bj�rn >-
Re: [SLRN] Detecting X (was: [SLRN] Help w/macro please)
Author: Greg Wooledge
Date: Sat, 19 Jul 1997 00:00
Date: Sat, 19 Jul 1997 00:00
31 lines
1837 bytes
1837 bytes
On Fri, 18 Jul 1997 03:52:12 +0200, Bjoern Frantzen <bjoff@bgnett.no> wrote: >I've seen the code in art.c, but I'm wondering if that code is so >good. On the *nix accounts I have I always declare DISPLAY in my >loginscripts as the display usually is on another machines. "Usually" isn't the same as "always", right? >Or maybe it's just my setups that are a bit uncommon... ;-) Probably. Maybe you could do something like this: if [ "$TERM" = xterm ]; then DISPLAY=mydisplay:0 export DISPLAY fi It depends on how you get in, etc. Since I don't have the details, I can't help more than this; you may have to be clever to get everything right. It's extremely common (a de facto standard, I'd say) to use the presence of $DISPLAY to indicate the presence of an X server. If you set $DISPLAY when you aren't running X, things will break. -- ------------ Greg Wooledge ------------- ------- wooledge@kellnet.com ------- --- http://kellnet.com/wooledge/main.html ---
Re: [SLRN] Detecting X (was: [SLRN] Help w/macro please)
Author: Bjoern Frantzen
Date: Sat, 19 Jul 1997 00:00
Date: Sat, 19 Jul 1997 00:00
19 lines
1372 bytes
1372 bytes
A. Deckers <I-hate-cyber-promo@man.ac.uk> wrote:
>In <slrn5stj2h.4e.bjoff@bgnett.no>,
>>good. On the *nix accounts I have I always declare DISPLAY in my
>>loginscripts as the display usually is on another machines.
>>Or maybe it's just my setups that are a bit uncommon... ;-)
>
>Well, yes, I wouldn't consider setting DISPLAY in the login script a
>good policy in most cases (if you move around at all, that is).
Nope, I mostly sit still. ;-) But I guess you're right in that
setting DISPLAY from zshrc/bashrc/etc. isn't the 'right thing' to do.
--
-< Bj�rn >-
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