File: Manipulating-the-Load-Path.html

package info (click to toggle)
octave 3.8.2-2~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 84,360 kB
  • sloc: cpp: 293,356; ansic: 42,041; fortran: 23,669; sh: 13,629; objc: 7,890; yacc: 7,093; lex: 3,442; java: 2,125; makefile: 1,589; perl: 1,009; awk: 974; xml: 34
file content (252 lines) | stat: -rw-r--r-- 12,899 bytes parent folder | download | duplicates (3)
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Octave: Manipulating the Load Path</title>

<meta name="description" content="GNU Octave: Manipulating the Load Path">
<meta name="keywords" content="GNU Octave: Manipulating the Load Path">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Function-Files.html#Function-Files" rel="up" title="Function Files">
<link href="Subfunctions.html#Subfunctions" rel="next" title="Subfunctions">
<link href="Function-Files.html#Function-Files" rel="prev" title="Function Files">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Manipulating-the-Load-Path"></a>
<div class="header">
<p>
Next: <a href="Subfunctions.html#Subfunctions" accesskey="n" rel="next">Subfunctions</a>, Up: <a href="Function-Files.html#Function-Files" accesskey="u" rel="up">Function Files</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Manipulating-the-Load-Path-1"></a>
<h4 class="subsection">11.9.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>
<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 &lsquo;<samp>~/Octave</samp>&rsquo; to the load path.
</p>
<div class="example">
<pre class="example">addpath (&quot;~/Octave&quot;)
</pre></div>

<p>After this the directory &lsquo;<samp>~/Octave</samp>&rsquo; will be searched for functions.
</p> 
<a name="XREFaddpath"></a><dl>
<dt><a name="index-addpath"></a>Built-in Function: <em></em> <strong>addpath</strong> <em>(<var>dir1</var>, &hellip;)</em></dt>
<dt><a name="index-addpath-1"></a>Built-in Function: <em></em> <strong>addpath</strong> <em>(<var>dir1</var>, &hellip;, <var>option</var>)</em></dt>
<dd><p>Add named directories to the function search path.  If
<var>option</var> is <code>&quot;-begin&quot;</code> or 0 (the default), prepend the
directory name to the current path.  If <var>option</var> is <code>&quot;-end&quot;</code>
or 1, append the directory name to the current path.
Directories added to the path must exist.
</p>
<p>In addition to accepting individual directory arguments, lists of
directory names separated by <code>pathsep</code> are also accepted.  For example:
</p>
<div class="example">
<pre class="example">addpath (&quot;dir1:/dir2:~/dir3&quot;)
</pre></div>

<p><strong>See also:</strong> <a href="#XREFpath">path</a>, <a href="#XREFrmpath">rmpath</a>, <a href="#XREFgenpath">genpath</a>, <a href="#XREFpathdef">pathdef</a>, <a href="#XREFsavepath">savepath</a>, <a href="#XREFpathsep">pathsep</a>.
</p></dd></dl>


<a name="XREFgenpath"></a><dl>
<dt><a name="index-genpath"></a>Built-in Function: <em></em> <strong>genpath</strong> <em>(<var>dir</var>)</em></dt>
<dt><a name="index-genpath-1"></a>Built-in Function: <em></em> <strong>genpath</strong> <em>(<var>dir</var>, <var>skip</var>, &hellip;)</em></dt>
<dd><p>Return a path constructed from <var>dir</var> and all its subdirectories.
If additional string parameters are given, the resulting path will
exclude directories with those names.
</p></dd></dl>


<a name="XREFrmpath"></a><dl>
<dt><a name="index-rmpath"></a>Built-in Function: <em></em> <strong>rmpath</strong> <em>(<var>dir1</var>, &hellip;)</em></dt>
<dd><p>Remove <var>dir1</var>, &hellip; from the current function search path.
</p>
<p>In addition to accepting individual directory arguments, lists of
directory names separated by <code>pathsep</code> are also accepted.  For example:
</p>
<div class="example">
<pre class="example">rmpath (&quot;dir1:/dir2:~/dir3&quot;)
</pre></div>

<p><strong>See also:</strong> <a href="#XREFpath">path</a>, <a href="#XREFaddpath">addpath</a>, <a href="#XREFgenpath">genpath</a>, <a href="#XREFpathdef">pathdef</a>, <a href="#XREFsavepath">savepath</a>, <a href="#XREFpathsep">pathsep</a>.
</p></dd></dl>


<a name="XREFsavepath"></a><dl>
<dt><a name="index-savepath"></a>Function File: <em></em> <strong>savepath</strong> <em>()</em></dt>
<dt><a name="index-savepath-1"></a>Function File: <em></em> <strong>savepath</strong> <em>(<var>file</var>)</em></dt>
<dt><a name="index-savepath-2"></a>Function File: <em><var>status</var> =</em> <strong>savepath</strong> <em>(&hellip;)</em></dt>
<dd><p>Save the unique portion of the current function search path that is
not set during Octave&rsquo;s initialization process to <var>file</var>.
If <var>file</var> is omitted, <samp>~/.octaverc</samp> is used.  If successful,
<code>savepath</code> returns 0.
</p>
<p><strong>See also:</strong> <a href="#XREFpath">path</a>, <a href="#XREFaddpath">addpath</a>, <a href="#XREFrmpath">rmpath</a>, <a href="#XREFgenpath">genpath</a>, <a href="#XREFpathdef">pathdef</a>.
</p></dd></dl>


<a name="XREFpath"></a><dl>
<dt><a name="index-path"></a>Built-in Function: <em></em> <strong>path</strong> <em>(&hellip;)</em></dt>
<dd><p>Modify or display Octave&rsquo;s load path.
</p>
<p>If <var>nargin</var> and <var>nargout</var> are zero, display the elements of
Octave&rsquo;s load path in an easy to read format.
</p>
<p>If <var>nargin</var> is zero and nargout is greater than zero, return the
current load path.
</p>
<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>
<p>No checks are made for duplicate elements.
</p>
<p><strong>See also:</strong> <a href="#XREFaddpath">addpath</a>, <a href="#XREFrmpath">rmpath</a>, <a href="#XREFgenpath">genpath</a>, <a href="#XREFpathdef">pathdef</a>, <a href="#XREFsavepath">savepath</a>, <a href="#XREFpathsep">pathsep</a>.
</p></dd></dl>


<a name="XREFpathdef"></a><dl>
<dt><a name="index-pathdef"></a>Function File: <em><var>val</var> =</em> <strong>pathdef</strong> <em>()</em></dt>
<dd><p>Return the default path for Octave.
The path information is extracted from one of three sources.
The possible sources, in order of preference, are:
</p>
<ol>
<li> <samp>~/.octaverc</samp>

</li><li> <samp>&lt;octave-home&gt;/&hellip;/&lt;version&gt;/m/startup/octaverc</samp>

</li><li> Octave&rsquo;s path prior to changes by any octaverc.
</li></ol>

<p><strong>See also:</strong> <a href="#XREFpath">path</a>, <a href="#XREFaddpath">addpath</a>, <a href="#XREFrmpath">rmpath</a>, <a href="#XREFgenpath">genpath</a>, <a href="#XREFsavepath">savepath</a>.
</p></dd></dl>


<a name="XREFpathsep"></a><dl>
<dt><a name="index-pathsep"></a>Built-in Function: <em><var>val</var> =</em> <strong>pathsep</strong> <em>()</em></dt>
<dt><a name="index-pathsep-1"></a>Built-in Function: <em><var>old_val</var> =</em> <strong>pathsep</strong> <em>(<var>new_val</var>)</em></dt>
<dd><p>Query or set the character used to separate directories in a path.
</p>
<p><strong>See also:</strong> <a href="Filesystem-Utilities.html#XREFfilesep">filesep</a>.
</p></dd></dl>


<a name="XREFrehash"></a><dl>
<dt><a name="index-rehash"></a>Built-in Function: <em></em> <strong>rehash</strong> <em>()</em></dt>
<dd><p>Reinitialize Octave&rsquo;s load path directory cache.
</p></dd></dl>


<a name="XREFfile_005fin_005floadpath"></a><dl>
<dt><a name="index-file_005fin_005floadpath"></a>Built-in Function: <em></em> <strong>file_in_loadpath</strong> <em>(<var>file</var>)</em></dt>
<dt><a name="index-file_005fin_005floadpath-1"></a>Built-in Function: <em></em> <strong>file_in_loadpath</strong> <em>(<var>file</var>, &quot;all&quot;)</em></dt>
<dd>
<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 character string.
</p>
<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>
<p>If the second optional argument <code>&quot;all&quot;</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.
</p>
<p><strong>See also:</strong> <a href="Filesystem-Utilities.html#XREFfile_005fin_005fpath">file_in_path</a>, <a href="#XREFfind_005fdir_005fin_005fpath">find_dir_in_path</a>, <a href="#XREFpath">path</a>.
</p></dd></dl>


<a name="XREFrestoredefaultpath"></a><dl>
<dt><a name="index-restoredefaultpath"></a>Built-in Function: <em></em> <strong>restoredefaultpath</strong> <em>(&hellip;)</em></dt>
<dd><p>Restore Octave&rsquo;s path to its initial state at startup.
</p>

<p><strong>See also:</strong> <a href="#XREFpath">path</a>, <a href="#XREFaddpath">addpath</a>, <a href="#XREFrmpath">rmpath</a>, <a href="#XREFgenpath">genpath</a>, <a href="#XREFpathdef">pathdef</a>, <a href="#XREFsavepath">savepath</a>, <a href="#XREFpathsep">pathsep</a>.
</p></dd></dl>


<a name="XREFcommand_005fline_005fpath"></a><dl>
<dt><a name="index-command_005fline_005fpath"></a>Built-in Function: <em></em> <strong>command_line_path</strong> <em>(&hellip;)</em></dt>
<dd><p>Return the command line path variable.
</p>

<p><strong>See also:</strong> <a href="#XREFpath">path</a>, <a href="#XREFaddpath">addpath</a>, <a href="#XREFrmpath">rmpath</a>, <a href="#XREFgenpath">genpath</a>, <a href="#XREFpathdef">pathdef</a>, <a href="#XREFsavepath">savepath</a>, <a href="#XREFpathsep">pathsep</a>.
</p></dd></dl>


<a name="XREFfind_005fdir_005fin_005fpath"></a><dl>
<dt><a name="index-find_005fdir_005fin_005fpath"></a>Built-in Function: <em></em> <strong>find_dir_in_path</strong> <em>(<var>dir</var>)</em></dt>
<dt><a name="index-find_005fdir_005fin_005fpath-1"></a>Built-in Function: <em></em> <strong>find_dir_in_path</strong> <em>(<var>dir</var>, &quot;all&quot;)</em></dt>
<dd><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>&quot;foo/bar&quot;</code>, it matches the path element
<code>&quot;/some/dir/foo/bar&quot;</code>, but not
<code>&quot;/some/dir/foo/bar/baz&quot;</code>
<code>&quot;/some/dir/allfoo/bar&quot;</code>.
</p>
<p>The second argument is optional.  If it is supplied, return a cell array
containing all name matches rather than just the first.
</p>
<p><strong>See also:</strong> <a href="Filesystem-Utilities.html#XREFfile_005fin_005fpath">file_in_path</a>, <a href="#XREFfile_005fin_005floadpath">file_in_loadpath</a>, <a href="#XREFpath">path</a>.
</p></dd></dl>


<hr>
<div class="header">
<p>
Next: <a href="Subfunctions.html#Subfunctions" accesskey="n" rel="next">Subfunctions</a>, Up: <a href="Function-Files.html#Function-Files" accesskey="u" rel="up">Function Files</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>