799 views
in GUI Development by
Hello,

        I currently have a class defined that holds information about a device property. This device property sometimes is a list and can contain a defined set of values. Currently, I have several properties defined (simple data types like integers, strings etc.) within this class. I'd like to meaningfully connect this array of values to this class to show that it's a list data type. I'm unable to create a property array. Is there anyway to accomplish this without having an outside array and looking it up. It's very cumbersome and error-prone to do this. I'd like the array to be encapsulated within this class if possible. If I can store a reference to the array that would be a good solution too, but I tried without success.

Thank you!

1 Answer

+1 vote
by
 
Best answer
Hi,

actually Chora dosn't support refereces to arrays. The unique workaround is to maintain the array within an object and store the object in variable, property, etc. In other words:

1. You create a 'data container' class with your array inside.

2. You create an object of the 'data container' class.

3. Having this object you can access the array. The object itself can be passes in method parameters and stored within properties, variables, etc.

Hope it helps you further

Best regards

Paul Banach
by
Thank you, that helps!
by
Hi Paul,

Can you add example code for better understanding on data container class.

Thanks

M.Kannadasan
by

Hello M.Kannadasan,

possibly the denomination 'container class' is causing a confusion. In fact, the application case is very simple:

Step 1: Add to one of your project units a new class. See also Creating non visual components.

Step 2: Name the class according to its application case (e.g. DataStorage).

Step 3: Open the class for editing.

Step 4: Add to this class an array member.

Step 5: Configure the data type of the values to store in the array as well as its capacity.

That's all. Now you can create objects of this class and access the array existing inside it. The objects can also be assigned to variables, properties or you can pass them in parameters when invoking methods. This of course only when the variables, parameters, etc. are declared with the name of the corresponding class. For example:

var YourUnit::DataStorage data = new YourUnit::DataStorage;

data.Array[0] = ...
data.Array[1] = ...
data.Array[2] = ...
...

// Assuming, Foo is an object implementing a property named Data and 
// the property is declared with 'YourUnit::DataStorage' as data type,
// then the data object can be assigned to this property. Thereupon,
// 'Foo' can access the data object and the array found inside it
Foo.Data = data;

I hope it helps you further.

Best regards

Paul Banach

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

...