In Netlogo, I have a problem using set-current-directory
(I am running Netlogo 6.2.1 in Windows 7 with Bootcamp on a MacBookAir from 2012)
In Setup I have:
set-current-directory "C:\Users\LALC\Desktop\1 RESEARCH\BLABLA\BLABLABLA\MODEL"
set-country-names-list
The function set-country-names-list is:
to set-country-names-list
file-open "countries12.csv"
while [not file-at-end?]
[set country-names-list csv:from-row file-read-line]
file-close
I get this error:
The file C:UsersLALCDesktop1 RESEARCHBLABLABLABLABLAMODELcountries12.csv cannot be found
error while observer running FILE-AT-END?
called by procedure SET-COUNTRY-NAMES-LIST
called by procedure SETUP
called by Button 'SETUP'
I am not sure why it does not give me the error when it opens the file, but only when it checks file-at-end? Where is the logic?
Also, the file is precisely in that directory, how can it not find it?
Now, the Netlogo Help page
at https://ccl.northwestern.edu/netlogo/docs/dict/set-current-directory.html says:
“The change is temporary and is not saved with the model.”
What does this mean exactly? Reading this, I think it means that it is not saved when I exit the model; but within the same model execution I expect it to hold to the directory I set, until either 1) I change it to another directory later in the code, or 2) the system changes it back to the default directory when I run the model again from scratch. Is this correct?
( If this is not correct, why not fix this and make it straightforward? The directory should stay to the one I set in the code until I change it somewhere else in the code for ALL primitives referring to that file (not just file-delete, file-exists?, and file-open) or until I close and reopen the Netlogo file. In my case, I have to analyze in R the Netlogo output. To circumvent this issue, I have to put both the R and the Netlogo files in the same directory and it makes a mess. It’s not the end of the world, but I am sure there are cases when this is much more important. )
Am I missing something in the use of set-current-directory?
Any suggestions?
Thank you!