newlisp main-args not to execute

Q&A's, tips, howto's

newlisp main-args not to execute

Postby dexter » Thu Nov 27, 2014 12:47 pm

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" ?
dexter
 
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

Re: newlisp main-args not to execute

Postby xytroxon » Thu Nov 27, 2014 4:08 pm

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
xytroxon
 
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm

Re: newlisp main-args not to execute

Postby mark5009 » Fri Nov 28, 2014 2:04 am

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.
mark5009
 
Posts: 6
Joined: Sat Oct 25, 2014 6:33 am

Re: newlisp main-args not to execute

Postby dexter » Mon Dec 01, 2014 3:49 am

Oh yeah

Thanks to you all, it works now

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

Re: newlisp main-args not to execute

Postby ralph.ronnquist » Mon Dec 01, 2014 9:37 pm

Use (reset) at the end of the script rather than (exit) If you want to enter interactive mode at that point.
ralph.ronnquist
 
Posts: 200
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia


Return to newLISP in the real world

Who is online

Users browsing this forum: joejoe and 2 guests