Using class object data within another function

2 Ansichten (letzte 30 Tage)
dweather
dweather am 12 Mär. 2019
Kommentiert: dweather am 12 Mär. 2019
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!

Akzeptierte Antwort

Adam
Adam am 12 Mär. 2019
Bearbeitet: Adam am 12 Mär. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by