help-octave
[Top][All Lists]
Advanced

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

C++: recover from feval error


From: David Shih
Subject: C++: recover from feval error
Date: Tue, 8 Mar 2011 20:26:53 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

I am tring to run octave scripts using an embedded octave initialized
using:

octave_main(argc, argv, true);

Scripts are called by:

eval_string(script_name, false, parse_status);

(Does eval_string block the C++ program until octave finishes processing the 
script?)

If the script indicated by script_name does not exist, subsequent
eval_string (or feval) calls do nothing if built-in functions are
called, and are undefined if custom scripts are called.

For example:

program1.cc

eval_string("script1")     // script 1 does not exist
>error: 'script1' undefined near line 1 column 1
feval("path")
>nothing happens: no error, nor is path called
feval("script2")           // script 2 exists
>error: 'script2' undefined near line 1 column 1


program2.cc

//eval_string("script1")
feval("path")
>...paths are printed
feval("script2")
>script2 is found and executed


eval_string does not seem to throw an exception, as I cannot catch it
with

try{
  feval("script1")
} catch (...) {
  cerr << "error: script1 is not found" << endl;
}

I tried calling:
recover_from_exception()

but subsequent calls eval_string/feval still do not work


On a related note...
What can I do to get variables created by the octave script, aside
from the following:

1. rewrite the script as function and use octave_value_list
X = feval(...)

2. octave_value x = eval_string("x", false, parse_status)


Thank you for you help.

David Shih
Graduate Student, University of Toronto, Canada


reply via email to

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