Pretty Crazy uigetfile bug?

1 次查看(过去 30 天)
Rainer
Rainer 2013-2-8
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 ?

回答(2 个)

the cyclist
the cyclist 2013-2-8
编辑:the cyclist 2013-2-10
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 个评论
Rainer
Rainer 2013-2-9
编辑:Rainer 2013-2-9
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)

请先登录,再进行评论。


Jan
Jan 2013-2-10
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 个评论
Rainer
Rainer 2013-2-10
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by