Does it exist a reliable way to process command-line args of a newlisp script, working for both a script in a source form and a script linked with an interpreter in a single executable? In the first case real args starts from second, in the second -- from first. How to find a right one?
How many argsuments would you like to process?
I always count from the last to the first argument to workaround this..
(instead of starting at the first/second and counting forward)
Norman.
Quote from: "newdep"
How many argsuments would you like to process?
If only I need a fixed number of args to process, I'll not ask this question here! Believe me, I was able to count backwards before elementary school. ;-) But if I need one obligatory and one optional argument?
Quote
C:Programmenewlisp>testm
("testm")
newLISP v.9.2.5 on Win32, execute 'newlisp -h' for more info.
> (exit)
C:Programmenewlisp>newlisp testm.lsp
("newlisp" "testm.lsp")
newLISP v.9.2.5 on Win32, execute 'newlisp -h' for more info.
> (exit)
So (=(first(main-args))"newlisp") should indicate you are running a script with the newlisp.exe. Then you set your offset for the parameter.
Edit: You must check also for a path and strip it out: (last(parse (first(main-args)) "\"))
This is what i ment..(but not what you seek?) ->
You get always the absolute length and lists are limited to their length..
> $main-args
("newlisp" "bla" "one" "two" "three")
> (length $main-args)
5
> ($main-args -100)
"newlisp"
> ($main-args -10)
"newlisp"
> ($main-args -6)
"newlisp"
> ($main-args -5)
"newlisp"
>
See http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1644&highlight= as variant...