1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
<html lang="en">
<head>
<title>Manipulating the load path - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Function-Files.html#Function-Files" title="Function Files">
<link rel="next" href="Subfunctions.html#Subfunctions" title="Subfunctions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Manipulating-the-load-path"></a>
Next: <a rel="next" accesskey="n" href="Subfunctions.html#Subfunctions">Subfunctions</a>,
Up: <a rel="up" accesskey="u" href="Function-Files.html#Function-Files">Function Files</a>
<hr>
</div>
<h4 class="subsection">11.7.1 Manipulating the load path</h4>
<p>When a function is called, Octave searches a list of directories for
a file that contains the function declaration. This list of directories
is known as the load path. By default the load path contains
a list of directories distributed with Octave plus the current
working directory. To see your current load path call the <code>path</code>
function without any input or output arguments.
<p>It is possible to add or remove directories to or from the load path
using <code>addpath</code> and <code>rmpath</code>. As an example, the following
code adds ‘<samp><span class="samp">~/Octave</span></samp>’ to the load path.
<pre class="example"> addpath("~/Octave")
</pre>
<p class="noindent">After this the directory ‘<samp><span class="samp">~/Octave</span></samp>’ will be searched for functions.
<!-- load-path.cc -->
<p><a name="doc_002daddpath"></a>
<div class="defun">
— Built-in Function: <b>addpath</b> (<var>dir1, <small class="dots">...</small></var>)<var><a name="index-addpath-621"></a></var><br>
— Built-in Function: <b>addpath</b> (<var>dir1, <small class="dots">...</small>, option</var>)<var><a name="index-addpath-622"></a></var><br>
<blockquote><p>Add <var>dir1</var>, <small class="dots">...</small> to the current function search path. If
<var>option</var> is ‘<samp><span class="samp">"-begin"</span></samp>’ or 0 (the default), prepend the
directory name to the current path. If <var>option</var> is ‘<samp><span class="samp">"-end"</span></samp>’
or 1, append the directory name to the current path.
Directories added to the path must exist.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dpath.html#doc_002dpath">path</a>, <a href="doc_002drmpath.html#doc_002drmpath">rmpath</a>, <a href="doc_002dgenpath.html#doc_002dgenpath">genpath</a>, <a href="doc_002dpathdef.html#doc_002dpathdef">pathdef</a>, <a href="doc_002dsavepath.html#doc_002dsavepath">savepath</a>, <a href="doc_002dpathsep.html#doc_002dpathsep">pathsep</a>.
</p></blockquote></div>
<!-- load-path.cc -->
<p><a name="doc_002dgenpath"></a>
<div class="defun">
— Built-in Function: <b>genpath</b> (<var>dir</var>)<var><a name="index-genpath-623"></a></var><br>
<blockquote><p>Return a path constructed from <var>dir</var> and all its subdirectories.
</p></blockquote></div>
<!-- load-path.cc -->
<p><a name="doc_002drmpath"></a>
<div class="defun">
— Built-in Function: <b>rmpath</b> (<var>dir1, <small class="dots">...</small></var>)<var><a name="index-rmpath-624"></a></var><br>
<blockquote><p>Remove <var>dir1</var>, <small class="dots">...</small> from the current function search path.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dpath.html#doc_002dpath">path</a>, <a href="doc_002daddpath.html#doc_002daddpath">addpath</a>, <a href="doc_002dgenpath.html#doc_002dgenpath">genpath</a>, <a href="doc_002dpathdef.html#doc_002dpathdef">pathdef</a>, <a href="doc_002dsavepath.html#doc_002dsavepath">savepath</a>, <a href="doc_002dpathsep.html#doc_002dpathsep">pathsep</a>.
</p></blockquote></div>
<!-- ./path/savepath.m -->
<p><a name="doc_002dsavepath"></a>
<div class="defun">
— Function File: <b>savepath</b> (<var>file</var>)<var><a name="index-savepath-625"></a></var><br>
<blockquote><p>Save the portion of the current function search path, that is
not set during Octave's initialization process, to <var>file</var>.
If <var>file</var> is omitted, <samp><span class="file">~/.octaverc</span></samp> is used. If successful,
<code>savepath</code> returns 0.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dpath.html#doc_002dpath">path</a>, <a href="doc_002daddpath.html#doc_002daddpath">addpath</a>, <a href="doc_002drmpath.html#doc_002drmpath">rmpath</a>, <a href="doc_002dgenpath.html#doc_002dgenpath">genpath</a>, <a href="doc_002dpathdef.html#doc_002dpathdef">pathdef</a>, <a href="doc_002dpathsep.html#doc_002dpathsep">pathsep</a>.
</p></blockquote></div>
<!-- load-path.cc -->
<p><a name="doc_002dpath"></a>
<div class="defun">
— Built-in Function: <b>path</b> (<var><small class="dots">...</small></var>)<var><a name="index-path-626"></a></var><br>
<blockquote><p>Modify or display Octave's load path.
<p>If <var>nargin</var> and <var>nargout</var> are zero, display the elements of
Octave's load path in an easy to read format.
<p>If <var>nargin</var> is zero and nargout is greater than zero, return the
current load path.
<p>If <var>nargin</var> is greater than zero, concatenate the arguments,
separating them with <code>pathsep()</code>. Set the internal search path
to the result and return it.
<p>No checks are made for duplicate elements.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002daddpath.html#doc_002daddpath">addpath</a>, <a href="doc_002drmpath.html#doc_002drmpath">rmpath</a>, <a href="doc_002dgenpath.html#doc_002dgenpath">genpath</a>, <a href="doc_002dpathdef.html#doc_002dpathdef">pathdef</a>, <a href="doc_002dsavepath.html#doc_002dsavepath">savepath</a>, <a href="doc_002dpathsep.html#doc_002dpathsep">pathsep</a>.
</p></blockquote></div>
<!-- ./path/pathdef.m -->
<p><a name="doc_002dpathdef"></a>
<div class="defun">
— Function File: <var>val</var> = <b>pathdef</b> ()<var><a name="index-pathdef-627"></a></var><br>
<blockquote><p>Return the default path for Octave.
The path information is extracted from one of three sources.
In order of preference, those are;
<ol type=1 start=1>
<li><samp><span class="file">~/.octaverc</span></samp>
<li><samp><span class="file"><octave-home>/.../<version>/m/startup/octaverc</span></samp>
<li>Octave's path prior to changes by any octaverc.
</ol>
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dpath.html#doc_002dpath">path</a>, <a href="doc_002daddpath.html#doc_002daddpath">addpath</a>, <a href="doc_002drmpath.html#doc_002drmpath">rmpath</a>, <a href="doc_002dgenpath.html#doc_002dgenpath">genpath</a>, <a href="doc_002dsavepath.html#doc_002dsavepath">savepath</a>, <a href="doc_002dpathsep.html#doc_002dpathsep">pathsep</a>.
</p></blockquote></div>
<!-- dirfns.cc -->
<p><a name="doc_002dpathsep"></a>
<div class="defun">
— Built-in Function: <var>val</var> = <b>pathsep</b> ()<var><a name="index-pathsep-628"></a></var><br>
— Built-in Function: <var>old_val</var> = <b>pathsep</b> (<var>new_val</var>)<var><a name="index-pathsep-629"></a></var><br>
<blockquote><p>Query or set the character used to separate directories in
a path.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dfilesep.html#doc_002dfilesep">filesep</a>, <a href="doc_002ddir.html#doc_002ddir">dir</a>, <a href="doc_002dls.html#doc_002dls">ls</a>.
</p></blockquote></div>
<!-- load-path.cc -->
<p><a name="doc_002drehash"></a>
<div class="defun">
— Built-in Function: <b>rehash</b> ()<var><a name="index-rehash-630"></a></var><br>
<blockquote><p>Reinitialize Octave's load path directory cache.
</p></blockquote></div>
<!-- utils.cc -->
<p><a name="doc_002dfile_005fin_005floadpath"></a>
<div class="defun">
— Built-in Function: <b>file_in_loadpath</b> (<var>file</var>)<var><a name="index-file_005fin_005floadpath-631"></a></var><br>
— Built-in Function: <b>file_in_loadpath</b> (<var>file, "all"</var>)<var><a name="index-file_005fin_005floadpath-632"></a></var><br>
<blockquote>
<p>Return the absolute name of <var>file</var> if it can be found in
the list of directories specified by <code>path</code>.
If no file is found, return an empty matrix.
<p>If the first argument is a cell array of strings, search each
directory of the loadpath for element of the cell array and return
the first that matches.
<p>If the second optional argument <code>"all"</code> is supplied, return
a cell array containing the list of all files that have the same
name in the path. If no files are found, return an empty cell array.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dfile_005fin_005fpath.html#doc_002dfile_005fin_005fpath">file_in_path</a>, <a href="doc_002dpath.html#doc_002dpath">path</a>.
</p></blockquote></div>
<!-- load-path.cc -->
<p><a name="doc_002drestoredefaultpath"></a>
<div class="defun">
— Built-in Function: <b>restoredefaultpath</b> (<var><small class="dots">...</small></var>)<var><a name="index-restoredefaultpath-633"></a></var><br>
<blockquote><p>Restore Octave's path to it's initial state at startup.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dpath.html#doc_002dpath">path</a>, <a href="doc_002daddpath.html#doc_002daddpath">addpath</a>, <a href="doc_002drmpath.html#doc_002drmpath">rmpath</a>, <a href="doc_002dgenpath.html#doc_002dgenpath">genpath</a>, <a href="doc_002dpathdef.html#doc_002dpathdef">pathdef</a>, <a href="doc_002dsavepath.html#doc_002dsavepath">savepath</a>, <a href="doc_002dpathsep.html#doc_002dpathsep">pathsep</a>.
</p></blockquote></div>
<!-- load-path.cc -->
<p><a name="doc_002dcommand_005fline_005fpath"></a>
<div class="defun">
— Built-in Function: <b>command_line_path</b> (<var><small class="dots">...</small></var>)<var><a name="index-command_005fline_005fpath-634"></a></var><br>
<blockquote><p>Return the command line path variable.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dpath.html#doc_002dpath">path</a>, <a href="doc_002daddpath.html#doc_002daddpath">addpath</a>, <a href="doc_002drmpath.html#doc_002drmpath">rmpath</a>, <a href="doc_002dgenpath.html#doc_002dgenpath">genpath</a>, <a href="doc_002dpathdef.html#doc_002dpathdef">pathdef</a>, <a href="doc_002dsavepath.html#doc_002dsavepath">savepath</a>, <a href="doc_002dpathsep.html#doc_002dpathsep">pathsep</a>.
</p></blockquote></div>
<!-- utils.cc -->
<p><a name="doc_002dfind_005fdir_005fin_005fpath"></a>
<div class="defun">
— Built-in Function: <b>find_dir_in_path</b> (<var>dir</var>)<var><a name="index-find_005fdir_005fin_005fpath-635"></a></var><br>
<blockquote><p>Return the full name of the path element matching <var>dir</var>. The
match is performed at the end of each path element. For example, if
<var>dir</var> is <code>"foo/bar"</code>, it matches the path element
<code>"/some/dir/foo/bar"</code>, but not <code>"/some/dir/foo/bar/baz"</code>
or <code>"/some/dir/allfoo/bar"</code>.
</p></blockquote></div>
</body></html>
|