in GUI Development by


In our project we try to access array variable as like below 

1.created array variable inside a class(ex: arr_class)

2. passing that class as an argument to method in another class

3.inside method how can we access array variable which is there in (arr_class) class.

In above image array_class contain the array variable

  when we are trying to access the array facing issue like below



1 Answer

0 votes

Hello Harshini,

similarly to C++, Chora is a static typed programming language. This means that before source code is compiled, the type associated with each and every single variable must be known. In your case the type of the variable obj is known as object. Such variable can represent any object. This however without any assumption to the content of the object. If you want to access a data member of such object, you have to explicitly type-cast it to the expected class and test whether the type-cast was successful (whether the object stored in the variable really does represent the desired class). See also Type conversion: Object runtime cast.

In your case (you plan to create an instance of a dynamically specified class), you could also use the Type conversion: Class runtime cast to distinguish the different classes. Once the class is known, you can perform code dedicated to the known class. For example:

// Trying to create an object of the Int32Array class?
if ((SomeUnit::Int32Array)array_class )
  var SomeUnit::Int32Array obj = new SomeUnit::Int32Array;

  trace obj.arr;

// Trying to create an object of the StringArray class?
else if ((SomeUnit::StringArray)array_class )
  var SomeUnit::StringArray obj = new SomeUnit::StringArray;

  trace obj.arr;

else if ( ... )

I hope it helps you further.

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