From help-octave-request at bevo dot che dot wisc dot edu Sun Feb 1 01:53:07 2004 Subject: Re: varargout form a DLD function From: Shai Ayal To: Geraint Paul Bevan CC: help-octave Date: Sun, 01 Feb 2004 15:51:13 +0200 This is a multi-part message in MIME format. --------------000103040701040105060603 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Essentially you suggest returning a list for the function. This is a nice trick which solves my problem completely Thanks for the help Shai Geraint Paul Bevan wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Shai Ayal wrote on 01/29/04 22:10: > | Hi all, > | > | I am trying to return a variable number of arguments from a DLD function > | > > | > | however, I cannot recover these arguments at the command line: > > | > | Note that if I know the number of arguments I can get them as in line 4. > | but what if I don't know beforehand ? Is there something similar to > | varargin{:} for output arguments ? > | > | Shai > | > > > You can return a variable number of arguments by returning an > octave_value_list as the first element of retval: > > > ~/test: > $ cat varargouttest.cc > #include > > DEFUN_DLD (varargouttest, args, nargout, "") > { > octave_value_list retval, retval2; > for (int i = 4; i >= 0; i--) { > retval2(i) = octave_value (1 + i); > } > retval(0) = retval2; > nargout = 5; > return retval; > } > ~/test: > $ mkoctfile varargouttest.cc > ~/test: > $ octave -q > octave:1> varargouttest > ans = > ( > ~ [1] = 1 > ~ [2] = 2 > ~ [3] = 3 > ~ [4] = 4 > ~ [5] = 5 > ) > octave:2> > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.2 (GNU/Linux) > > iEYEARECAAYFAkAZNV8ACgkQcXV3N50QmNMEpQCeJaBEFPh/HYp4A3z7oOUOPAsi > RYgAn2qQ2c6/CJNeAgBbXDa/Ai/WqCjP > =5JaE > -----END PGP SIGNATURE----- > > > > ------------------------------------------------------------- > Octave is freely available under the terms of the GNU GPL. > > Octave's home on the web: http://www.octave.org > How to fund new projects: http://www.octave.org/funding.html > Subscription information: http://www.octave.org/archive.html > ------------------------------------------------------------- > --------------000103040701040105060603 Content-Type: text/x-vcard; charset=utf8; name="shaia.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="shaia.vcf" begin:vcard fn:Shai Ayal n:Ayal;Shai org:BioControl Medical adr:;;3 Geron St.;Yahud;;56100;Israel email;internet:shaia at biocontrol dot co dot il title:Scientific Project Manager tel;work:+972 3 6322126 ext 223 tel;fax:+972 3 6322125 x-mozilla-html:FALSE version:2.1 end:vcard --------------000103040701040105060603-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------