Dot indexing not supported in App Designer start up Fcnb

2 views (last 30 days)
Hello, hope you're good.
i'm creating a multi window app where de dialog window recibes a number as an numeryc entry block, the value is stored (as app.PP.param.TP401) in a mainapp's property when the user closes it. I As the dialog window information is reseted when the user open it again, i want to display the users previusly set value in a label (app.label ). For that i'm using the following code:
function startupFcn(app, AcetonePlant)
app.PP=AcetonePlant; % Set the property for the calling app
a=app.PP.param.TP401; % Extracts the interest value
if (isnumeric(a))==1 % Evaluates if the value was already set by the user and displays it. If not, sets not applicable.
app.Label.Text = num2str(app.PP.param.TP401);
return
else
app.Label.Text = 'N/A'
end
end
But it throws me an error saying:
Dot indexing is not supported for variables of this type.
Error in xP401/startupFcn (line 40)
a=app.PP.param.TP401.value;
Error using matlab.apps.internal.GraphicsCallbackProxy/runCallbackFunction (line 23)
Error while evaluating GraphicsCallbackProxy CallbackFcn.
where xP401 is the filename of the dialog window.
I have been trying to solve this problemn for several hours but i couldn't. So i would like you to help me with this, please.
Good bye and thank you in advance
  5 Comments
Mohammad Sami
Mohammad Sami on 19 Sep 2020
If you leave it uninitialised, you will then have to use the function isstruct to verify the param is a structure and isfield to verify that it has a field TP401 before accessing it.
Mario Malic
Mario Malic on 19 Sep 2020
Edited: Mario Malic on 19 Sep 2020
As Mohammad already mentioned, initialise your properties with the known class.
a = struct(); % for structure
a = []; % for numeric array
a = ''; % for char array
% AccetonePlant is not property of the app as you did not create it
app.AcetonePlant.param.TP401=app.TP401.Value;
Save callback button is a bit messy, if you're refering to properties as 'app.propertyname', you have to declare that property as 'propertyname'
properties (Access = public)
param % Save the parameters to be used during each unit operation subrutine
res % Save the results of each unit operation subrutine.
PP=struct(); % if AcetonePlant is struct
end
In callback, refer to it
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
app.PP.param.TP401=app.TP401.Value; % See the TP401.Value, what is this?
% is this a numeric field in App Designer
% if it is, leave the EditField text next to it,
% so one can know what is it, otherwise, someone
% would guess it's structure with field 'Value'
end
This code might not solve your problem, but might give you an idea with variables, properties and passing them around the app.

Sign in to comment.

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!