gui with guide into a script file
3 views (last 30 days)
Show older comments
i have made 2 files a gui that asks whattypes of stuff and the quantities then an ok button that gets all the quantities, and i want to use this file in another m script, vut i dont know how to please help.
function fpok_Callback(hObject, eventdata, handles)
guidata(hObject,handles);
clc
% fpmcstr=string(get(handles.chkfpmc,'string'))
% fpcoystr=string(get(handles.chkfpcoy,'string'))
% fprgstr=string(get(handles.chkfprg,'string'))
% fpblkstr=string(get(handles.chkfpblk,'string'))
% fpmcbstr=string(get(handles.chkfpmcb,'string'))
% fparidstr=string(get(handles.chkfparid,'string'))
%
%
%the below is to make a struct of all the values entered by the user
fpres=struct('FlatpackMC',nan,'FlatpackCOY',nan,'FlatpackRG',nan,'FlatpackBLK',nan,'FlatpackMCB',nan,'FlatpackArid',nan)
fpmcv=get(handles.chkfpmc,'Value');%if the checkbox is checked
fpcoyv=get(handles.chkfpcoy,'Value');
fprgv=get(handles.chkfprg,'Value');
fpblkv=get(handles.chkfpblk,'Value');
fpmcbv=get(handles.chkfpmcb,'Value');
fparidv=get(handles.chkfparid,'Value');
if fpmcv==1;%if the checkbox is checked
fpmcqt1=handles.fpmcqt.String; % this calls the number entered in the edit box
fpres.FlatpackMC=str2double(fpmcqt1);% makes that number into a number
end
if fpcoyv==1;
fpcoyqt1=handles.fpcoyqt.String;
fpres.FlatpackCOY=str2double(fpcoyqt1);
end
if fprgv==1;
fprgqt1=handles.fprgqt.String;
fpres.FlatpackRG=str2double(fprgqt1);
end
if fpblkv==1;
fpblkqt1=handles.fpblkqt.String;
fpres.FlatpackBLK=str2double(fpblkqt1);
end
if fpmcbv==1;
fpmcbqt1=handles.fpmcbqt.String;
fpres.FlatpackMCB=str2double(fpmcbqt1);
end
if fparidv==1;
fparidqt1=handles.fparidqt.String;
fpres.FlatpackArid=str2double(fparidqt1);
end
handles.output=fpres
guidata(hObject,handles);
%uiresume(ancestor(hObject, 'flatpack'))
closereq()
this is the gui call back for the ok button
fpmcqt=0;fpcoyqt=0;fprgqt=0;fpblkqt=0;fpgyqt=0;fpmcbqt=0;
fp=questdlg('Flatpacks','Select','Yes','No','c');
switch fp
case 'Yes'
result=Flatpack %was told this calls the gui it does but i cant get the values
end
disp(fpres.fpmcqt)%this is just for the mc one but it runs before you can enter a value for it
this is what someone told me to do for the call back ive tried changing the fpres to the gui file name "Flatpack" and the paper name "flatpack"
1 Comment
Walter Roberson
on 31 May 2021
How does this differ in technology from the discussion at https://www.mathworks.com/matlabcentral/answers/842565-use-a-custom-made-gui-in-another-m-file?s_tid=prof_contriblnk ?
Answers (2)
Walter Roberson
on 31 May 2021
closereq()
Do not do that. closereq() deletes the figure, but the handles structure is stored as part of the figure, so you are deleting the saved information about what to return the caller. You need to use the uiresume() instead of closereq() .
13 Comments
Image Analyst
on 29 May 2021
Several ways are shown in the FAQ:
Write back if none of them work for you and attach your m-file, fig file, and any files needed at runtime to launch your program.
0 Comments
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!