newLISP Fan Club

Forum => newLISP and the O.S. => Topic started by: Cyril on February 02, 2008, 09:39:45 AM

Title: lisp2exe.lsp
Post by: Cyril on February 02, 2008, 09:39:45 AM
I have hack this up back in November when writing my first end-user application in newlisp, and now I am convinced in its usefulness. Get link.lsp from util subdirectory, add the following lines to the end of file after ';; eof' comment, and save it as lisp2exe.lsp somewhere in the PATH.


;; eof

(unless (and (member (length (main-args)) '(3 4))
             (ends-with (main-args 0) "newlisp.exe" nil)
             (ends-with (main-args 1) "lisp2exe.lsp" nil)
             (ends-with (main-args 2) ".lsp" nil))
  (begin (println "Usage: lisp2exe file.lsp [file.exe]") (exit)))

(map set '(interpreter script lispfile exefile) (main-args))

(unless exefile
  (setq exefile (replace {.lsp$} (begin lispfile) ".exe" 1)))

(link interpreter exefile lispfile)

(exit)


Oh, just forgot: you must make the .lsp extension executable (unless you already have this done).