[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help uigetfile
From: |
Markus Mützel |
Subject: |
Re: help uigetfile |
Date: |
Mon, 21 Oct 2019 13:46:15 +0200 |
On Mon, 21 Oct 2019 01:35:38 +0000 "Joe Tusek" wrote:
> Hi,
>
> I am having some difficulty in easily identifying the number of files
> returned by uigetfile when I span multiple. I was using numfiles =
> [size(fname)](2); to give me the number of files but this fails as the
> dimensionality of the fname retuned by uigetfile call changes depending on
> if one or multiple files is selected.
>
> When I select one file, the returned fname has dimension of 1 x
> num_filename_chars. When I select multiple files, fname has dimension of 1 x
> numfiles. Is this the correct behaviour?
>
> It seems to me that the dimension should not change its orientation between
> returning one file or multiple file names when using uigetfile GUI.
From the documentation of uigetfile:
"Two or more files can be selected when setting the "MultiSelect" key to "on".
In that case fname is a cell array containing the files."
So you could check with "iscell (fname)" if multiple files have been selected.
As a one-liner you might be able to use (I haven't tested):
numfiles = ~isnumeric(fname) * (iscell(fname) * (numel(fname) - 1) + 1);
> Also, fltidx in the function reference for uigetfile is undocumented.
fltidx is "the filter index", i.e. which filter was selected in the dropdown
box in the UI (see also "flt" in the documentation).
If you could suggest better wording to improve the documentation, that would be
highly welcome.
I also don't see being mentioned that flt is 0 if the user closes the dialog
without selecting a file.
Markus
- Re: help uigetfile,
Markus Mützel <=