# HG changeset patch # User jwe # Date 1157470404 0 # Node ID dadcfe8b7ba424f04c0cbeee8a703bb216a50570 # Parent 45f612d96d0ed922b58a46e55270b475b444c366 [project @ 2006-09-05 15:33:24 by jwe] diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2006-09-05 Alexander Barth + + * miscellaneous/parseparams.m: New function. + 2006-09-05 Rafael Laboissiere * miscellaneous/doc.m: Swap order of --file and --directory diff --git a/scripts/miscellaneous/parseparams.m b/scripts/miscellaneous/parseparams.m new file mode 100644 --- /dev/null +++ b/scripts/miscellaneous/parseparams.m @@ -0,0 +1,63 @@ +## Copyright (C) 2006 Alexander Barth +## +## This file is part of Octave. +## +## Octave 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, or (at your option) +## any later version. +## +## Octave 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 Octave; see the file COPYING. If not, write to the Free +## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + +## -*- texinfo -*- +## @deftypefn {Function File} {} [@var{reg}, @var{prop}] = parseparams (@var{params}) +## Return in @var{reg} the cell elements of @var{param} up to the first +## string element and in @var{prop} all remaining elements beginning +## with the first string element. For example +## +## @example +## [reg, prop] = parseparams (@{1, 2, "linewidth", 10@}) +## reg = +## { +## [1,1] = 1 +## [1,2] = 2 +## } +## prop = +## { +## [1,1] = linewidth +## [1,2] = 10 +## } +## @end example +## +## The parseparams function may be used to separate "regular" +## arguments and additional arguments given as property/value pairs of +## the @var{varargin} cell array. +## @seealso{varargin} +## @end deftypefn + +## Author: Alexander Barth +## Author: Aida Alvera Azcarate + +function [reg, prop] = parseparams (params) + + i = 1; + + while (i <= numel (params)) + if (ischar (params{i})) + break; + endif + i++; + endwhile + + reg = params(1:i-1); + prop = params(i:end); + +endfunction