From help-octave-request at bevo dot che dot wisc dot edu Mon Dec 31 08:24:54 2001 Subject: Re: Is there a built-in variable that contains a function's name? From: Paul Kienzle To: robher at adinet dot com dot uy, help-octave@bevo.che.wisc.edu Date: Mon, 31 Dec 2001 09:23:17 -0500 Sort of. You could write an oct-file which returns the function name given in the global variable curr_function. Something like the following: /* This program is granted to the public domain */ #include #include #include DEFUN_DLD(fname,args,nargout,"\ fname returns the name of the currently executing user function\n\ ") { octave_value_list retval; if (curr_function) retval(0) = curr_function->function_name (); else error("fname: there is no currently executing function"); return retval; } Paul Kienzle pkienzle at users dot sf dot net On Sat, Dec 29, 2001 at 11:13:12PM -0300, Roberto Hernandez wrote: > Hello everyone, > > Is there any built in variable (such as nargin) that contains the name > of the function that is being executed? I've been searching the > documentation, but if it's there I haven't found it. > > What I'm trying to do is to include something like this at the beginning > of each function: > > -------------------- > function foo() > printf("%s\n", variable_containing_function_name); > fflush(stdout); > > ... > endfunction > -------------------- > > That way I can locate bugs a lot easier. I would rather use a variable > than hard code the name in the printf statement if that's possible, just > in case I later change the function name and forget to change the rest. > > TIA and Happy New Year. > > - Roberto > > > > > ------------------------------------------------------------- > Octave is freely available under the terms of the GNU GPL. > > Octave's home on the web: http://www.octave.org > How to fund new projects: http://www.octave.org/funding.html > Subscription information: http://www.octave.org/archive.html > ------------------------------------------------------------- > ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------