Mercurial > hg > octave-nkf
comparison examples/code/funcdemo.cc @ 20753: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
20752:c547458dc10e | 20753:2f8500ca91d3 |
---|---|
2 #include <octave/parse.h> | 2 #include <octave/parse.h> |
3 | 3 |
4 DEFUN_DLD (funcdemo, args, nargout, "Function Demo") | 4 DEFUN_DLD (funcdemo, args, nargout, "Function Demo") |
5 { | 5 { |
6 octave_value_list retval; | 6 octave_value_list retval; |
7 | |
7 int nargin = args.length (); | 8 int nargin = args.length (); |
8 | 9 |
9 if (nargin < 2) | 10 if (nargin < 2) |
10 print_usage (); | 11 print_usage (); |
12 | |
13 octave_value_list newargs; | |
14 | |
15 for (octave_idx_type i = nargin - 1; i > 0; i--) | |
16 newargs(i-1) = args(i); | |
17 | |
18 if (args(0).is_function_handle () || args(0).is_inline_function ()) | |
19 { | |
20 octave_function *fcn = args(0).function_value (); | |
21 | |
22 retval = feval (fcn, newargs, nargout); | |
23 } | |
24 else if (args(0).is_string ()) | |
25 { | |
26 std::string fcn = args(0).string_value (); | |
27 | |
28 retval = feval (fcn, newargs, nargout); | |
29 } | |
11 else | 30 else |
12 { | 31 error ("funcdemo: INPUT must be string, inline, or function handle"); |
13 octave_value_list newargs; | 32 |
14 for (octave_idx_type i = nargin - 1; i > 0; i--) | |
15 newargs(i-1) = args(i); | |
16 if (args(0).is_function_handle () || args(0).is_inline_function ()) | |
17 { | |
18 octave_function *fcn = args(0).function_value (); | |
19 if (! error_state) | |
20 retval = feval (fcn, newargs, nargout); | |
21 } | |
22 else if (args(0).is_string ()) | |
23 { | |
24 std::string fcn = args(0).string_value (); | |
25 if (! error_state) | |
26 retval = feval (fcn, newargs, nargout); | |
27 } | |
28 else | |
29 error ("funcdemo: INPUT must be string, inline, or function handle"); | |
30 } | |
31 return retval; | 33 return retval; |
32 } | 34 } |