diff scripts/testfun/example.m @ 12505:6a1fe83fe129

Allow command forms of example and demo.
author Ben Abbott <bpabbott@mac.com>
date Sat, 26 Feb 2011 18:15:48 -0500
parents c792872f8942
children 55430618bd5f
line wrap: on
line diff
--- a/scripts/testfun/example.m
+++ b/scripts/testfun/example.m
@@ -17,7 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} example ('@var{name}', @var{n})
+## @deftypefn  {Command} {} example @var{name} @var{n}
+## @deftypefnx {Function File} {} example ('@var{name}', @var{n})
 ## @deftypefnx {Function File} {[@var{x}, @var{idx}] =} example ('@var{name}', @var{n})
 ##
 ##  Display the code for example @var{n} associated with the function
@@ -37,9 +38,12 @@
   if (nargin < 1 || nargin > 2)
     print_usage ();
   endif
+
   if (nargin < 2)
     n = 0;
-  endif
+  elseif (strcmp ("char", class (n)))
+    n = str2double (n);
+  endif 
 
   [code, idx] = test (name, "grabdemo");
   if (nargout > 0)