Mercurial > hg > octave-nkf
annotate examples/myset.c @ 19022:5eca3080c7cd
maint: Merge Stefan's changesets onto default after verification.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 14 Jun 2014 13:24:46 -0700 |
parents | 224e76250443 |
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; | |
9 | |
10 if (nrhs != 2 || ! mxIsString (prhs[0])) | |
11 mexErrMsgTxt ("expects symbol name and value"); | |
12 | |
13 str = mxArrayToString (prhs[0]); | |
14 | |
15 v = mexGetArray (str, "global"); | |
16 | |
17 if (v) | |
18 { | |
19 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
|
20 mexCallMATLAB (0, NULL, 1, &v, "disp"); |
5864 | 21 } |
22 | |
23 v = mexGetArray (str, "caller"); | |
24 | |
25 if (v) | |
26 { | |
27 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
|
28 mexCallMATLAB (0, NULL, 1, &v, "disp"); |
5864 | 29 } |
30 | |
31 // WARNING!! Can't do this in MATLAB! Must copy variable first. | |
17791
224e76250443
Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents:
16867
diff
changeset
|
32 mxSetName (prhs[1], str); |
5864 | 33 mexPutArray (prhs[1], "caller"); |
34 } |