help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: varargout form a DLD function


From: Shai Ayal
Subject: Re: varargout form a DLD function
Date: Sun, 01 Feb 2004 15:51:13 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031210 Thunderbird/0.5a

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 <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
-------------------------------------------------------------

Attachment: shaia.vcf
Description: Vcard


reply via email to

[Prev in Thread] Current Thread [Next in Thread]