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 |
|
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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
5996
|
21 ## @deftypefn {Function File} {[@var{reg}, @var{prop}] =} parseparams (@var{params}) |
5981
|
22 ## Return in @var{reg} the cell elements of @var{param} up to the first |
|
23 ## string element and in @var{prop} all remaining elements beginning |
5997
|
24 ## with the first string element. For example |
5981
|
25 ## |
|
26 ## @example |
5996
|
27 ## @group |
5981
|
28 ## [reg, prop] = parseparams (@{1, 2, "linewidth", 10@}) |
|
29 ## reg = |
5996
|
30 ## @{ |
5981
|
31 ## [1,1] = 1 |
|
32 ## [1,2] = 2 |
5996
|
33 ## @} |
5981
|
34 ## prop = |
5996
|
35 ## @{ |
5981
|
36 ## [1,1] = linewidth |
|
37 ## [1,2] = 10 |
5996
|
38 ## @} |
|
39 ## @end group |
5981
|
40 ## @end example |
|
41 ## |
5996
|
42 ## The parseparams function may be used to separate 'regular' |
5981
|
43 ## arguments and additional arguments given as property/value pairs of |
|
44 ## the @var{varargin} cell array. |
|
45 ## @seealso{varargin} |
|
46 ## @end deftypefn |
|
47 |
|
48 ## Author: Alexander Barth <abarth93@users.sourceforge.net> |
|
49 ## Author: Aida Alvera Azcarate <aida@netecho.info> |
|
50 |
|
51 function [reg, prop] = parseparams (params) |
|
52 |
|
53 i = 1; |
|
54 |
|
55 while (i <= numel (params)) |
|
56 if (ischar (params{i})) |
|
57 break; |
|
58 endif |
|
59 i++; |
|
60 endwhile |
|
61 |
|
62 reg = params(1:i-1); |
|
63 prop = params(i:end); |
|
64 |
|
65 endfunction |