hey guys,
How can I make
(nth 3 (main-args))
into
(nth * (main-args))
Well, not quite like that, but so that main-args can use any number of arguments?
thanks.
I do not understand the question.
newlisp 1 2 3 4 . . .
> (main-args) => ("/usr/bin/newlisp" "1" "2" "3" "4" . . . )
(main-args) is not limited how much parameter are passed (Maybe the OS).
Tried later:
C:Programmenewlisp>newlisp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
newLISP v.8.7.1 on Win32 MinGW, execute 'newlisp -h' for more info.
> (main-args)
("newlisp" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13"
"14" "15" "16" "17" "18" "19" "20")
>
I can't quite seem to get what I'm trying to work.
I've been messing with rox-filer. in rox, you can open
a sort of "send to" menu for a file or multiple files.
I wrote a single line script to send files to.
#!/usr/bin/newlisp
(!(append "aterm -e w3m " (nth 3 (main-args))))
(exit)
...it uses my favorite browser/pager w3m, of course :-)
it works if one file is selected.
if I call w3m from an xterm with "-N" then multiple
files or sites open up in tabs.
When I add the "-N" to my one-liner, and take away the
"nth 3" nothing happens.
I'm probably not being clear. let me try this: I want
somthing like
$ w3m -N file file file file file file
(in rox, I may select multiple files to send to my
script)
any ideas?
Still not sure what you do!
Do you use direct execution mode or load a lisp-file for startup?
Do you start newlisp only to start w3m?
Why not direct?
And from where come the file-titles?
Maybe you want:
(rest (rest (main-args)))
Return all main-args without first and second.

(//%3C/s%3E%3CURL%20url=%22http://perpetualnewbie.info/pix/rox-shot1.png%22%3Ehttp://perpetualnewbie.info/pix/rox-shot1.png%3C/URL%3E%3Ce%3E)
that's a rox window with the send-to (open-with)
context menu open.
I just can't get my script to work. I can't launch w3m
directly because it's a console app, have to launch an
xterm and tell it to.
(print(append "aterm -e w3m -N " main-args)
If I can get that line to print out
aterm -e w3m -N blah blah blah foo whatever
then I could replace the print with a ! and my thing
would work. I can't do it. grrrr. frustrating.
So you want ROX to call a newlisp script that does execute an aterm / xterm
which executes w3m ? If i look in the manpage of xterm it does tell that the "-e" needs to be the LAST option in the line, not sure if aterm has that too.
this works here..
> (exec "xterm -e "lynx http://www.newlisp.org" ")
or
> (! "xterm -e "lynx http://www.newlisp.org" ")
This works also ->
#!/usr/bin/newlisp
(! (append {xterm -e "lynx } ((main-args) 2) {"}) )
run it like ->
# script.lsp "http://www.newlisp.org"
and xterm is started with lynx running the webpage...
(Using (start length (main-args)) here can be used to inside the "!" too)
sorry, guys!
I'm really parading my ignorance around. Here's what I have.
#!/usr/bin/newlisp
(set 'a (string (rest (rest (main-args)))))
(print (append "aterm -e w3m -N " """ a """))
;(exit)
run like this,
$ stupidthing.lsp a-good-day.txt a-hot-day.txt
I get
aterm -e w3m -N "("a-good-day.txt" "a-hot-day.txt")"
how do I get rid of the parens?
Try this:
#!/usr/bin/newlisp
(set 'a (join (rest (rest (main-args))) " "))
(! (append "aterm -e w3m -N " a))
(exit)
or shorter
#!/usr/bin/newlisp
(set 'a (join (2 (main-args)) " "))
(! (append "aterm -e w3m -N " a))
(exit)
Lutz
ta daaaa!
that's it. Thanks Lutz and everybody :-)