setting (main-args)

Started by newdep, August 12, 2006, 12:17:12 PM

Previous topic - Next topic

newdep

Hi Lutz,



(main-args) is used as a copy from argv in the newlisp.c code..



I would like to manipulate the (main-args) during newlisp startup.



But this is not that easy ;-)  



If you take i.e. my new option called "-o" and use it like this ->



newlisp -o "(chop (main-args))" it will nicely print the chopped args

but if I then type (main-args) it gives me still the main argv values.



Do you have any idea how to manipulate the (main-args) during startup?



Yes that sounds strange, but emagine newlisp.exe being executed from another

shell or program that always sends its own args too.. then newlisp does not have

its own args but also the ones from the shell or program that executed it...





Regards, Norman
-- (define? (Cornflakes))

Lutz

#1
The original argv[] list is stored in a protecteed system symbol $main-args. But you can modify it as the following dialog shows:

~> newlisp a b c d e f
newLISP v.8.9.3 on OSX UTF-8, execute 'newlisp -h' for more info.

> (main-args)
("newlisp" "a" "b" "c" "d" "e" "f")
> (constant '$main-args (chop (main-args)))
("newlisp" "a" "b" "c" "d" "e")
> (main-args)
("newlisp" "a" "b" "c" "d" "e")
>


Lutz

newdep

#2
HA thanks..great solution! that I did not think of that..

(thats because i probably did not know of $main-args ;-)
-- (define? (Cornflakes))