Mercurial > hg > octave-nkf
annotate examples/code/funcdemo.cc @ 20752:c547458dc10e
eliminate error_state from most header files
* defun-int.h, event-queue.h, graphics.in.h, oct-handle.h,
ov-classdef.h, misc/f77-fcn.h, unwind-prot.h:
Eliminate use of global error_state variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 03 Oct 2015 13:20:28 -0400 |
parents | c8240a60dd01 |
children | 2f8500ca91d3 |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/parse.h> | |
3 | |
4 DEFUN_DLD (funcdemo, args, nargout, "Function Demo") | |
5 { | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
6 octave_value_list retval; |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
9932
diff
changeset
|
7 int nargin = args.length (); |
6572 | 8 |
9 if (nargin < 2) | |
10 print_usage (); | |
11 else | |
12 { | |
13 octave_value_list newargs; | |
14 for (octave_idx_type i = nargin - 1; i > 0; i--) | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
15 newargs(i-1) = args(i); |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
16 if (args(0).is_function_handle () || args(0).is_inline_function ()) |
6572 | 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 { | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
24 std::string fcn = args(0).string_value (); |
6572 | 25 if (! error_state) |
26 retval = feval (fcn, newargs, nargout); | |
27 } | |
28 else | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
29 error ("funcdemo: INPUT must be string, inline, or function handle"); |
6572 | 30 } |
31 return retval; | |
32 } |