Mercurial > hg > octave-nkf
annotate scripts/testfun/rundemos.m @ 11472:1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 21:33:04 -0800 |
parents | d1978e7364ad |
children | fd0a3ac60b0e |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2008, 2009 John W. Eaton |
8229 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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. | |
9 ## | |
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. | |
14 ## | |
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/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} rundemos (@var{directory}) | |
21 ## @end deftypefn | |
22 | |
23 ## Author: jwe | |
24 | |
25 function rundemos (directory) | |
26 | |
27 if (nargin == 0) | |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
8746
diff
changeset
|
28 dirs = strsplit (path (), pathsep ()); |
8229 | 29 elseif (nargin == 1) |
30 if (is_absolute_filename (directory)) | |
31 dirs = {directory}; | |
32 else | |
33 fullname = find_dir_in_path (directory); | |
34 if (! isempty (fullname)) | |
10549 | 35 dirs = {fullname}; |
8229 | 36 else |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
37 error ("rundemos: DIRECTORY argument must be a valid pathname"); |
8229 | 38 endif |
39 endif | |
40 else | |
41 print_usage (); | |
42 endif | |
43 | |
8231
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
44 for i = 1:numel (dirs) |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
45 d = dirs{i}; |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
46 run_all_demos (d); |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
47 endfor |
df28b55d03c0
make rundemos with no arguments work
John W. Eaton <jwe@octave.org>
parents:
8230
diff
changeset
|
48 |
8229 | 49 endfunction |
50 | |
51 function run_all_demos (directory) | |
52 dirinfo = dir (directory); | |
53 flist = {dirinfo.name}; | |
54 for i = 1:numel (flist) | |
55 f = flist{i}; | |
56 if (length (f) > 2 && strcmp (f((end-1):end), ".m")) | |
57 f = fullfile (directory, f); | |
58 if (has_demos (f)) | |
10549 | 59 demo (f); |
60 if (i != numel (flist)) | |
61 input ("Press <enter> to continue: ", "s"); | |
62 endif | |
8229 | 63 endif |
64 endif | |
65 endfor | |
66 endfunction | |
67 | |
68 function retval = has_demos (f) | |
69 fid = fopen (f); | |
8699
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
70 if (f < 0) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
71 error ("rundemos: fopen failed: %s", f); |
8699
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
72 else |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
73 str = fscanf (fid, "%s"); |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
74 fclose (fid); |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
75 retval = findstr (str, "%!demo"); |
6e764b7317bd
test/fntests.m, scripts/test/demo.m: error on fopen failures
John W. Eaton <jwe@octave.org>
parents:
8245
diff
changeset
|
76 endif |
8229 | 77 endfunction |