Mercurial > hg > octave-lyh
comparison examples/funcdemo.cc @ 6572:8e7148b84b59
[project @ 2007-04-25 04:13:44 by jwe]
author | jwe |
---|---|
date | Wed, 25 Apr 2007 04:14:49 +0000 |
parents | |
children | 4270ded9ddc6 |
comparison
equal
deleted
inserted
replaced
6571:24d9e0799603 | 6572:8e7148b84b59 |
---|---|
1 #include <octave/oct.h> | |
2 #include <octave/parse.h> | |
3 | |
4 DEFUN_DLD (funcdemo, args, nargout, "Function Demo") | |
5 { | |
6 int nargin = args.length(); | |
7 octave_value_list retval; | |
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--) | |
15 newargs (i - 1) = args(i); | |
16 if (args(0).is_function_handle () | |
17 || args(0).is_inline_function ()) | |
18 { | |
19 octave_function *fcn = args(0).function_value (); | |
20 if (! error_state) | |
21 retval = feval (fcn, newargs, nargout); | |
22 } | |
23 else if (args(0).is_string ()) | |
24 { | |
25 std::string fcn = args (0).string_value (); | |
26 if (! error_state) | |
27 retval = feval (fcn, newargs, nargout); | |
28 } | |
29 else | |
30 error ("funcdemo: expected string, inline or function handle"); | |
31 } | |
32 return retval; | |
33 } |