Passing Variables from GUI to Script

3 vues (au cours des 30 derniers jours)
junkbond916
junkbond916 le 13 Oct 2017
Hello All. I have built an analysis tool that boots up to a UI with dropdown menus. The 'Run PME Analysis' button runs a script with a SQL query that is generated from values in the dropdowns ("run_pme").
But, I have been unable to pass variables from the GUI dropdowns to my script. Here is the code from the top dropdown and the first bit of code from the script:
if true
function popfirm_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
firmcontents = cellstr(get(hObject,'String'));
firm = firmcontents{get(hObject,'Value')};
if (strcmp(firm,'All Firms'))
firmquery = '';
else
firmquery = strcat('AND [Firm] ='," '", firm, "'");
end
handles.firmquery = 'firmquery';
guidata(hObject, handles);
if true
function popfirm_Callback(hObject, eventdata, handles)
firmcontents = cellstr(get(hObject,'String'));
firm = firmcontents{get(hObject,'Value')};
if (strcmp(firm,'All Firms'))
firmquery = '';
else
firmquery = strcat('AND [Firm] ='," '", firm, "'");
end
handles.firmquery = 'firmquery';
guidata(hObject, handles);
end
if true
function run_pme(obj, eventData, handles)
firmq = handles.firmquery
end
When I click the "Run PME" Button, I get the following error:
_Not enough input arguments.
Error in PME_Analysis_Full>run_pme (line 206) firmq = handles.firmquery_
I'm sure the problem will be obvious to anyone with experience but I'm still quite new. Any help you can provide would be most appreciated.
Thanks!
  2 commentaires
Adam
Adam le 13 Oct 2017
How is run_pme called? Is it the callback for the button that you renamed to not include the usual 'callback' part of its name?
junkbond916
junkbond916 le 13 Oct 2017
Sorry - I should have included the code for the "Run PME Analysis" button. Here you go:
if true
function runpmebutton_Callback(hObject, eventdata, handles)
run_pme;
end

Connectez-vous pour commenter.

Réponse acceptée

Rajesh Balagam
Rajesh Balagam le 16 Oct 2017
Refer to the following MATLAB documentation page for some pointers on sharing the data among UI elements.
It seems the error observed in your code is due to calling run_pme function with no input arguments whereas the run_pme function expects 3 inputs.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by