0001 function [dirname, fnames, canceled] = pa_prjfile_select(proj_root, ext, caption)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 persistent h;
0016 persistent HISTORY;
0017
0018 dirname = [];
0019 fnames= [];
0020 canceled = false;
0021
0022
0023 if ~isempty(h)
0024 canceled = true;
0025 return;
0026 end
0027
0028 h = file_dialog;
0029 h = set(h, 'file_extensions', ext);
0030 if exist('caption', 'var')
0031 h.dialog_title = caption;
0032 end
0033 h = set(h, 'current_dir', proj_root);
0034
0035
0036 hist_num = size(HISTORY, 2);
0037 if ~isempty(HISTORY)
0038 ix = [];
0039 k=1;
0040 for k=1:hist_num
0041 for j=1:size(ext,2)
0042 if ~isempty(strmatch(ext{j}, HISTORY{k}{2}, 'exact'))
0043 ix = [ix;k];
0044 end
0045 h = set(h, 'hist_dir', {HISTORY{k}{1}});
0046 end
0047 end
0048 if ~isempty(ix)
0049 current_dir = HISTORY{ix(end)}{1};
0050 else
0051 current_dir = HISTORY{k}{1};
0052 end
0053 h = set(h, 'current_dir', char(current_dir));
0054 end
0055 [dirname fnames] = visible(h);
0056
0057
0058 if isempty(dirname)
0059 canceled = true;
0060 end
0061
0062
0063 if ~isempty(dirname)
0064 HISTORY{hist_num+1} = {dirname, ext};
0065 end
0066
0067
0068 if ~isempty(dirname) & ~isempty(proj_root)
0069 dirname = vb_relativepath(dirname, proj_root);
0070 dirname = dirname(1:length(dirname)-1);
0071 end
0072
0073 h = [];