comparison examples/code/celldemo.cc @ 20578:2f8500ca91d3

eliminate error_state from example files * addtwomatrices.cc, celldemo.cc, embedded.cc, fortrandemo.cc, funcdemo.cc, globaldemo.cc, helloworld.cc, make_int.cc, paramdemo.cc, stringdemo.cc, structdemo.cc, unwinddemo.cc: Eliminate use of global error_state variable.
author John W. Eaton <jwe@octave.org>
date Sat, 03 Oct 2015 16:05:27 -0400
parents c8240a60dd01
children
comparison
equal deleted inserted replaced
20577:c547458dc10e 20578:2f8500ca91d3
2 #include <octave/Cell.h> 2 #include <octave/Cell.h>
3 3
4 DEFUN_DLD (celldemo, args, , "Cell Demo") 4 DEFUN_DLD (celldemo, args, , "Cell Demo")
5 { 5 {
6 octave_value_list retval; 6 octave_value_list retval;
7 int nargin = args.length ();
8 7
9 if (nargin != 1) 8 if (args.length () != 1)
10 print_usage (); 9 print_usage ();
11 else 10
11 Cell c = args(0).cell_value ();
12
13 for (octave_idx_type i = 0; i < c.numel (); i++)
12 { 14 {
13 Cell c = args(0).cell_value (); 15 retval(i) = c(i); // using operator syntax
14 if (! error_state) 16 //retval(i) = c.elem (i); // using method syntax
15 for (octave_idx_type i = 0; i < c.numel (); i++)
16 {
17 retval(i) = c(i); // using operator syntax
18 //retval(i) = c.elem (i); // using method syntax
19 }
20 } 17 }
21 18
22 return retval; 19 return retval;
23 } 20 }