newlisp main-args not to execute

Started by dexter, November 27, 2014, 04:47:45 AM

Previous topic - Next topic

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


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

#1
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

#2
I generally just use the #! syntax



$ 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

#3
Oh yeah



Thanks to you all, it works now



:)

rrq

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