Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added default scheme path to uigetfile dialog, with safe fallback. #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion schemer_import.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
else
% Dialog asking for input filename
% Need to make this dialogue include .txt by default, at least
[filename, pathname] = uigetfile(filefilt);
[filename, pathname] = uigetfile(filefilt,[],getSchemeDialogPathSafely());
% End if user cancels
if isequal(filename, 0);
if nargout>0; varargout{1} = 0; end;
Expand Down Expand Up @@ -710,3 +710,17 @@
end

end

function defaultSchemePath = getSchemeDialogPathSafely()
% getSchemeDialogPathSafely() - Get the scheme path for the uigetfile.
% If the folder doesn't exist in the expected relative path,
% this will return the path to the folder containing the current mfile
% to prevent a warning.
expectedRelativePath = '/schemes/';
[thisFilePath, ~, ~] = fileparts(mfilename('fullpath'));
defaultSchemePath= fullfile(thisFilePath,expectedRelativePath);
% Safe fallback if schemes folder isn't in expected relative path.
if not( exist(defaultSchemePath,'dir') )
defaultSchemePath = thisFilePath;
end
end