-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmyuigetfile.m
51 lines (46 loc) · 1.08 KB
/
myuigetfile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [filename,pathname,filterindex,ok] = myuigetfile(varargin)
%[FILENAME, PATHNAME, FILTERINDEX,OK] = MYUIGETFILE(FILTERSPEC, TITLE)
%Corresponding to uigetfile, but also fixes macro recording and test
%scripts.
%Nils Lundahl
global DATA
if isa(DATA,'maingui')
if DATA.Testing
testing = DATA.Testing;
else
testing = false;
end
if DATA.RecordMacro
recordmacro = DATA.RecordMacro;
else
recordmacro = false;
end
else
testing = false;
recordmacro = false;
end
ok = false;
if testing
%Take from buffer
s = popfrombuffer('File');
if ~isempty(s)
ok = true;
[pathname,file,ext] = fileparts(s);
filename = [file ext];
filterindex = 1;
else
error('No file selection in buffer.');
end
else
%Ask user
[filename,pathname,filterindex] = uigetfile(varargin{:});
if isequal(filename,0)
return
end
ok = true;
end
if recordmacro
file = fullfile(pathname,filename);
macro_helper('put',sprintf('pushtobuffer(''File'',''%s'') ; %%add to buffer',file));
macro_helper('switchorder');
end