uicontrol's, figure's and uimenu's use these magic strings for properties, which are strings:
'default', 'remove', 'factory'
Such properties are e.g. 'String', 'Callback', 'Name', 'Tag', etc.
A bullet-proof workaround:
S = input('Input the button string: ', 's');
if any(strcmp(S, {'default', 'remove', 'factory'})
S = ['\', S];
elseif any(strcmp(S, {'\default', '\remove', '\factory'})
warning('String "%s" padded to support uicontrol!', S);
S = [' ', S];
end
uicontrol('String', S);
Such an ugly catching of rare exceptions is a typical effect of magic strings.
When a callback function is called 'default', use the function handle instead of a string:
uicontrol('Callback', @default);
A real solution, not only a workaround, is to strictly avoid using these names as function names or as 'String' property and never allow not controllable user-input as a property. But this can be a limitation, if e.g. the ten most frequent words of an arbitrary text file should be displayed in 10 buttons.
Best Answer