1 |
% |
2 |
% LIST = get_plotlist(MASTER,SUBDIR) |
3 |
% |
4 |
% This function determines the list of pre-defined plots |
5 |
% available with the MASTER.m in the folder SUBDIR |
6 |
% LIST is a structure with name and description of each modules. |
7 |
% |
8 |
|
9 |
function LIST = get_plotlist(MASTER,SUBDIR) |
10 |
|
11 |
global sla |
12 |
|
13 |
% Define suffixe of plot module: |
14 |
suff = '_pl'; |
15 |
|
16 |
d = dir(strcat(SUBDIR,sla)); |
17 |
|
18 |
ii = 0; |
19 |
% Select Matlab files: |
20 |
for id = 1 : length(d) |
21 |
en = length( d(id).name ); |
22 |
if en~=1 & (d(id).name(en-1:en) == '.m') & ~d(id).isdir |
23 |
ii = ii + 1; |
24 |
l(ii).name = d(id).name; |
25 |
end |
26 |
end |
27 |
|
28 |
|
29 |
% Select Matlab files with MASTER as prefix |
30 |
ii = 0; |
31 |
|
32 |
for il = 1 : size(l,2) |
33 |
fil = l(il).name; |
34 |
pref = strcat(MASTER,suff); |
35 |
iM = findstr( strcat(SUBDIR,sla,fil) , pref ) ; |
36 |
|
37 |
if ~isempty(iM) |
38 |
ii = ii + 1; |
39 |
LIST(ii).name = l(il).name; |
40 |
LIST(ii).index = ii; |
41 |
|
42 |
% Recup description of plot module: |
43 |
fid = fopen(strcat(SUBDIR,sla,fil)); |
44 |
if fid < 0 |
45 |
sprintf('Problem with file: %s',strcat(SUBDIR,sla,fil)) |
46 |
return |
47 |
end |
48 |
thatsit = 0; |
49 |
while thatsit ~= 1 |
50 |
tline = fgetl(fid); |
51 |
if tline ~= -1 |
52 |
if length(tline)>4 & tline(1:4) == '%DEF' |
53 |
LIST(ii).description = tline(5:end); |
54 |
thatsit = 1; |
55 |
end %if |
56 |
else |
57 |
LIST(ii).description = 'Not found'; |
58 |
thatsit = 1; |
59 |
end %if |
60 |
end %while |
61 |
|
62 |
end %if |
63 |
|
64 |
end %for il |
65 |
|
66 |
if ~exist('LIST') |
67 |
LIST= NaN; |
68 |
end |