588 views
in Embedded Wizard Studio by

Hallo,

i create an DeviceClass/autoObject, in that Class i place multidimensional array's. Now i want to read an write values in these array's. As example: 

I have a Class within a List. When i create an instance of that class, i load the values of an array, which is stored in the DeviceClass like this:

// Get the Root
var Core::Root rootObject = GetRoot();
// Create a new instance of some MyClass object
var MyApp::MyClass myClass= new MyApp::MyClass;

// Load the values from the DeviceClass into the List
while( i< 8 )
{
  myClass.currentArray[i] = MyApp::Device.Array1[0, 0, i];
  i = i+1;
}
myClass.List.NoOfItems = i;
// Area of the Widget component. Don't overlap the buttons.
myClass.Bounds.origin.x = 0;
myClass.Bounds.origin.y = 150;

CurrentRoomControl = roomControl;
// Add the Widget directly to the applucation component
// Therupon the Widget wil appear on the screen
rootObject.Add( myClass, 0 );

In this instance of this Class the User can change some parameters. The Changes should be also stored in the array in the DeviceClass. So i do this:

MyApp:Device.Array1[ 0, 0, X] = true //or false

It seems to be stored in the Array, but when i close this instance of the class and reload it, the values in the Array in the DeviceClass hasn't changed.

do i have to to a workaround here? Like a Setter and Getter for Array's? Or do i something wrong?

Best regards

Torben

1 Answer

0 votes
by
 
Best answer

Hi,

you are using an autoobject to store the data. As any other dynamically managed resource, autoobjects are released if these are not in use anymore. Please see Lifetime of an autoobject.

To maintain the autobject alive, add a variable to your application component, specify the type of the variable to correspond to the class of the autobject (e.g. MyApp::DeviceClass) and initialize the variable to refer permanently to the autoobject (e.g. set the variable to the value MyApp::Device).

This preevents the autoobject from being released if there is no other active reference to it.

Best regards

Paul Banach

by
Thank you! That helped and solved my problem.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...