MATLAB: Modify GUI textbox from another script file

guiguide

Hello,
I am trying to update the text of a textbox via another function that performs an operation/does something. So under my GUI Opening function I have the following.
function Example_OpeningFcn(hObject, eventdata, handles, varargin)
handles = guidata(hObject); % Care for the newest version explicitly!
Test(hObject, handles);
handles = guidata(hObject); % Get the version updated in myFunction!
% Update handles structure
guidata(hObject, handles);
And then my function Test is something like this.
function Test(source, args, handles, hObject, eventdata)
%text = get(handles.Textbox1, 'string');
text = ['It Worked'];
%set(handles.Textbox1, 'string', text);
handles.Textbox1 = text
guidata(hObject, handles);
h = msgbox('Completed');
end
I am having trouble initializing text properly from what is in the textbox already and then needing to add a line, something like 'It Worked,' and then display it in the textbox.
I have been referencing this article but have gotten stuck. https://www.mathworks.com/matlabcentral/answers/66386-how-to-modify-the-handles-structure-gui-from-an-external-function Any assistance is appreciated!!
My current error is Not enough input arguments.
Error in Test (line 6) guidata(hObject, handles);

Best Answer

You call the function Test() by:
Test(hObject, handles);
but the definition of the function uses 5 input arguments:
function Test(source, args, handles, hObject, eventdata)
Then e.g. "handles" is not defined inside the function. The solution is to provide all required inputs in the calling.