parseparams

Alexander Barth <[email protected]> Sun, 03 Sep 2006 18:37:19 -0400
Newsgroups gmane.comp.gnu.octave.sources
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------070404020006080402020704
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi all,

I implemented the parseparams function. To my knowledge this function is missing in octave. The
function is useful to separate regular function arguments and property/value pairs.

Would this be a candidate for inclusion in octave?

Thanks,
Alex

-- 
_______________________________________________________________

  Alexander Barth

  Ocean Circulation Group
  University of South Florida
  College of Marine Science
  140 Seventh Avenue South
  St. Petersburg, Florida  33701
  USA

  Phone: +1-727-553-3508     FAX:   +1-727-553-1189

_______________________________________________________________

--------------070404020006080402020704
Content-Type: text/x-objcsrc;
 name="parseparams.m"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="parseparams.m"

## Copyright (C) 2006 Alexander Barth <[email protected]>
##
## This program is free software; it 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 file; see the file COPYING.  If not, write to the
## Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, 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.
##
## Example:
## @example
## [@var{reg},@var{prop}] = parseparams(@{[1 2],[2 3],'linewidth',10@})
## @var{reg} is @{[1 2],[2 3]@}
## @var{prop} is @{'linewidth',10@}
## @end example
##
## parseparams is often used to separate "regular" arguments and additional arguments given as property/value pairs of the @var{varargin} cell array.
##
## @seealso{varargin}
## @end deftypefn

## Authors: Alexander Barth <[email protected]>
##          Aida Alvera Azcarate <[email protected]>

function [reg,prop] = parseparams(params)

  i=1; 

  while (i<=length(params)); 
    if ischar(params{i}); 
      break; 
    endif
    i=i+1; 
  endwhile

  reg=params(1:i-1);
  prop=params(i:end);

endfunction

--------------070404020006080402020704
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Octave-sources mailing list
[email protected]
https://www.cae.wisc.edu/mailman/listinfo/octave-sources

--------------070404020006080402020704--