GUI Push Button Behavior

조회 수: 1 (최근 30일)
Jared
Jared 2012년 12월 11일
I have a push button which, when pressed, uses the uigetdir function to get a directory. However, when I press it again, I get an error:
??? Undefined function or method 'Program' for input arguments of type
'struct'.
Error in ==>
@(hObject,eventdata)Program('load_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I want it to simply reopen the uigetdir dialog and load a new directory, if pressed again.

채택된 답변

Image Analyst
Image Analyst 2012년 12월 11일
Does "Program" try to call another function called "Prpgram"??? Maybe it's just a spelling mistake. What is the tag property of your pushbutton? Is the button called load? Set a breakpoint in the callback. Does it ever get there when you click the button? Do you know how to use the debugger? This would be fairly simple if you did.
  댓글 수: 2
Jared
Jared 2012년 12월 11일
That was a typo in my question, which I have fixed. I figured it out, was very simple. When I am using that directory to load files, I was not switching back to the root directory where the .exe was located. Once I did a cd(root), it was good to go.
Good tip on the debugger, I should practice with it.
Image Analyst
Image Analyst 2012년 12월 11일
cd() should not be necessary - I rarely use it. uigetdir() will work just fine without calling cd(). However if you pass a directory to uigetdir(), you should use exist(folder, 'dir') first to make sure the directory exists.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by