-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetAutoLayoutConfig.m
More file actions
34 lines (31 loc) · 1.02 KB
/
getAutoLayoutConfig.m
File metadata and controls
34 lines (31 loc) · 1.02 KB
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
function val = getAutoLayoutConfig(parameter, default)
% GETAUTOLAYOUTCONFIG Get a parameter from the tool configuration file.
%
% Inputs:
% parameter Configuration parameter to retrieve value for.
% default Value to use if parameter is not found.
%
% Outputs:
% val Char configuration value.
val = default;
filePath = mfilename('fullpath');
name = mfilename;
filePath = filePath(1:end-length(name));
fileName = [filePath 'config.txt'];
file = fopen(fileName);
line = fgetl(file);
paramPattern = ['^' parameter ':.*'];
while ischar(line)
match = regexp(line, paramPattern, 'match');
if ~isempty(match)
val = match{1}; % Get first occurrance
val = num2str(strrep(val, [parameter ': '], '')); % Strip parameter
if isempty(val) % No value specified
val = default;
end
break
end
line = fgetl(file);
end
fclose(file);
end