dynamically allocating arrays inside structures

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by traumatic.

i wonder what's the best way to dynamically allocate arrays inside structures.
well, even a good way would be enough

imagine the following example:

Code: Select all

Structure one
 x.f
 y.f
EndStructure


Structure two
 something.one[#dont_know_how_much]
EndStructure
'#dont_know_how_much' isn't known at start.
the value needed is generated at runtime.

how would i adjust 'something.one' to fit?

hope i explained myself well enough..

tia,
traumatic
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by traumatic.

anyone?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

I don-t know the rest of the people, but personally I don-t understand the question, sorry. God, this keyboard is a mess!

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by traumatic.
[...]but personally I don-t understand the question[...]
i really don't know how to define my problem other than the way i did... :(

i just want to know a good way to allocate arrays inside structures dynamically with purebasic...

anyone out there understanding me? thank you for any help!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.

I think I know your problem, I have the same too in my app.
There is no way atm to add dimensions to a structure yet, as far as I know.

The best way would be to use a linked list in that case which is much faster and does not need so much memory. But for this way, I have to completely recode my app and this is a very huge work. :-(

Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.

If i understand you need to redim the array but as far as i know its not possible on PB until now.

As tranquil says maybe lists are the solution.

Maybe one wish for PB is to manage arrays as other basic does.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

But it IS possible to redim an array. Only I don-t know if doing it resets data or not.

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by traumatic.
But it IS possible to redim an array. Only I don-t know if doing it resets data or not.
yes, using dim you can resize an array and yes, the contents gets deleted.

my problem is the usage of arrays inside structures.
using somearray[] inside a structure isn't a 'real' array one could change with dim, is it?
you also can't work with dim while setting up a structure, can you?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Structures cannot be changed at runtime (logical).
You have to use another way.

cya,
...Danilo

(registered PureBasic user)
Post Reply