Path: news.mathworks.com!not-for-mail
From: "Phil Au" <philipawt@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: GUI question
Date: Tue, 19 Feb 2008 01:38:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 92
Message-ID: <fpdbtq$h4u$1@fred.mathworks.com>
References: <fpaofr$ru7$1@fred.mathworks.com> <fpb2v8$5s4$1@canopus.cc.umanitoba.ca> <fpbnqu$2in$1@fred.mathworks.com> <fpbq6o$4e2$1@canopus.cc.umanitoba.ca>
Reply-To: "Phil Au" <philipawt@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203385082 17566 172.30.248.35 (19 Feb 2008 01:38:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 19 Feb 2008 01:38:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1283662
Xref: news.mathworks.com comp.soft-sys.matlab:452256


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