Pretty Crazy uigetfile bug?

3 views (last 30 days)
Rainer
Rainer on 8 Feb 2013
Spent hours trying to figure out why my script written in 2012a gave weird results in 2012b. Finally found it.....
So....uigetfile returns a cell array of filenames, we all know that. In 2012a, if three files are selected (eg 1.xls, 2.xls, 3.xls), it would return an array of filenames with the first called '1.xls', second '2.xls' and third '3.xls'.
Apparently, in 2012b, the filenames array now becomes 3.xls, 1.xls, 2.xls
Can anyone corroborate this ?

Answers (2)

the cyclist
the cyclist on 8 Feb 2013
Edited: the cyclist on 10 Feb 2013
I'm using the prerelease version of 2013a (but guessing the behavior is the same as 2012b) on Mac OS X 10.8.2.
In very, very limited testing, I am finding that the order seems to be determined by the order the files are listed in the GUI. So, for example, I could get either 1,2,3 or 3,2,1 depending on whether I did the sorting by filename or by the date-last-modified.
  1 Comment
Rainer
Rainer on 9 Feb 2013
Edited: Rainer on 9 Feb 2013
Hmmmm, I tried sorting it on dates etc and it doesnt make a difference. In fact, it doesn't make a difference if I highlighted each file separately or in whatever order I selected them. (Windows XP)

Sign in to comment.


Jan
Jan on 10 Feb 2013
The order of outputs is to defined in the documentation. Even the output of e.g. the operating systems or Matlab's DIR command under Windows is not defined. The fact, that all tests seems like after . and .. the filenames are sorted alphabetically does not mean, that another order is a "crazy bug".
The graphical part of uigetfile relies on a Java class, depending on the value of usejavadialog. You can insert a sort() in uigetputfile_helper on demand. But it would be cleaner to perform the sorting in your program, when it is required there.
  1 Comment
Rainer
Rainer on 10 Feb 2013
You are right. The documentation says: "File names in the cell array are sorted in the order your platform uses."
Here is what happened to me:
Computer 1: Win7, matlab2012a...returns order 1,2,3
Computer 2: WinXP, matlab2012b..returns order 3,1,2
I guess Win7 handles it differently from WinXP.

Sign in to comment.

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!