Mercurial > hg > octave-nkf
changeset 5740:b2637e696bb4
[project @ 2006-04-05 16:51:08 by jwe]
author | jwe |
---|---|
date | Wed, 05 Apr 2006 16:51:08 +0000 |
parents | d090d39bb82c |
children | 07421c4e0312 |
files | scripts/path/setpath.m |
diffstat | 1 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/scripts/path/setpath.m @@ -0,0 +1,43 @@ +## Copyright (C) 2006 John W. Eaton +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +## -*- texinfo -*- +## @deftypefn {Function File} @var{opath} setpath (@var{npath}) +## Set @code{LOADPATH} to @var{path} and return the previous value. +## +## @seealso{LOADPATH, addpath, rmpath, savepath} +## @end deftypefn + +## PKGADD: mark_as_command setpath + +function opath = setpath (npath) + + if (nargin == 1) + if (nargout > 0) + opath = LOADPATH; + endif + ## XXX FIXME XXX -- perhaps validate elements of npath to make sure + ## they are existing directories? + if (ischar (npath)) + LOADPATH = npath; + else + error ("setpath: expecting argument to be a character string"); + endif + else + usage ("opath = setpath (npath)"); + endif + +endfunction