|
Hi Walter,
Thx again for the reply, I edited the code as below, now i
dont have the error, but i can't use the browse button if
I press the cancel, Do you know how can I still use the
browse button even I press the cancel button
try
[pathstr,name,ext,versn] = fileparts(get
(handles.inputimg_ed,'string'));
if ~isempty(pathstr),
pathstr = [pathstr '\'];
else
[pathstr,name,ext,versn] = fileparts(get
(handles.inputimg_ed,'string'));
end
[file,path] = uigetfile([pathstr '*.jpg'],'Select an
image');
if isequal(pathstr,0)
set(handles.inputimg_ed,'string','cancelled');
else
set(handles.inputimg_ed,'string',[path file]);
end
info = imfinfo([path file]);
set(handles.width_ed,'string',info.Width);
set(handles.height_ed,'string',info.Height);
imshow([path file]);
catch
btw, do you know why I got an Warning: Single line Edit
Controls can not have multi-line text.
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fpbq6o$4e2$1@canopus.cc.umanitoba.ca>...
> In article <fpbnqu$2in$1@fred.mathworks.com>,
> Phil Au <philipawt@gmail.com> wrote:
>
> >Thx for your reply first.
> >It was used in the Browse button, whem i press the
button,
> >it was supposed to select an image file and if I
selected a
> >file, it will display the path of the file in an edit
box,
> >and diplay the details of the img and the actual img.
>
> >But I i press the cancel button, the edit box which used
to
> >display the path of the file is disappeareed and when I
> >press the button again, I got this error..
>
> You use fileparts -first- and then you use uigetfile. So
any
> problem with uigetfile will not be reflected until the -
next-
> time you call the function.
>
>
> >> > [file,path] = uigetfile([pathstr '*.jpg'],'Select
an
> >image');
>
> >> What is the documented output result when you cancel a
> >uigetfile
> >> dialog?
>
> To answer my hint to you myself: when the user cancels
> uigetfile, the return value is the -number- 0, not
> a string. You then store that 0 in a handle, and the next
> call around, you pull the numeric 0 out and try to use it
> in fileparts, which promptly complains because you have
not
> passed fileparts a string.
> --
> "Beware of bugs in the above code; I have only proved
it correct,
> not tried it." --
Donald Knuth
|