link a list of files?

Started by Sammo, July 28, 2004, 05:13:25 PM

Previous topic - Next topic

Sammo

Will (or should) the following work to extend link.lsp to allow several source files to be specified? I'd like to link several files (one main program plus several libraries) without having to merge the files by hand.


(load "link.lsp")
(define (link-list orgExe newExeName list-of-SourceNames)
  (set 'tempFileName "linktemp.lsp")
  (set 'tempHandle (open tempFileName "write"))
  (map (fn (F) (write-buffer tempHandle (read-file F))) list-of-SourceNames)
  (close tempHandle)
  (link orgExe NewExeName tempFileName))
after which I would execute


(link-list "newlisp.exe" "myprog.exe" '("mysource.lsp" "mylibrary.lsp"))I suppose a macro might be a better implementation choice, but being somewhat "macro challenged" I choose this route. A macro would have the advantage of not having to explictly form the list of files. Any other advantages?

HPW

#1
Hello Sam,



works for me after correcting your typo:



(link orgExe newExeName tempFileName)

not

(link orgExe NewExeName tempFileName)


Case-sensitive symbol names in newLISP!

Maybe you could add 'deleting of tempFileName'.



;-)



7:40 am from Germany
Hans-Peter

eddier

#2
The only advantage, if it is really an advantage, that I can see is that the list of files in

(link-list "newlisp.exe" "myprog.exe" '("mysource.lsp" "mylibrary.lsp"))


could be called as

(link-list "newlisp.exe" "myprog.exe" "mysource.lsp" "mylibrary.lsp")


Using the code you have, I think the macro would be something like

(define-macro (link-list orgExe newExeName )
  (set 'tempFileName "linktemp.lsp")
  (set 'tempHandle (open tempFileName "write"))
  (map (fn (F) (write-buffer tempHandle (read-file F))) (args))
  (close tempHandle)
  (link orgExe newExeName tempFileName))


Eddie

Lutz

#3
you would have to do (slice (args) 2) because the first two parameters are the orginal and new exe.



Lutz

eddier

#4
Oops!



Eddie

HPW

#5
Nice! Shorter is better!
Hans-Peter

Sammo

#6
Thanks, everyone! Here is the working macro version:(load "link.lsp")
(define-macro (link-list orgExe newExeName )
    (set 'tempFileName "linktemp.lsp")
    (set 'tempHandle (open tempFileName "write"))
    (map (fn (F) (write-buffer tempHandle (read-file F))) (slice (args) 2))
    (close tempHandle)
    (link orgExe newExeName tempFileName)
    (delete-file tempFileName))
which is called like this:(link-list "newlisp.exe" "myprog.exe" "main.lsp" "lib.lsp" "etc.lsp")