1 ## Copyright (C) 2012 John W. Eaton
3 ## This file is part of Octave.
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 3 of the License, or (at
8 ## your option) any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} setpref (@var{group}, @var{pref}, @var{val})
21 ## Set a preference @var{pref} to the given @var{val} in the named
22 ## preference group @var{group}.
24 ## The named preference group must be a character string.
26 ## The preference @var{pref} may be a character string or a cell array
27 ## of character strings. The corresponding value @var{val} may be any
28 ## value, or, if @var{pref} is a cell array of strings, @var{val}
29 ## must be a cell array of values with the same size as @var{pref}.
31 ## If the named preference or group does not exist, it is added.
32 ## @seealso{addpref, getpref, ispref, rmpref}
37 function setpref (group, pref, val)
43 prefs.(group).(pref) = val;
44 elseif (iscellstr (pref))
45 if (size_equal (pref, val))
47 prefs.(group).(pref{i}) = val;
50 error ("size mismatch for pref and val");
53 error ("expecting pref to be a character string or cellstr");
57 error ("expecting group to be a character string");
65 %% Testing these functions will require some care to avoid wiping out
66 %% existing (or creating unwanted) preferences for the user running the