Mercurial > hg > octave-lyh
annotate examples/fortdemo.cc @ 17484:9849075a5da6
allow objects to load if constructor fails but loadobj method succeeds
* ov-class.cc (octave_class::reconstruct_exemplar): Don't throw error
if constructor execution fails.
(octave_class::load_ascii, octave_class::load_binary,
octave_class::load_hdf5): Attempt to handle exemplar and loadobj
method consistently.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 24 Sep 2013 16:41:20 -0400 |
parents | be41c30bcb44 |
children |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/f77-fcn.h> | |
3 | |
12174 | 4 extern "C" |
6572 | 5 { |
12174 | 6 F77_RET_T |
7 F77_FUNC (fortsub, FORTSUB) | |
8 (const int&, double*, F77_CHAR_ARG_DECL | |
6572 | 9 F77_CHAR_ARG_LEN_DECL); |
10 } | |
11 | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
12 DEFUN_DLD (fortdemo, args, , "Fortran Demo") |
6572 | 13 { |
12174 | 14 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:
12174
diff
changeset
|
15 int nargin = args.length (); |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
16 |
6572 | 17 if (nargin != 1) |
18 print_usage (); | |
19 else | |
20 { | |
21 NDArray a = args(0).array_value (); | |
22 if (! error_state) | |
23 { | |
24 double *av = a.fortran_vec (); | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
25 octave_idx_type na = a.numel (); |
6572 | 26 OCTAVE_LOCAL_BUFFER (char, ctmp, 128); |
27 | |
12174 | 28 F77_XFCN (fortsub, FORTSUB, (na, av, ctmp |
7081 | 29 F77_CHAR_ARG_LEN (128))); |
6572 | 30 |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
31 retval(1) = std::string (ctmp); |
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
32 retval(0) = a; |
6572 | 33 } |
34 } | |
35 return retval; | |
36 } |