3017
|
1 ## Copyright (C) 1997 John W. Eaton |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, USA. |
|
19 |
3449
|
20 ## -*- texinfo -*- |
3500
|
21 ## @deftypefn {Function File} {} path (@dots{}) |
3449
|
22 ## Modify or display Octave's @code{LOADPATH}. |
3017
|
23 ## |
3449
|
24 ## If @var{nargin} and @var{nargout} are zero, display the elements of |
|
25 ## Octave's @code{LOADPATH} in an easy to read format. |
3017
|
26 ## |
3449
|
27 ## If @var{nargin} is zero and nargout is greater than zero, return the |
|
28 ## current value of @code{LOADPATH}. |
3017
|
29 ## |
3449
|
30 ## If @var{nargin} is greater than zero, concatenate the arguments, |
|
31 ## separating them with @code{":"}. Set @code{LOADPATH} to the result |
|
32 ## and also return it. |
3017
|
33 ## |
|
34 ## No checks are made for duplicate elements. |
3449
|
35 ## @end deftypefn |
3017
|
36 |
|
37 ## Author: jwe |
|
38 |
4688
|
39 function retval = path (varargin) |
3017
|
40 |
4688
|
41 if (nargin > 0) |
3979
|
42 p = varargin{1}; |
3017
|
43 for i = 2:nargin |
3979
|
44 p = sprintf ("%s:%s", p, varargin{i}); |
3017
|
45 endfor |
|
46 LOADPATH = p; |
|
47 endif |
|
48 |
4688
|
49 if (LOADPATH(1) == ":") |
|
50 p = strcat (DEFAULT_LOADPATH, LOADPATH); |
|
51 else |
|
52 t = findstr (LOADPATH, "::"); |
|
53 if (any (t)) |
|
54 loc = t(1); |
|
55 p = strcat (LOADPATH(1:loc), DEFAULT_LOADPATH, LOADPATH(loc+1:end)); |
|
56 elseif (LOADPATH(end) == ":") |
|
57 p = strcat (LOADPATH, DEFAULT_LOADPATH); |
|
58 else |
|
59 p = LOADPATH; |
|
60 endif |
|
61 endif |
|
62 |
|
63 if (nargin == 0 && nargout == 0) |
|
64 puts ("\nOctave's search path contains the following directories:\n\n "); |
|
65 puts (strrep (p, ":", "\n ")); |
|
66 puts ("\n\n"); |
|
67 else |
|
68 retval = p; |
|
69 endif |
|
70 |
3017
|
71 endfunction |