5981
|
1 ## Copyright (C) 2006 Alexander Barth |
|
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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
5981
|
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 |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
5981
|
18 |
|
19 ## -*- texinfo -*- |
5996
|
20 ## @deftypefn {Function File} {[@var{reg}, @var{prop}] =} parseparams (@var{params}) |
5981
|
21 ## Return in @var{reg} the cell elements of @var{param} up to the first |
|
22 ## string element and in @var{prop} all remaining elements beginning |
5997
|
23 ## with the first string element. For example |
5981
|
24 ## |
|
25 ## @example |
5996
|
26 ## @group |
5981
|
27 ## [reg, prop] = parseparams (@{1, 2, "linewidth", 10@}) |
|
28 ## reg = |
5996
|
29 ## @{ |
5981
|
30 ## [1,1] = 1 |
|
31 ## [1,2] = 2 |
5996
|
32 ## @} |
5981
|
33 ## prop = |
5996
|
34 ## @{ |
5981
|
35 ## [1,1] = linewidth |
|
36 ## [1,2] = 10 |
5996
|
37 ## @} |
|
38 ## @end group |
5981
|
39 ## @end example |
|
40 ## |
5996
|
41 ## The parseparams function may be used to separate 'regular' |
5981
|
42 ## arguments and additional arguments given as property/value pairs of |
|
43 ## the @var{varargin} cell array. |
|
44 ## @seealso{varargin} |
|
45 ## @end deftypefn |
|
46 |
|
47 ## Author: Alexander Barth <abarth93@users.sourceforge.net> |
|
48 ## Author: Aida Alvera Azcarate <aida@netecho.info> |
|
49 |
|
50 function [reg, prop] = parseparams (params) |
|
51 |
|
52 i = 1; |
|
53 |
|
54 while (i <= numel (params)) |
|
55 if (ischar (params{i})) |
|
56 break; |
|
57 endif |
|
58 i++; |
|
59 endwhile |
|
60 |
|
61 reg = params(1:i-1); |
|
62 prop = params(i:end); |
|
63 |
|
64 endfunction |