Mercurial > octave-nkf
annotate examples/code/myset.c @ 20595:c1a6c31ac29a
eliminate more simple uses of error_state
* ov-classdef.cc: Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Oct 2015 00:20:02 -0400 |
parents | 5c42ff6f0eb1 |
children |
rev | line source |
---|---|
5864 | 1 #include "mex.h" |
2 | |
3 void | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
4 mexFunction (int nlhs, mxArray* plhs[], |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
5 int nrhs, const mxArray* prhs[]) |
5864 | 6 { |
7 char *str; | |
8 mxArray *v; | |
20297 | 9 int found = 0; |
5864 | 10 |
20297 | 11 if (nrhs != 2 || ! mxIsChar (prhs[0])) |
12 mexErrMsgTxt ("Arguments must be a symbol name and a value"); | |
5864 | 13 |
14 str = mxArrayToString (prhs[0]); | |
15 | |
20297 | 16 // FIXME: If variable does not exist, error is reported which prevents |
17 // subsequent mexGetArray function from working. | |
5864 | 18 v = mexGetArray (str, "global"); |
19 if (v) | |
20 { | |
21 mexPrintf ("%s is a global variable with the following value:\n", str); | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
22 mexCallMATLAB (0, NULL, 1, &v, "disp"); |
20297 | 23 found = 1; |
5864 | 24 } |
25 | |
20297 | 26 if (! found) |
27 v = mexGetArray (str, "caller"); | |
5864 | 28 |
20297 | 29 if (! found && v) |
5864 | 30 { |
31 mexPrintf ("%s is a caller variable with the following value:\n", str); | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
32 mexCallMATLAB (0, NULL, 1, &v, "disp"); |
5864 | 33 } |
34 | |
35 // WARNING!! Can't do this in MATLAB! Must copy variable first. | |
20297 | 36 mexPutVariable ("caller", str, prhs[1]); |
5864 | 37 } |