1 |
function folder = uigetfolder(title, initial_path) |
---|
2 |
%UIGETFOLDER Standard Windows browse for folder dialog box. |
---|
3 |
% |
---|
4 |
% folder = uigetfolder(title, initial_path) |
---|
5 |
% |
---|
6 |
% Output: folder = selected folder (empty string if dialog cancelled) |
---|
7 |
% Inputs: title = title string (OPTIONAL) |
---|
8 |
% initial_path = initial path (OPTIONAL, defaults to PWD) |
---|
9 |
% |
---|
10 |
% Examples: folder = uigetfolder - default title and initial path |
---|
11 |
% folder = uigetfolder('Select results folder') - default initial path |
---|
12 |
% folder = uigetfolder([], 'C:\Program Files') - default title |
---|
13 |
% |
---|
14 |
% See also UIGETFILE, UIPUTFILE |
---|
15 |
|
---|
16 |
%----------------------------------------------------------------------------------------------- |
---|
17 |
|
---|
18 |
if ~strcmp(computer, 'PCWIN') |
---|
19 |
error_dialog_handle = errordlg(['The function ', upper(mfilename), ' only works on a MS-Windows PC'], ... |
---|
20 |
mfilename, ... |
---|
21 |
'modal'); |
---|
22 |
folder = ''; |
---|
23 |
else |
---|
24 |
if nargin < 2 |
---|
25 |
initial_path = pwd; |
---|
26 |
end |
---|
27 |
|
---|
28 |
if nargin < 1 | isempty(title) |
---|
29 |
title = 'Select a folder'; |
---|
30 |
end |
---|
31 |
|
---|
32 |
% Error checking |
---|
33 |
if ~ischar(title) |
---|
34 |
error('The title must be a string') |
---|
35 |
end |
---|
36 |
if ~ischar(initial_path) |
---|
37 |
error('The initial path must be a string') |
---|
38 |
end |
---|
39 |
if ~exist(initial_path, 'dir') |
---|
40 |
error(['The initial path: ', initial_path, ' does not exist!']) |
---|
41 |
end |
---|
42 |
|
---|
43 |
folder = uigetfolder_win32(title, initial_path); |
---|
44 |
|
---|
45 |
end |
---|
46 |
%----------------------------------------------------------------------------------------------- |
---|