From: Richard Conforti on
Hello,

I am trying to program a GUI for a school project and I am stuck. My professor doesn't know much about programming GUIs and I am hoping someone here can help me. I am attempting to create a checkbox on my GUI that when checked gives a variable a specific value for later use and when unchecked gives a different value. However, everytime I try to run the GUI it gives me the same error.

Here is my code.

function e_checkbox_Callback(hObject, eventdata, handles)
checkboxStatus = get(handles.e_checkbox,'Value');
if checkboxStatus==1
e=10;
elseif checkboxStatus == 0
e=1;
end


Please help me. Thanks.
From: Matt Fig on
And the error message is .....?
From: Walter Roberson on
Richard Conforti wrote:

> I am trying to program a GUI for a school project and I am stuck. My
> professor doesn't know much about programming GUIs and I am hoping
> someone here can help me. I am attempting to create a checkbox on my
> GUI that when checked gives a variable a specific value for later use
> and when unchecked gives a different value. However, everytime I try to
> run the GUI it gives me the same error.
> Here is my code.
>
> function e_checkbox_Callback(hObject, eventdata, handles)
> checkboxStatus = get(handles.e_checkbox,'Value');
> if checkboxStatus==1
> e=10;
> elseif checkboxStatus == 0
> e=1; end
>

You do not indicate what error you are receiving.

I do note, though, that you do not appear to do anything with e after you set
that variable.

Is there a particular reason for comparing checkboxStatus to 0 in the elseif
statement ? Is it possible for the status to be anything other than 1 or 0? If
it is not possible, then the check is redundant. If it is possible for the
status to be some third value, then what other value is possible and what does
it mean?

At least person has reported that in their Matlab installation, a checkbox
which has never been checked or unchecked manually will return [] as the
value. Other people with the same version have tested and not seen that, so it
may be localized to that person or it may perhaps be operating-system
specific. I have a vague memory of having encountered something similar in an
earlier version, which I found I could get around by specifically setting the
Value at the time I created the checkbox (a work-around that has been tried
without success by the person who reported the difficulty.)
From: Richard Conforti on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hs9nq8$4l$1(a)canopus.cc.umanitoba.ca>...
> Richard Conforti wrote:
>
> > I am trying to program a GUI for a school project and I am stuck. My
> > professor doesn't know much about programming GUIs and I am hoping
> > someone here can help me. I am attempting to create a checkbox on my
> > GUI that when checked gives a variable a specific value for later use
> > and when unchecked gives a different value. However, everytime I try to
> > run the GUI it gives me the same error.
> > Here is my code.
> >
> > function e_checkbox_Callback(hObject, eventdata, handles)
> > checkboxStatus = get(handles.e_checkbox,'Value');
> > if checkboxStatus==1
> > e=10;
> > elseif checkboxStatus == 0
> > e=1; end
> >
>
> You do not indicate what error you are receiving.
>
> I do note, though, that you do not appear to do anything with e after you set
> that variable.
>
> Is there a particular reason for comparing checkboxStatus to 0 in the elseif
> statement ? Is it possible for the status to be anything other than 1 or 0? If
> it is not possible, then the check is redundant. If it is possible for the
> status to be some third value, then what other value is possible and what does
> it mean?
>
> At least person has reported that in their Matlab installation, a checkbox
> which has never been checked or unchecked manually will return [] as the
> value. Other people with the same version have tested and not seen that, so it
> may be localized to that person or it may perhaps be operating-system
> specific. I have a vague memory of having encountered something similar in an
> earlier version, which I found I could get around by specifically setting the
> Value at the time I created the checkbox (a work-around that has been tried
> without success by the person who reported the difficulty.)

Sorry about that, the error I am recieving is Undefined variable e.

Further down the GUI I am attempting to use the value from the check box to plug into a formula.

The code for the formula is;
rr=e+l+x+t

Each of the variables after the = are other check boxes, but I assume that if I can get the first variable to work I can get the others to as well.
From: Walter Roberson on
Richard Conforti wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <hs9nq8$4l$1(a)canopus.cc.umanitoba.ca>...
>> Richard Conforti wrote:

>> > Here is my code.
>> > > function e_checkbox_Callback(hObject, eventdata, handles)
>> > checkboxStatus = get(handles.e_checkbox,'Value');
>> > if checkboxStatus==1
>> > e=10;
>> > elseif checkboxStatus == 0
>> > e=1; end

>> You do not indicate what error you are receiving.

>> I do note, though, that you do not appear to do anything with e after
>> you set that variable.

> Sorry about that, the error I am recieving is Undefined variable e.
> Further down the GUI I am attempting to use the value from the check box
> to plug into a formula.

Well, like I said before "you do not appear to do anything with e after you
set that variable". When you get to the end of e_checkbox_Callback, the value
of e is going to disappear unless you somehow save it somewhere, perhaps using
the guidata() function.