Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
20615:729a85dafba8 | 20616:fd0efcdb3718 |
---|---|
120 { | 120 { |
121 octave_value retval; | 121 octave_value retval; |
122 | 122 |
123 if (args.length () == 1) | 123 if (args.length () == 1) |
124 { | 124 { |
125 std::string file = args(0).string_value (); | 125 std::string file = args(0).string_value ("expecting file name as argument"); |
126 | 126 |
127 if (! error_state) | 127 flush_octave_stdout (); |
128 { | 128 |
129 flush_octave_stdout (); | 129 retval = octave_link::edit_file (file); |
130 | |
131 retval = octave_link::edit_file (file); | |
132 } | |
133 else | |
134 error ("expecting file name as argument"); | |
135 } | 130 } |
136 else if (args.length () == 2) | 131 else if (args.length () == 2) |
137 { | 132 { |
138 std::string file = args(0).string_value (); | 133 std::string file = args(0).string_value ("expecting file name as first argument"); |
139 | 134 |
140 if (! error_state) | 135 flush_octave_stdout (); |
141 { | 136 |
142 flush_octave_stdout (); | 137 retval = octave_link::prompt_new_edit_file (file); |
143 | |
144 retval = octave_link::prompt_new_edit_file (file); | |
145 } | |
146 else | |
147 error ("expecting file name as first argument"); | |
148 } | 138 } |
149 | 139 |
150 return retval; | 140 return retval; |
151 } | 141 } |
152 | 142 |
158 { | 148 { |
159 octave_value retval; | 149 octave_value retval; |
160 | 150 |
161 if (args.length () == 3) | 151 if (args.length () == 3) |
162 { | 152 { |
163 std::string dlg = args(0).string_value (); | 153 std::string dlg = args(0).string_value ("invalid arguments"); |
164 std::string msg = args(1).string_value (); | 154 std::string msg = args(1).string_value ("invalid arguments"); |
165 std::string title = args(2).string_value (); | 155 std::string title = args(2).string_value ("invalid arguments"); |
166 | 156 |
167 if (! error_state) | 157 flush_octave_stdout (); |
168 { | 158 |
169 flush_octave_stdout (); | 159 retval = octave_link::message_dialog (dlg, msg, title); |
170 | |
171 retval = octave_link::message_dialog (dlg, msg, title); | |
172 } | |
173 else | |
174 error ("invalid arguments"); | |
175 } | 160 } |
176 | 161 |
177 return retval; | 162 return retval; |
178 } | 163 } |
179 | 164 |
185 { | 170 { |
186 octave_value retval; | 171 octave_value retval; |
187 | 172 |
188 if (args.length () == 6) | 173 if (args.length () == 6) |
189 { | 174 { |
190 std::string msg = args(0).string_value (); | 175 std::string msg = args(0).string_value ("invalid arguments"); |
191 std::string title = args(1).string_value (); | 176 std::string title = args(1).string_value ("invalid arguments"); |
192 std::string btn1 = args(2).string_value (); | 177 std::string btn1 = args(2).string_value ("invalid arguments"); |
193 std::string btn2 = args(3).string_value (); | 178 std::string btn2 = args(3).string_value ("invalid arguments"); |
194 std::string btn3 = args(4).string_value (); | 179 std::string btn3 = args(4).string_value ("invalid arguments"); |
195 std::string btndef = args(5).string_value (); | 180 std::string btndef = args(5).string_value ("invalid arguments"); |
196 | 181 |
197 if (! error_state) | 182 flush_octave_stdout (); |
198 { | 183 |
199 flush_octave_stdout (); | 184 retval = octave_link::question_dialog (msg, title, btn1, btn2, btn3, |
200 | 185 btndef); |
201 retval = octave_link::question_dialog (msg, title, btn1, btn2, btn3, | |
202 btndef); | |
203 } | |
204 else | |
205 error ("invalid arguments"); | |
206 } | 186 } |
207 | 187 |
208 return retval; | 188 return retval; |
209 } | 189 } |
210 | 190 |
325 for (octave_idx_type i = 0; i < nel; i++) | 305 for (octave_idx_type i = 0; i < nel; i++) |
326 prompt_lst.push_back (plist(i)); | 306 prompt_lst.push_back (plist(i)); |
327 std::string ok_string = args(6).string_value (); | 307 std::string ok_string = args(6).string_value (); |
328 std::string cancel_string = args(7).string_value (); | 308 std::string cancel_string = args(7).string_value (); |
329 | 309 |
330 if (! error_state) | 310 flush_octave_stdout (); |
311 | |
312 std::pair<std::list<int>, int> result | |
313 = octave_link::list_dialog (list_lst, mode, width, height, | |
314 initial_lst, name, prompt_lst, | |
315 ok_string, cancel_string); | |
316 | |
317 std::list<int> items_lst = result.first; | |
318 nel = items_lst.size (); | |
319 Matrix items (dim_vector (1, nel)); | |
320 octave_idx_type i = 0; | |
321 for (std::list<int>::iterator it = items_lst.begin (); | |
322 it != items_lst.end (); it++) | |
331 { | 323 { |
332 flush_octave_stdout (); | 324 items.xelem(i++) = *it; |
333 | |
334 std::pair<std::list<int>, int> result | |
335 = octave_link::list_dialog (list_lst, mode, width, height, | |
336 initial_lst, name, prompt_lst, | |
337 ok_string, cancel_string); | |
338 | |
339 std::list<int> items_lst = result.first; | |
340 nel = items_lst.size (); | |
341 Matrix items (dim_vector (1, nel)); | |
342 octave_idx_type i = 0; | |
343 for (std::list<int>::iterator it = items_lst.begin (); | |
344 it != items_lst.end (); it++) | |
345 { | |
346 items.xelem(i++) = *it; | |
347 } | |
348 | |
349 retval(1) = result.second; | |
350 retval(0) = items; | |
351 } | 325 } |
352 else | 326 |
353 error ("invalid arguments"); | 327 retval(1) = result.second; |
328 retval(0) = items; | |
354 } | 329 } |
355 | 330 |
356 return retval; | 331 return retval; |
357 } | 332 } |
358 | 333 |
390 nel = tmp.numel (); | 365 nel = tmp.numel (); |
391 std::list<std::string> defaults_lst; | 366 std::list<std::string> defaults_lst; |
392 for (octave_idx_type i = 0; i < nel; i++) | 367 for (octave_idx_type i = 0; i < nel; i++) |
393 defaults_lst.push_back (tmp(i)); | 368 defaults_lst.push_back (tmp(i)); |
394 | 369 |
395 if (! error_state) | 370 flush_octave_stdout (); |
371 | |
372 std::list<std::string> items_lst | |
373 = octave_link::input_dialog (prompt_lst, title, nr, nc, | |
374 defaults_lst); | |
375 | |
376 nel = items_lst.size (); | |
377 Cell items (dim_vector (nel, 1)); | |
378 octave_idx_type i = 0; | |
379 for (std::list<std::string>::iterator it = items_lst.begin (); | |
380 it != items_lst.end (); it++) | |
396 { | 381 { |
397 flush_octave_stdout (); | 382 items.xelem(i++) = *it; |
398 | |
399 std::list<std::string> items_lst | |
400 = octave_link::input_dialog (prompt_lst, title, nr, nc, | |
401 defaults_lst); | |
402 | |
403 nel = items_lst.size (); | |
404 Cell items (dim_vector (nel, 1)); | |
405 octave_idx_type i = 0; | |
406 for (std::list<std::string>::iterator it = items_lst.begin (); | |
407 it != items_lst.end (); it++) | |
408 { | |
409 items.xelem(i++) = *it; | |
410 } | |
411 | |
412 retval = items; | |
413 } | 383 } |
414 else | 384 |
415 error ("invalid arguments"); | 385 retval = items; |
416 } | 386 } |
417 | 387 |
418 return retval; | 388 return retval; |
419 } | 389 } |
420 | 390 |