Octave logo Octave-Forge - Extra packages for GNU Octave
Home · Packages · Developers · Documentation · Function Reference · FAQ · Bugs · Mailing Lists · Links · SVN
  • Main Page
  • Classes
  • Files

examples/myset.c

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2006, 2007 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #include "mex.h"
00024 
00025 void
00026 mexFunction (int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
00027 {
00028   char *str;
00029   mxArray *v;
00030 
00031   if (nrhs != 2 || ! mxIsString (prhs[0]))
00032     mexErrMsgTxt ("expects symbol name and value");
00033 
00034   str = mxArrayToString (prhs[0]);
00035 
00036   v = mexGetArray (str, "global");
00037 
00038   if (v)
00039     {
00040       mexPrintf ("%s is a global variable with the following value:\n", str);
00041       mexCallMATLAB (0, 0, 1, &v, "disp");
00042     }
00043 
00044   v = mexGetArray (str, "caller");
00045 
00046   if (v)
00047     {
00048       mexPrintf ("%s is a caller variable with the following value:\n", str);
00049       mexCallMATLAB (0, 0, 1, &v, "disp");
00050     }
00051 
00052   // WARNING!! Can't do this in MATLAB!  Must copy variable first.
00053   mxSetName (prhs[1], str);  
00054   mexPutArray (prhs[1], "caller");
00055 }
SourceForge.net Logo