Remove problem with main-args in script vs executable

Q&A's, tips, howto's
Post Reply
hotcore
Posts: 29
Joined: Fri Aug 26, 2011 1:03 pm

Remove problem with main-args in script vs executable

Post by 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:

Code: Select all

(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:

Code: Select all

(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)

Post Reply