newLISP Fan Club

Forum => newLISP in the real world => Topic started by: newdep on August 12, 2006, 12:17:12 PM

Title: setting (main-args)
Post by: newdep on August 12, 2006, 12:17:12 PM
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
Title:
Post by: Lutz on August 12, 2006, 02:03:56 PM
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
Title:
Post by: newdep on August 12, 2006, 02:06:48 PM
HA thanks..great solution! that I did not think of that..

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