# About Code_Snippets:(cwd)

For the Compleat Fan
Locked
alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

# About Code_Snippets:(cwd)

Post by alex »

# About Code_Snippets:(cwd)
It can be shorter, I think:

Code: Select all

(define (cwd) (first (exec (if (= (& 0xF (last (sys-info))) 6) "cd" "pwd"))))
[/code]

Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Post by Sammo »

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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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.

Locked