newLISP Fan Club

Forum => Anything else we might add? => Topic started by: alex on March 20, 2006, 12:11:31 PM

Title: # About Code_Snippets:(cwd)
Post by: alex on March 20, 2006, 12:11:31 PM
# About Code_Snippets:(cwd)

It can be shorter, I think:
(define (cwd) (first (exec (if (= (& 0xF (last (sys-info))) 6) "cd" "pwd"))))
[/code]
Title:
Post by: Sammo on March 20, 2006, 12:34:00 PM
Hi Alex,



Your version is, indeed, shorter and more direct than the snippet that calls the Windows DLL, but it has the disadvantage of not working in the newLisp-tk environment on my WIN2K system. Anybody know why?



Thanks,

-- Sam
Title:
Post by: Lutz on March 20, 2006, 01:04:04 PM
May be you have to do: (exec "cmd.exe /C cd")



Lutz



ps: I have put Alex's version as a second solution on the code-snippets page.



In a speed-sensitive situation the library import solution will be much faster, specially if the import has been done before, i.e. in init.lsp,  and during program execution the imported function is only called.