Skip to content

Commit f850161

Browse files
committed
Add 'ForceCharOutput' flag
Adds the option to return a cell array of char rather than a string array
1 parent fa5a1a8 commit f850161

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ User Selected: C:\uiget\uiget.m
100100
| `'ScalarPathOutput'` | Specify whether a scalar path is output when using `'MultiSelect'` | `logical` | `false` |
101101
| `'Title'` | Specify a custom dialog title | `char` vector, `string` scalar | `'Select File or Folder'` |
102102
| `'ExtensionFilter'` | Specify a custom file extension filter | `{n x 2}` `cell` array of text, where each row is `{extension(s), description}`<sup>1, 2</sup> | All Files |
103+
| `'ForceCharOutput'` | Force return of a cell array of `char` | `logical` | `false` |
103104

104105
1. Extension filter syntax follows that of [uigetfile](https://www.mathworks.com/help/matlab/ref/uigetfile.html), see [the documentation](https://www.mathworks.com/help/matlab/ref/uigetfile.html#mw_d51d3e26-4b0d-4017-a1ed-28162572b6bc) for additional details and examples.
105106

uiget.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
% ScalarPathOutput - Specify whether a scalar path is output when using MultiSelect
1313
% Title - Specify a custom dialog title
1414
% ExtensionFilter - Specify a custom file extension filter
15+
% ForceCharOutput - Force return of a cell array of char
1516
%
1617
% See README.md for detailed documentation and examples
1718
%
@@ -145,6 +146,12 @@
145146
end
146147
end
147148

149+
% Convert to cell array of char if flag is set
150+
if p.Results.ForceCharOutput
151+
file = cellstr(file);
152+
path = cellstr(path);
153+
end
154+
148155
end
149156

150157
function p = buildParser()
@@ -163,6 +170,7 @@
163170
p.addParameter('ScalarPathOutput', false, @(x)islogical(x))
164171
p.addParameter('Title', 'Select File or Folder', @(x)validateattributes(x, {'char', 'string'}, {'scalartext'}))
165172
p.addParameter('ExtensionFilter', [], @(x)validateattributes(x, {'cell'}, {'ncols', 2}))
173+
p.addParameter('ForceCharOutput', false, @(x)islogical(x))
166174
end
167175

168176
function extensions = parsefilter(incell)

0 commit comments

Comments
 (0)