Page 1 of 1
link a list of files?
Posted: Thu Jul 29, 2004 12:13 am
by 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.
Code: Select all
(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
Code: Select all
(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?
Posted: Thu Jul 29, 2004 5:36 am
by HPW
Hello Sam,
works for me after correcting your typo:
Code: Select all
(link orgExe newExeName tempFileName)
not
Code: Select all
(link orgExe NewExeName tempFileName)
Case-sensitive symbol names in newLISP!
Maybe you could add 'deleting of tempFileName'.
;-)
7:40 am from Germany
Posted: Thu Jul 29, 2004 12:32 pm
by eddier
The only advantage, if it is really an advantage, that I can see is that the list of files in
Code: Select all
(link-list "newlisp.exe" "myprog.exe" '("mysource.lsp" "mylibrary.lsp"))
could be called as
Code: Select all
(link-list "newlisp.exe" "myprog.exe" "mysource.lsp" "mylibrary.lsp")
Using the code you have, I think the macro would be something like
Code: Select all
(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
Posted: Thu Jul 29, 2004 12:37 pm
by Lutz
you would have to do (slice (args) 2) because the first two parameters are the orginal and new exe.
Lutz
Posted: Thu Jul 29, 2004 12:47 pm
by eddier
Oops!
Eddie
Posted: Thu Jul 29, 2004 1:05 pm
by HPW
Nice! Shorter is better!
Posted: Thu Jul 29, 2004 1:09 pm
by Sammo
Thanks, everyone! Here is the working macro version:
Code: Select all
(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:
Code: Select all
(link-list "newlisp.exe" "myprog.exe" "main.lsp" "lib.lsp" "etc.lsp")