Remove problem with main-args in script vs executable

Started by hotcore, February 26, 2016, 03:21:43 AM

Previous topic - Next topic

hotcore

Maybe somebody is interested in the code below.

The main function is to show the contents of the Windows path, line by line. You may specify a search string on the comaand line to filter the output.



More important is the separate code for a function which takes care of the difference in command line arguments between running as a script and running as an executable.



Code to be "included" (loaded) by the main porogram:
(define (mainargs)
(letn (osargs (main-args)
(srch (lower-case (osargs 0))))
(if (or (= srch "newlisp") (= srch "newlisp.exe"))
(1 osargs)
osargs)))


Main program which loads the above code:
(load "mainargs.lsp")

(define (showpath myargs)
(let (pathlist (parse (lower-case (env "PATH")) ";")
osargs (mainargs))
(dolist (line  pathlist)
(if (> (length osargs) 1)
(if (not (nil? (find (lower-case (osargs 1)) line)))
(println line))
(println line)))))

(println "=====================================================")
(showpath)
(println "=====================================================")
(exit)