Using class object data within another function

2 views (last 30 days)
Hello
Apologies, probably a fairly simplistic question but I can't seem to get it to work so any help appreciated.
I am using App Designer and am trying to use the value of an object defined within the app class of the GUI script as a variable in an external function I am calling:
end
% Button pushed function: Button
function Folder_creator_v3(app, event)
val = app.TestType.Value;
Folder_creator_v3();
% if val == 1;
%
% %%%
%
If I copy the full content of the "Folder_creator_v3" function into the GUI script, it is able to use the value for 'val' but if I specify it in this manner, when I call the function as an external file it says the variable is unspecified.
Could someone please let me know the correct syntax/method to allow the Value for TestType to be used as a variable in the external function?
Thanks!

Accepted Answer

Adam
Adam on 12 Mar 2019
Edited: Adam on 12 Mar 2019
Folder_creator_v3( val );
is required to pass val in as an argument to your function, otherwise you are just calling it with no arguments and a function has a sealed workspace so that would be identical to if you called it that way from command line or literally anywhere else where val is not defined.
This is true of any function, irrespective of whether App Designer or classes are involved in any way.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer 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!