Why does get(handles.editbox, 'String') return a char when the box is empty but a cell for all other cases?
2 次查看(过去 30 天)
显示 更早的评论
Is this expected behavior or is it a bug?
I finally tracked down a frustrating bug to this behavior, as I was tacking the contents of several edit boxes onto the end of a cell array.
I worked around by writing my own getEditboxContents function that always returns a cell, but that seems like it shouldn't be necessary.
What is the best practice for handling this case?
Cheers
0 个评论
采纳的回答
Geoff Hayes
2014-10-10
Nicholas - I suspect that this is expected behaviour. If the edit box control allows for multiple lines (because the Max property is greater than the Min property), then the return of
get(handles.edit1,'String')
would be an mx1 cell array where m is the number of lines in the edit box. That's why, whenever I call the above on edit boxes which are single lines, I always wrap the get in a char
char(get(handles.edit1,'String'))
so that the result is in fact a string (or char array).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!