[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
more help with writing C++ functions for Octave
From: |
John W. Eaton |
Subject: |
more help with writing C++ functions for Octave |
Date: |
Wed, 6 May 1998 09:22:19 -0500 (CDT) |
On 6-May-1998, Karen L. Kalat <address@hidden> wrote:
| I have a function successfully compiled that uses a C library
| of my own. Now I'm trying to figure out how to "cast" octave-type variables
| to values with datatypes I can pass to my C functions.
| For example:
| If I read in a bunch of things in args how do I get a char*
| out of arg(0)?
|
| octave:1> myfunction("charstring")
You can use something like
DEFUN(myfunction, args, ,
"help text"
{
octave_value retval;
string arg = args(0).string_value;
my_c_function (arg.c_str ());
return retval;
}
Of course, you might want to add some error checking too.
Take a look at the functions distributed with Octave for more
examples. The list of functions that extract data from octave_value
objects are declared in the header file ov.h.
jwe