Setting a textbox returning error 'Unable to resolve the name'
Afficher commentaires plus anciens
I have a GUI function that defines a few text boxes under the structure S. When calling to update the value of the text box named 'S.Text_for_display' within a seperate function called 'Speak' I recive the error 'Unable to resolve the name 'S.Text_for_display'.'.
function []=Speak(txt)
set(S.Text_for_display,'String','','LineStyle','none','FontSize',14,'FontName','Comic Sans... MS','FitBoxToText','off');
len=length(txt);
for i=1:len;
if i<=len;
Display(txt(1:i));
pause(.05);
else
Display(txt);
end
end
end
1 commentaire
Walter Roberson
le 20 Jan 2024
for i=1:len;
if i<=len;
Display(txt(1:i));
pause(.05);
else
Display(txt);
end
In a for loop that goes 1:len it is certain that i <= len so there is no point in having the if
Réponses (1)
Dyuman Joshi
le 18 Jan 2024
Modifié(e) : Dyuman Joshi
le 19 Jan 2024
The function does not know what "S" is. You need to pass it as an input.
And the font name 'Comic Sans MS' does not have ellipses (3 dots) in it.
%For cross-check
listfonts
4 commentaires
lewis williamson
le 19 Jan 2024
Dyuman Joshi
le 19 Jan 2024
If you want to use ellipses, you should use it after a name-value arguement pair, I've shown an example below -
%Modify function to add S as an input
% v
function []=Speak(txt, S)
set(S.Text_for_display,'String','','LineStyle','none','FontSize',14,...
'FontName','Comic Sans MS','FitBoxToText','off');
len=length(txt);
for i=1:len;
if i<=len;
Display(txt(1:i));
pause(.05);
else
Display(txt);
end
end
end
lewis williamson
le 19 Jan 2024
Dyuman Joshi
le 20 Jan 2024
Could you share the struct "S"? Use the paperclip button to attach.
How are you calling the function?
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!