[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
how to return vector of strings?
From: |
John W. Eaton |
Subject: |
how to return vector of strings? |
Date: |
Tue, 22 Apr 1997 12:16:55 -0500 |
On 22-Apr-1997, Tom Goles <address@hidden> wrote:
| I'm trying to return a vector of character strings from dynamically
| loadable c++ function (.oct file).
| For example, if my function is called 'Test' then from octave I'd like
| to call it as follows:
|
| octave> a = Test()
| a =
|
| Hello
| world
|
| octave>
|
| In other words, the vector that gets returned should be the same as if
| I simply typed:
|
| octave> a = ["Hello";"world"]
| a =
|
| Hello
| world
Use Octave's string_vector class (header file is str-vec.h,
distributed in the liboctave directory).
#include <octave/oct.h>
DEFUN_DLD (test, , ,
"usage: test ()\n\
\n\
Return a friendly array of strings.")
{
string_vector retval (11);
retval(0) = "hello";
retval(1) = "world";
retval(2) = "these";
retval(3) = "are";
retval(4) = "some";
retval(5) = "strings";
retval(6) = "in";
retval(7) = "a";
retval(8) = "friendly";
retval(9) = "string";
retval(10) = "vector";
return retval;
}
jwe