newLISP Fan Club

Forum => newLISP newS => Topic started by: hsmyers on March 26, 2008, 02:30:40 AM

Title: Current newLISP edit directory?
Post by: hsmyers on March 26, 2008, 02:30:40 AM
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
Title:
Post by: cormullion on March 26, 2008, 03:34:48 AM
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...
Title:
Post by: hsmyers on March 26, 2008, 08:32:22 AM
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
Title:
Post by: Lutz on March 26, 2008, 09:02:29 AM
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
Title:
Post by: Lutz on March 26, 2008, 10:09:02 AM
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
Title:
Post by: hsmyers on March 26, 2008, 12:29:22 PM
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
Title:
Post by: Lutz on March 26, 2008, 05:19:21 PM
development version 9.3.5 now correctly goes to home directory on Win32