So, perhaps it was just a glitch ...
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
; ################################################################################
; # NLINC
; #
; # Purpose:
; # - read a newLISP script xxx.lsp
; # - if there are LOAD functions (on the utter left of a line)
; # these will be replaced by the loaded MEMBER itself (INCLUDED)
; # - output will be written to xxx-i.lsp
; ################################################################################
(define (mainargs , osargs srch)
(setq osargs (main-args))
(setq srch (lower-case (osargs 0)))
(if (or (= srch "newlisp") (= srch "newlisp.exe"))
(2 osargs)
(1 osargs)))
(define (check-include line , incmem)
(setq line (lower-case (trim line)))
(if (!= (0 6 line) "(load ")
(setq imcmem nil)
(begin
(setq line (6 line))
(setq incmem ((parse line {"}) 1))))
incmem)
(define (write-incmem incmem out , memfile)
(setq memfile (open incmem "read"))
(write-line out (append "; NLINC: member " incmem " included here") )
(while (read-line memfile)
(write-line out (current-line)))
(close memfile)
)
(define (pass , in out incmem extra-pass)
(setq in (open wf1 "read"))
(setq out (open wf2 "write"))
(setq extra-pass nil)
(println "NLINC: entering pass " (inc passnum) " ...")
(while (read-line in)
(setq line (current-line))
(setq incmem (check-include line))
(cond ((nil? incmem) (write-line out line))
((find incmem inclist) (write-line out (append "; " line)))
(true
(push incmem inclist)
(write-incmem incmem out)
(setq extra-pass true))))
(close in)
(close out)
extra-pass)
(define (nlinc , extra-pass scriptname script wf1 wf2 tmp)
(setq extra-pass true)
(setq scriptname ((mainargs) 0))
(setq script (append scriptname ".lsp"))
(setq wf1 (append scriptname "-i1.lsp"))
(setq wf2 (append scriptname "-i2.lsp"))
(setq scriptout (append scriptname "-i.lsp"))
(setq swapped nil)
(setq inclist '())
(setq passnum 0)
(setq tmp "")
(if (not (file? script))
(begin
(println "NLINC: you may only specify the name part of the script")
(println " without path and extension!")
(exit 999)))
(println {NLINC: processing started for script "} script {"})
(copy-file script wf1)
; Loop over the script and include
; If any script included, repeat until nothing included
; Avoid duplicate includes
(while extra-pass
(setq extra-pass (pass wf1 wf2))
(setq tmp wf2)
(setq wf2 wf1)
(setq wf1 tmp)
(if swapped
(setq swapped nil)
(setq swapped true)))
(delete-file scriptout)
(if swapped
(begin
(rename-file wf1 scriptout)
(delete-file wf2))
(begin
(rename-file wf1 scriptout)
(delete-file wf2))))
(nlinc)
(exit)
e:
cd srcnewlisp
newlisp nlinc.lsp %1
newlisp -x %1-i.lsp %1.exe
move /y %1.exe e:scripts
del %1-i.lsp
(define (mainargs)
(letn (osargs (main-args)
(srch (lower-case (osargs 0))))
(if (or (= srch "newlisp") (= srch "newlisp.exe"))
(1 osargs)
osargs)))
(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)
(define (mainargs)Quote
(let (osargs (main-args))
(if (= (lower-case (osargs 0)) "newlisp")
(1 osargs))))
(load "mainargs.lsp")Quote
(define (showpath myargs)
(let (pathlist (parse (lower-case (env "PATH")) ";")
osargs (mainargs))
(println "===>" osargs (main-args))
(dolist (line pathlist)
(if (> (length osargs) 1)
(if (not (nil? (find (lower-case (osargs 1)) line)))
(println line))
(println line)))))
(println "=====================================================")
(showpath)
(println "=====================================================")
(exit)