newlisp main-args not to execute

Q&A's, tips, howto's
Locked
dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

newlisp main-args not to execute

Post 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" ?

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Re: newlisp main-args not to execute

Post 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
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

mark5009
Posts: 6
Joined: Sat Oct 25, 2014 6:33 am

Re: newlisp main-args not to execute

Post 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.

dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

Re: newlisp main-args not to execute

Post by dexter »

Oh yeah

Thanks to you all, it works now

:)

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: newlisp main-args not to execute

Post by ralph.ronnquist »

Use (reset) at the end of the script rather than (exit) If you want to enter interactive mode at that point.

Locked