On Oct 10, 2009, at 5:16 PM, Juergen Rose wrote:
Am Samstag, den 10.10.2009, 10:48 +0000 schrieb address@hidden:
did you see varargin?
Doug
Subject: getopt
From: address@hidden
To: address@hidden
Date: Sat, 10 Oct 2009 19:55:35 +0200
Hi,
I am looking for a possibility to evaluate the arguments passed
to a
octave script similar to getopt[s] in bash or Getopt::Std in perl.
Any hints are appreciated.
Hi Doug,
I don't understand, what 'varargin' has to do with 'getopt'.
octave:1> help varargin
-- Keyword: varargin
Pass an arbitrary number of arguments into a function.
See also: varargout, nargin, nargout
I need a function, which I can use to parse arg_list = argv() and
which
can distinguish between allowed and not allowed options, and between
options with and without additional parameter.
I.e., I look for something like in Perl:
use Getopt::Std;
my $opts="dhS:o:N:n:";
my $options={};
getopts($opts,$options);
if (defined $options->{d}) {$DBG_LVL=$options->{d};}
if (defined $options->{h}) {usage(); exit 0;}
if (defined $options->{S}) {$Seed=$options->{S};}
..
Regards Juergen
Within a function ...
nargin = the number of arguments passed.
varargin{n} = the nth argument
The variables nargout and vargout are the output counterparts.
Below is a very simple example illustrating how varargin works.
octave:1> function test_varargin (varargin)
varargin{:}
end
octave:2> test_varargin (1, 2, 3, "a", "b", "c")
ans = 1
ans = 2
ans = 3
ans = a
ans = b
ans = c
octave:3>
Ben