1 ## Copyright (C) 2008-2012 John W. Eaton
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} rundemos ()
21 ## @deftypefnx {Function File} {} rundemos (@var{directory})
22 ## Execute built-in demos for all function files in the specified directory.
23 ## If no directory is specified, operate on all directories in Octave's
24 ## search path for functions.
25 ## @seealso{runtests, path}
30 function rundemos (directory)
33 dirs = strsplit (path (), pathsep ());
35 if (is_absolute_filename (directory))
38 directory = regexprep (directory, ['\',filesep(),'$'], "");
39 fullname = find_dir_in_path (directory);
40 if (! isempty (fullname))
43 error ("rundemos: DIRECTORY argument must be a valid pathname");
50 for i = 1:numel (dirs)
57 function run_all_demos (directory)
58 dirinfo = dir (directory);
59 flist = {dirinfo.name};
60 for i = 1:numel (flist)
62 if (length (f) > 2 && strcmp (f((end-1):end), ".m"))
63 f = fullfile (directory, f);
68 printf ("error: %s\n\n", lasterror().message)
70 if (i != numel (flist))
71 input ("Press <enter> to continue: ", "s");
78 function retval = has_demos (f)
81 error ("rundemos: fopen failed: %s", f);
83 str = fscanf (fid, "%s");
85 retval = findstr (str, "%!demo");
89 %!error rundemos ("foo", 1);