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 <octave/oct.h>
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
