Current newLISP edit directory?

Started by hsmyers, March 26, 2008, 02:30:40 AM

Previous topic - Next topic

hsmyers

When loading a file into newLISP edit what is the current directory? I ask because I got this error message
problem accessing file in function load : "rank-list.db"

based on this code
 (load "C:\Documents and Settings\hsmyers\My Documents\newLISP-Dev\newBoard\file-list.db")
  (load "rank-list.db")

Obviously the first time through I got the error message on the first load until I fully qualified it. I'm pretty sure I shouldn't have to. I am not sure about what I need to do to fix this. The likely suspect would seem to be a current directory mismatch between the newLISP edit and the development directory--- yes?



--hsm
\"Censeo Toto nos in Kansa esse decisse.\"—D. Gale \"[size=117]ℑ♥λ[/size]\"—Toto

cormullion

#1
I'd say it was that returned by (env "HOME"). You can use (real-path) to find out your current working directory, and (change-dir ...) to change it. Have you tried something like this:


(change-dir "C:\Documents and Settings\hsmyers\My Documents\newLISP-Dev\newBoard")

(load "file-list.db" "rank-list.db")


but I'm not using Windows and might not have grasped the differences...

hsmyers

#2
Thanks Cormullion! Your suggestion works. That said, I don't think I should have to change my code just to please the editor!



I set the value of HOME to point to the desired directory and the editor cheerfully ignored same. Must be some way to align things--- perhaps it is time to 'use the source Luke'?



--hsm
\"Censeo Toto nos in Kansa esse decisse.\"—D. Gale \"[size=117]ℑ♥λ[/size]\"—Toto

Lutz

#3
QuoteI set the value of HOME to point to the desired directory and the editor cheerfully ignored same.


It will not ignore (UNIX and Mac OS X) If you start newlisp-edit in the same shell where you changed the value of the environment variable HOME, it will make this the home directory for the shell process (lower window) and all code evaluated from the editor area.



You can check with (env "HOME") when in newlisp-edit or using the function (real-path), which will return the current directory path.



ps: On Windows the situation is different

Lutz

#4
On Win32  XP you could do:



(change-dir (env "HOME"))
; or
(change-dir (env "HOMEPATH"))
; or
(change-dir (env "USERPROFILE"))


normally on Windows the HOME environment variable is not present

hsmyers

#5
I run under w2k and as evidence here is the result of loading my file

problem accessing file in function load : "file-list.db"
called from user defined function ChessBoard:setup
> (env "HOME")
"C:\Documents and Settings\hsmyers\My Documents\newLISP-Dev\newBoard"
>


Note that file-list.db is local to the file being loaded.



--hsm
\"Censeo Toto nos in Kansa esse decisse.\"—D. Gale \"[size=117]ℑ♥λ[/size]\"—Toto

Lutz

#6
development version 9.3.5 now correctly goes to home directory on Win32