0
我使用Matlab R2014a的GUI工作。Variabile在調試中的表現與在Matlab中的非調試中有所不同?
我想看看是否有寫在編輯控制。如果是,那麼該程序會做一些事情。如果不是,那麼它會做其他事情。我寫的代碼是這樣的(在KeyPressFcn回調中):
h1=findobj('Tag','btnOK1'); %this is a button
h2=findobj('Tag','edIndexIesire'); %this is an edit
text=get(h2,'String'); %I read the content of the edit
msgbox(text); %display it in a message box
if (isempty(text)) %if the edit is empty...
set(h1,'Enable','off'); %... then disable the button.
else %If it is not...
set(h1,'Enable','on'); %... enable the button
end
到目前爲止好。然而,當我正在調試時,與我自己運行程序時文本變量的值似乎有所不同。在調試模式下,一切工作正常,文本變量獲取我從鍵盤輸入的值。當我不調試時,文本變量取得了此回調的前一次迭代的值。
例我想當我進入第一5輸入號碼55,則文本變量是空的。當我輸入第二個5時,文本變量的值爲5.
我錯在哪裏?
是的,你是對的。回調是問題。非常感謝你! –