Page 1 of 1

newlisp main-args not to execute

Posted: Thu Nov 27, 2014 12:47 pm
by dexter
I recently met a "problem"

I wrote a newlisp file ,let's say, test1.lsp

then I want the test1.lsp to deal with files in the (main-args) , like

Code: Select all

newlisp test1.lsp xxxx.file
In my mind, I thought newlisp and test1.lsp are together like one binary file
but then I found out , the command "newlisp" will also try to run xxxx.file whatever it is,just a file

I think there is no method can stop this behavior ,right?

so maybe newlisp can have a command line argument,like -f ? to seprate the files need to be executed or just use them as "string argments" ?

Re: newlisp main-args not to execute

Posted: Thu Nov 27, 2014 4:08 pm
by xytroxon
Just add the (exit) command to the end of your test1.lsp file to prevent the further loading of files as code...

This feature is so that any modules (that don't have the exit command) can be loaded ahead of your final code file...

-- xytroxon

Re: newlisp main-args not to execute

Posted: Fri Nov 28, 2014 2:04 am
by mark5009
I generally just use the #! syntax

Code: Select all

$ cat foo.lsp
#!/usr/bin/newlisp

(println (main-args))
(exit)

$ chmod 755 foo.lsp    # make sure foo.lsp is executable
$ ./foo.lsp xxxx.file
("/usr/bin/newlisp" "./foo.lsp" "xxxx.file")
Hope this helps.

.. m.

Re: newlisp main-args not to execute

Posted: Mon Dec 01, 2014 3:49 am
by dexter
Oh yeah

Thanks to you all, it works now

:)

Re: newlisp main-args not to execute

Posted: Mon Dec 01, 2014 9:37 pm
by ralph.ronnquist
Use (reset) at the end of the script rather than (exit) If you want to enter interactive mode at that point.