changeset 21069:a1aadf619e3c

inputname.m: Clarify docstring. * inputname.m: Clarify docstring. Rename output variable 's' to 'name' for clarity.
author Rik <rik@octave.org>
date Thu, 14 Jan 2016 08:51:44 -0800
parents c221ce56f774
children fd97ed44f2da
files scripts/miscellaneous/inputname.m
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/inputname.m	Thu Jan 14 08:35:42 2016 -0800
+++ b/scripts/miscellaneous/inputname.m	Thu Jan 14 08:51:44 2016 -0800
@@ -23,29 +23,32 @@
 ## @deftypefn {} {} inputname (@var{n})
 ## Return the name of the @var{n}-th argument to the calling function.
 ##
-## If the argument is not a simple variable name, return an empty string.
-## @code{inputname} may only be used within a function body, not at the
-## command line.
+## If the argument is not a simple variable name, return an empty string.  As
+## an example, a reference to a field in a structure such as @code{s.field} is
+## not a simple name and will return @qcode{""}.
+##
+## @code{inputname} is only useful within a function.  When used at the command
+## line it always returns an empty string.
 ## @seealso{nargin, nthargout}
 ## @end deftypefn
 
-function s = inputname (n)
+function name = inputname (n)
 
   if (nargin != 1)
     print_usage ();
   endif
 
-  s = "";
+  name = "";
   try
-    s = evalin ("caller", sprintf ("__varval__ ('.argn.'){%d}", fix (n)));
+    name = evalin ("caller", sprintf ("__varval__ ('.argn.'){%d}", fix (n)));
   catch
     return;
   end_try_catch
 
   ## For compatibility with Matlab,
   ## return empty string if argument name is not a valid identifier.
-  if (! isvarname (s))
-    s = "";
+  if (! isvarname (name))
+    name = "";
   endif
 
 endfunction