Array in Custom Type

Blitz3D Forums/Blitz3D Beginners Area/Array in Custom Type

PoliteProgrammer(Posted 2006) [#1]
Is it possible to have an array contained within a custom type?

Such as

Type MyType
Field array(99)
End Type

If so, how would I do this? What is the required syntax?


big10p(Posted 2006) [#2]
Just use square brackets instead:

Field array[99]

These arrays can only be one dimension, though.


Bobysait(Posted 2006) [#3]
and can't be resized.

=> dim can be resize :
Dim Thing(0)

function do_something()
dim thing(50)
for i = 1 to 50
thing(i)= any number...
next
use the dim to fill any code...
vertexcoords s,idVert,thing(???) , etc...
dim thing(0) ; reset the array
end function

=> in type, you can't do that. => every type created will automatically fill an array declared in the type list.
So , taje care of the array size . Sometime we declare arrays, and them we create 5000 sprite that use an array of 1000 cell = result in large memory used.
If only need 10 cells fos the array => declare it in the Type FieldList.


Dreamora(Posted 2006) [#4]
If you need dynamic arrays in your types, there are 2 ways:

1. Self created linked list
2. Bank. Thats the normally used way as it has dynamic size. Through Object and Handle functions you can even push type instances into banks.


octothorpe(Posted 2006) [#5]
re 2, see my sig. vectors specifically.