Welcome! Log In Create A New Profile

Advanced

Structure array

Posted by emirhan 
emirhan
Structure array
February 20, 2009 11:02AM
Hi all,
I have a structure array and I need to store some values in the array, but I dont know the number of records. How can I initialize the size of the array? can structure array be dynamic? and How can I add records to the structure array, arrayaddLine does not work with structure array

my structure is

STMyStructure is structure
age is int
name is string
end

MyArray is array of SIZE STMyStructure

How can I intialize the SIZE?, can it be dynamicly?
and also how can I add a new record to the structure array?

Thanks
Arie
Re: Structure array
February 20, 2009 11:06AM
Have a look at Dimension() in the help

Arie
emirhan
Re: Structure array
February 20, 2009 11:16AM

ok thank you, and the other question, how can I add a new record to the structure array? arrayaddline does not work?
Arie
Re: Structure array
February 20, 2009 11:28AM
Something like this (not tested)

STMyStructure is structure
age is int
name is string
end

MyArray is array of 0 STMyStructure
myItem is STMyStructure
myItem = new STMyStructure
myItem:age = 400
myItem:name = Santa

Dimension(:MyArray ,Dimension(:MyArray )+1)
:MyArray [Dimension(:MyArray )] = myItem

Arie
Paulo Oliveira
Re: Structure array
February 20, 2009 12:34PM
The array can be dynamic.
ARRAYADD is your friend.
Piet van Zanten
Re: Structure array
February 20, 2009 01:30PM
Hi,

Arie has a working method, but I prefer to leave out the dimension part.
You can use MyArray is array of 0 STMyStructure
Then you can use a simple structure as a buffer and use arrayadd to add the buffer structure to the array. Also, look at arraydeleteall to empty the array without deleting the array itself.

Regards,
Piet




Edited 1 time(s). Last edit at 02/20/2009 02:50PM by Piet van Zanten.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: