comparison scripts/miscellaneous/path.m @ 4688:eaa2caaa35d6

[project @ 2004-01-07 21:54:56 by jwe]
author jwe
date Wed, 07 Jan 2004 21:54:56 +0000
parents ed92d574b55b
children 4c8a2e4e0717
comparison
equal deleted inserted replaced
4687:e95c86d48732 4688:eaa2caaa35d6
34 ## No checks are made for duplicate elements. 34 ## No checks are made for duplicate elements.
35 ## @end deftypefn 35 ## @end deftypefn
36 36
37 ## Author: jwe 37 ## Author: jwe
38 38
39 function p = path (varargin) 39 function retval = path (varargin)
40 40
41 if (nargin == 0) 41 if (nargin > 0)
42 if (nargout == 0)
43 puts ("\nLOADPATH contains the following directories:\n\n ");
44 puts (strrep (DEFAULT_LOADPATH, ":", "\n "));
45 puts ("\n\n");
46 else
47 p = LOADPATH;
48 endif
49 else
50 p = varargin{1}; 42 p = varargin{1};
51 for i = 2:nargin 43 for i = 2:nargin
52 p = sprintf ("%s:%s", p, varargin{i}); 44 p = sprintf ("%s:%s", p, varargin{i});
53 endfor 45 endfor
54 LOADPATH = p; 46 LOADPATH = p;
55 endif 47 endif
56 48
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
57 endfunction 71 endfunction