I have a script to run a GUI menu in order to tie together a list of different scripts/functions so that they can run overnight without manual input. I already have a pushbutton and several checkboxes that are functional.
close all if ~exist('utilcode'); utilcode='';end
positiona=[30 550 120 20];
position2=[30,475,120,20]; BuildHr8=uicontrol('Style','checkbox','string','Build Hr8 Files','position',position2); set(BuildHr8,'Callback','Build1=1;')
I am able to get a good return on the checkboxes, but the editboxes return a blank matrix.
I tried doing this with functions, but the variables would be replaced with random numbers (not to mention moving variables became a headache.
Did you try the get() function to retrieve the current contents of the edit box?
contentsOfEditbox = get(utility, 'String');
I tried using functions such as
function h_utility(hObject,eventdata,Convert,Build,Update) utilcode=get(hObject,'String')
function h_GO(utilcode,ReadFilesAfterDate,ReadSubdirs,Convert,Build,Update) close all utilcode=get(h_utility,'String')
The function h_utility recognizes the input (i.e. I type in abc, it returns abc), but in function h_GO it returns a number in the utilcode input as 5.0037 and the get() function returns an error of too many input arguments (which doesn't make sense to me).
is going to run the function h_utility and take its return value as the list of handles whose String property is to be fetched. But the function h_utility not defined to return any value. That would lead to an error.
Note that when you execute h_utility, the variable you write to, utilcode, is a local variable, so the value of that variable is discarded after the get()
Perhaps the above is not your actual code?
You need to pass on the handle of your textbox to the function that has to read out the textbox. The common way to do this is by creating a handles struct, containing all the handles of your GUI.
Easy methods to do this is by using the function guidata, or by using getappdata/setappdata.