1.2k views
in GUI Development by
How can I modify the size of the array at the runtime? I want to change the size of the array dynamically.

2 Answers

0 votes
by
 
Best answer

Hi!

The size of arrays have to be defined at design time - there is no possibility to change the size of an array during runtime.

You can manage your data very easy within a simple chained list. You will find an example within the class Charts::RecordList. This class is able to store data records within a chained list. You can define the maximum number of items within your record list by setting the property 'NoOfItems'. You can clear the list by calling ClearList() and you can insert one record after the other by calling AddRecord().

You can create you own list class, based on this implementation. Very simple and flexible - maybe this helps for your application.

by
when i add Records.AddRecord more than max item  (10) via timer system collepsing need to be call Records.ClearList(); then how can we manage for online chart, I assume Record List should be arrange when new data receive he would clean last data and add new data in his array.
by
The property NoOfItems returns the current number of items and does not represent a maximum number of items. You can add as many items to the record list as you want by calling AddRecord(). There is no maximum number and no arrangement of new data that replaces some old data.

The behavior you are looking for is implemented within the class Charts::CoordList. There you will find a property MaxNoOfItems which limits the number of coordinates within the list. When the number is reached, the method AddCoord() removes the first item and add it with the new data at the end of the list.
by
How could i use Addcord() as online such as temprature? Is it possible to reach vehicle data logger example? Or could u give me little explanation abt it pls.

Thank you for explanation.
by

Hello,

the Vehicle Data Logger will be part of the provided examples in one of the next versions. At the moment it is not completely cleaned and documented. Nevertheless, you can download the current version and adapt it according your needs.

Best regards,

Manfred

0 votes
by

Hi,

as far as I know, you cannot do this yet.

Depending on your task/usecase, you could create some classes with different sized arrays.


Example (string arrays):
- ArrayClass (basic class) contains 2 methods: string GetStringByIndex( int32 index ), int32 GetNoOfItems( void )
- Classes that are derived from ArrayClass: ArrayClass5, ArrayClass50, ArrayClass100

Override their functions in the ArrayClasses:

GetNoOfItems():

return ArrayClass5.size;

OR, if empty strings are not welcome:

var int32 count = 0;
var int32 i = 0;
for( ; i < ArrayClass5.size; i=i+1 )
{
  if( ArrayClass5[ i ] != "" )
    count = count + 1;
}
return count;


GetStringByIndex():

if( GetNoOfItems() > aIndex )
  return ArrayClass5[ aIndex ];

trace "Exception: String not found.";

return "";

 

Actually this also allows you to transport arrays, e.g. via arguments in methods. 

Hope this helps.

Best regards,
Chris

P.S. Code was not tested, but should work. You could also use arrays via classes without those methodes.

Embedded Wizard Website | Privacy Policy | Imprint

...