Accessing string values from octave_value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Accessing string values from octave_value

shamikam
Hello,

How do I access string values from octave_value and octave_value_list?

I have the following code written in c++

octave_value path_dir=feval("pwd");
std::string pd  = path_dir.string_value ();
std::cout <<pd<< std::endl;


When I run this code, I get the following error-

octave_base_value::convert_to_str_internal (): wrong type argument 'cs-list'

How do I resolve this error?

Regards,
Shamika

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Accessing string values from octave_value

Olaf Till-2
On Wed, Jul 12, 2017 at 02:34:40PM +0530, Shamika Mohanan wrote:
> octave_value path_dir=feval("pwd");

Correct would be:

octave_value_list outlist = feval ("pwd");

Your code constructs an octave_value from an octave_value_list. The
result can't be converted to a string.

> std::string pd  = path_dir.string_value ();

This gets:

std::string pd  = outlist(0).string_value ();

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

signature.asc (836 bytes) Download Attachment
Loading...