Error message with string

I was wondering what I receive the following error:
Error using hg.root/set
The name 'String' is not an accessible property for an
instance of class 'root'.
Error in test>reset_Callback (line 1352)
set(handles.value,'String','0');
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in test (line 114)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)test('reset_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I'm not sure how it arose, the feature used to work.

 Accepted Answer

Walter Roberson
Walter Roberson on 28 Aug 2013

0 votes

Your "handles.value" contains 0. You have not shown us enough for us to be able to guess why that is so.

4 Comments

T
T on 28 Aug 2013
So basically there is this input box in this GUI that has 0 as its default value. The user would occasionally enter in an arbitrary number.
A reset button is to bring this value back to 0 but the error occurs.
Somehow the handle itself is 0, rather than the string it contains. For example if the field handles.value had been created but no uicontrol() or text() handle had been written into it. And make sure to use guidata(hObject, handles) to write back changes after changing the handles structure itself.
T
T on 28 Aug 2013
I have used guidata where ever handles.value arises within each function.
I did use value = str2double(get(hObject, 'String')) several times, is this the reason?
That would only be the reason if you then wrote "value" into handles.value .
You might want to do some renaming so that the location you display to makes clear in its name that it is a control rather than a numeric field. You might also want to have a field in handles that contains the latest copy of the string converted to numeric form; whatever name you use for that, make sure you will not confuse field entry with the name of the field for the static text. For example, handles.etabox and handles.etaval . Once you do that and start going through the code, any inconsistency treating the field as a control vs the numeric-conversion should become clear.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!