Mercurial > octave-nkf
annotate 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 |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/Cell.h> | |
3 | |
12174 | 4 DEFUN_DLD (celldemo, args, , "Cell Demo") |
6572 | 5 { |
6 octave_value_list retval; | |
20578
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
7 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
8 if (args.length () != 1) |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
9 print_usage (); |
6572 | 10 |
20578
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
11 Cell c = args(0).cell_value (); |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
12 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
13 for (octave_idx_type i = 0; i < c.numel (); i++) |
6572 | 14 { |
20578
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
15 retval(i) = c(i); // using operator syntax |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
16 //retval(i) = c.elem (i); // using method syntax |
6572 | 17 } |
9053
4295d634797d
remove copyright notices from example files
John W. Eaton <jwe@octave.org>
parents:
7081
diff
changeset
|
18 |
6572 | 19 return retval; |
20 } |