I used addpath(pwd)
to get my .m files working in my projects directory. When I close the window and start a new window, the path I just added is gone. But the files still run.
Is it in my path or not? How do I see the directories I have added to my path?
Also, .
is the first entry I see from path
. Does that mean I don't need to add any directories because it will always search the current directory first?
Thanks.
Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.
An alternative way to change the working directory is by editing the properties of the Octave Desktop Icon. Right click the Octave Desktop Icon, select "Properties" and then edit the "Start In:" folder to be your code folder.
Add named directories to the function search path. If option is "-begin" or 0 (the default), prepend the directory name to the current path. If option is "-end" or 1, append the directory name to the current path. Directories added to the path must exist.
Basically, yes.
You can add a directory to the search path using addpath()
, but as you know, it only exists for the current session and is reset when you restart Octave. If you want a path to survive between sessions, add it to your octaverc
, a script file that gets run whenever a new session gets started. Example path to octaverc
file is:
C:\Octave\3.2.4_gcc-4.4.0\share\octave\site\m\startup
Since .
is in your path by default, Octave will search your current directory for any function files that it needs. Using addpath(pwd)
is somewhat useless if you're just going to stay in the same directory. However, there are some cases where it'd be useful, if for example you have a directory that contains your functions, and another one that has the data that you're working on: you could start in the functions directory, do addpath(pwd)
, and then cd
to the data directory while still being able to use your functions.
You can create batch file, which will start Octave with your directory path. Please see example below:
octave-3.6.4.exe -p "C:\MyOctaveDiretory"
-p means addpath()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With