Using class object data within another function

2 次查看(过去 30 天)
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!

采纳的回答

Adam
Adam 2019-3-12
编辑:Adam 2019-3-12
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by