uigetfile for multiple type problem
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Hi:
I want to use uigetfile to pick files, the files needed have two types:
- 'abc*.mat'
- '*.dat'
but when I use command:
uigetfile({'abc*.mat','*.dat'})
only the type 'abc*.mat' is shown in the file selection window,
when I use command:
uigetfile({'*.dat','abc*.mat'})
only the type '*.dat' is shown in the file selection window.
these means that, my command only shows the 1st type.
is there any mistake with my command?
Thanks!
Yu
채택된 답변
dpb
2019년 4월 28일
Gotta' have good eyes in reading the documentation...use
uigetfile({'abc*.mat';'*.dat'})
instead--a column instead of row vector of cell strings. A second column is interpreted as an optional file descriptor.
Also NB: only one selection criterion is active at a time; they're sequential lines in a dropdown box so when you select one, the other goes away. This may or may not be desired behavior. Unfortunately if the latter, even with 'MultiSelect','on' it will cancel the other file in the already selected list so whether having more than one file type in the dropdown box is even worth doing or not appears questionable...
댓글 수: 8
Yu Li
2019년 4월 28일
Thanks for your reply.
but in my side, no matter use ',', ir ';', the behavior looks like the same.
Yu
Adam Danz
2019년 4월 28일
What does that mean?
Have you tried running dpb's line of code? It does exactly what you're asking it to do.
Yu Li
2019년 4월 28일
Yes I tried.
what I want to display both together, but it only display one, after I use ';' instead of ','
Adam Danz
2019년 4월 28일
Check out the last paragraph dpb wrote. You can only display one at a time. If you want the user to see all files, one option is to not specify the filter spec. Then you could write a few lines of code that detects the file extension of the file(s) selected and conditionally throw an error if the user chose an undesired file.
dpb
2019년 4월 28일
Unfortunately, that's just the behavior of the function; to see the other click the dropdown box in the file list...but, "that's as good as it gets!" with that particular UI.
"I don't do windows!" so I don't know if that mimics the MS UI behavior or whether it's an artifact of how Mathworks wrapped the Win32 API calls inside the function, but that's the way it works.
Using ";" instead of "," between the file type strings does let you look at the two selectively, and the shown files dialog changes to reflect that, but it simply won't show both at once with this functrion.
Sad, but true...
Ok... I see a selection at the bottom right of the window... thank you.
I'm contacting Mathworks Technical Support to see if there is a perfect solution as I expected (display both together), will post here once I have it.
Bests,
Yu
uigetfile() always invokes the system file browser, and only showing one file type at a time is common for system file browsers.
dpb
2019년 4월 28일
And, uicontrol won't allow the putgetfile style so appears TMW hasn't left any hooks to do anything else.
It seems to me the wrapper function in CVF Fortran let one do that but I've not reinstalled the compiler since the system crash as the installer won't run under 64-bit OS even though the command-line compiler will--but it takes setting a myriad of system variables to make linking work correctly and I've not taken the time to do so, so can't check...and I'm not enough of a masochist to go do it at the root level without the interface functions just for a Forum maybe question that doesn't have direct benefit to the OP! :)
I guess I also wasn't aware of that quirk...seems like a really rude implementation indeed; have to agree w/ Yu on that.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
참고 항목
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
