Mercurial > octave-nkf
diff libinterp/corefcn/octave-link.cc @ 20616:fd0efcdb3718
use new string_value method to handle value extraction errors
* dirfns.cc, file-io.cc, gammainc.cc, help.cc, load-path.cc,
octave-link.cc, qz.cc, regexp.cc, strfns.cc, syscalls.cc, time.cc,
variables.cc: Use new string_value method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 08 Oct 2015 19:00:51 -0400 |
parents | 7ac907da9fba |
children |
line wrap: on
line diff
--- a/libinterp/corefcn/octave-link.cc Thu Oct 08 17:55:57 2015 -0400 +++ b/libinterp/corefcn/octave-link.cc Thu Oct 08 19:00:51 2015 -0400 @@ -122,29 +122,19 @@ if (args.length () == 1) { - std::string file = args(0).string_value (); + std::string file = args(0).string_value ("expecting file name as argument"); - if (! error_state) - { - flush_octave_stdout (); + flush_octave_stdout (); - retval = octave_link::edit_file (file); - } - else - error ("expecting file name as argument"); + retval = octave_link::edit_file (file); } else if (args.length () == 2) { - std::string file = args(0).string_value (); + std::string file = args(0).string_value ("expecting file name as first argument"); - if (! error_state) - { - flush_octave_stdout (); + flush_octave_stdout (); - retval = octave_link::prompt_new_edit_file (file); - } - else - error ("expecting file name as first argument"); + retval = octave_link::prompt_new_edit_file (file); } return retval; @@ -160,18 +150,13 @@ if (args.length () == 3) { - std::string dlg = args(0).string_value (); - std::string msg = args(1).string_value (); - std::string title = args(2).string_value (); + std::string dlg = args(0).string_value ("invalid arguments"); + std::string msg = args(1).string_value ("invalid arguments"); + std::string title = args(2).string_value ("invalid arguments"); - if (! error_state) - { - flush_octave_stdout (); + flush_octave_stdout (); - retval = octave_link::message_dialog (dlg, msg, title); - } - else - error ("invalid arguments"); + retval = octave_link::message_dialog (dlg, msg, title); } return retval; @@ -187,22 +172,17 @@ if (args.length () == 6) { - std::string msg = args(0).string_value (); - std::string title = args(1).string_value (); - std::string btn1 = args(2).string_value (); - std::string btn2 = args(3).string_value (); - std::string btn3 = args(4).string_value (); - std::string btndef = args(5).string_value (); + std::string msg = args(0).string_value ("invalid arguments"); + std::string title = args(1).string_value ("invalid arguments"); + std::string btn1 = args(2).string_value ("invalid arguments"); + std::string btn2 = args(3).string_value ("invalid arguments"); + std::string btn3 = args(4).string_value ("invalid arguments"); + std::string btndef = args(5).string_value ("invalid arguments"); - if (! error_state) - { - flush_octave_stdout (); + flush_octave_stdout (); - retval = octave_link::question_dialog (msg, title, btn1, btn2, btn3, - btndef); - } - else - error ("invalid arguments"); + retval = octave_link::question_dialog (msg, title, btn1, btn2, btn3, + btndef); } return retval; @@ -327,30 +307,25 @@ std::string ok_string = args(6).string_value (); std::string cancel_string = args(7).string_value (); - if (! error_state) - { - flush_octave_stdout (); + flush_octave_stdout (); - std::pair<std::list<int>, int> result - = octave_link::list_dialog (list_lst, mode, width, height, - initial_lst, name, prompt_lst, - ok_string, cancel_string); + std::pair<std::list<int>, int> result + = octave_link::list_dialog (list_lst, mode, width, height, + initial_lst, name, prompt_lst, + ok_string, cancel_string); - std::list<int> items_lst = result.first; - nel = items_lst.size (); - Matrix items (dim_vector (1, nel)); - octave_idx_type i = 0; - for (std::list<int>::iterator it = items_lst.begin (); - it != items_lst.end (); it++) - { - items.xelem(i++) = *it; - } + std::list<int> items_lst = result.first; + nel = items_lst.size (); + Matrix items (dim_vector (1, nel)); + octave_idx_type i = 0; + for (std::list<int>::iterator it = items_lst.begin (); + it != items_lst.end (); it++) + { + items.xelem(i++) = *it; + } - retval(1) = result.second; - retval(0) = items; - } - else - error ("invalid arguments"); + retval(1) = result.second; + retval(0) = items; } return retval; @@ -392,27 +367,22 @@ for (octave_idx_type i = 0; i < nel; i++) defaults_lst.push_back (tmp(i)); - if (! error_state) - { - flush_octave_stdout (); + flush_octave_stdout (); - std::list<std::string> items_lst - = octave_link::input_dialog (prompt_lst, title, nr, nc, - defaults_lst); + std::list<std::string> items_lst + = octave_link::input_dialog (prompt_lst, title, nr, nc, + defaults_lst); - nel = items_lst.size (); - Cell items (dim_vector (nel, 1)); - octave_idx_type i = 0; - for (std::list<std::string>::iterator it = items_lst.begin (); - it != items_lst.end (); it++) - { - items.xelem(i++) = *it; - } + nel = items_lst.size (); + Cell items (dim_vector (nel, 1)); + octave_idx_type i = 0; + for (std::list<std::string>::iterator it = items_lst.begin (); + it != items_lst.end (); it++) + { + items.xelem(i++) = *it; + } - retval = items; - } - else - error ("invalid arguments"); + retval = items; } return retval;