Effacer les filtres
Effacer les filtres

Getting app data into a script (old guidata)

16 vues (au cours des 30 derniers jours)
Jeffrey Topp
Jeffrey Topp le 9 Nov 2023
Commenté : Jeffrey Topp le 10 Nov 2023
I've created a GUI in App Designer which has a button that calls another script. How do I access the values of the app components from inside my script? In the guide days I would use guidata(gcf). I would rather not pass all the app component values into the script as function parameters, that would be tedious.

Réponses (1)

atharva
atharva le 9 Nov 2023
Hey Jeffrey,
I understand that you are trying to access the values of your app components from another script.
In App Designer, you can access the values of app components from within another script by using the app object. The app object represents the instance of your app, and you can use it to get or set the values of app components.
Here's an example:
1. In your App Designer, let's say you have a button with the Tag "myButton". In the button's callback function, you can call your external script and pass the app object to it.
methods (Access = private)
% Button pushed function: MyButton
function MyButtonPushed(app, event)
% Call your external script and pass the app object
externalScript(app);
end
end
2. In your external script, you can receive the app object and access the values of the components.
function externalScript(app)
% Accessing the value of a component (assuming you have a component with Tag 'myComponent')
componentValue = app.myComponent.Value;
end
By passing the app object to your external script, you have access to all the components and their values. You don't need to pass each value as a separate parameter.
This approach is more in line with the object-oriented nature of App Designer compared to the guidata method.
I hope this helps!
  1 commentaire
Jeffrey Topp
Jeffrey Topp le 10 Nov 2023
Thanks for the response. I was hoping not to run these scripts as functions as the scripts call other scripts and they populate the workspace. That's why I was going for sharing like guidata.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by