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