0

I found a nice article on stack exchange about how to change the directory for prolog in the terminal, i.e. working_directory(CWD,'NEW'). However, I noticed that this only works for the one time you enter SWIPL and doesn't remain the same. Is there any way I can change this through terminal to always be my new depository? alternatively, is there any way that I can access other folders through SWIPL so that I don't have to move all of my files to its home directory? I would prefer not to do that. Thanks!

Algebra8
  • 1,115
  • 1
  • 10
  • 23
  • Also note that I found this on the documentation, http://www.swi-prolog.org/pldoc/man?predicate=absolute_file_name/2 but I am not sure what to make of it – Algebra8 Jan 20 '18 at 21:46
  • 2
    `absolute_file_name/2` takes a file name from your current directory and gives you its full path. That doesn't help you. If you want to access a file from another directory, specify its proper full path or relative path when you access it. Did you try that? – lurker Jan 20 '18 at 21:59
  • When you execute a program, the shell gives it its own environment including its current working directory. if it changes the current working directory, the new working directory only applies for that program while it's executing. The environment or shell that called the program has its own working directory which is not affected by this change. – lurker Jan 20 '18 at 22:00
  • @lurker I'm not sure how to do the first thing you mentioned, i.e. "pecify its proper full path or relative path when you access it". My issue is that I want to change the entire current working directory for prolog. but you're saying I can't do that? – Algebra8 Jan 20 '18 at 22:11
  • 2
    Maybe I'm not following what you mean. Before you start `swipl` you can go to any directory you wish first. Once you start `swipl` and within it you change directory via `working_directory/2`, that change in directory applies only to that execution instance of `swipl`. It does not affect the working directory of the shell that called it. In other words, when `working_directory/2` is called, when `swipl` exits, it will be in the same directory it was originally executed from. – lurker Jan 20 '18 at 22:14
  • Yes exactly, but I was hoping to change it permanently. Is that possible? – Algebra8 Jan 21 '18 at 02:17
  • I'm not sure how else to say it. You can see [this answer](https://stackoverflow.com/questions/1293660/is-there-any-way-to-change-directory-using-c-language#answer-1293688), which isn't `swipl` but it's saying it cannot be done from a program for the reasons I've mentioned already. `swipl` is a program. – lurker Jan 21 '18 at 02:29
  • Oh, ok I see; it cannot be done. Thank you so much and sorry for the misunderstanding! – Algebra8 Jan 21 '18 at 20:47

0 Answers0