Main Menu

when will this be implemented?

Started by Alex, March 17, 2007, 11:12:38 PM

Previous topic - Next topic

Alex

tried doing this, and it failed..

test = GetArray(temp(t1).springrecord() As Integer)

similar code with other commands also doesn't work

kevin

   That'd only be possible with nested dynamic array fields.  Which aren't implemented and i've no idea when we'll get to that.. but it is on the To Do list. 

   You can't do it with static arrays as the field isn't actually a PB Array, it's simply a chunk bytes held within the types structure.  So there's no 'header' or element address info in the structure, therefore there's no way (without building an new array/ which defeats the purpose!)  to return any sort of PB Array handle that would make sense externally.    Hence , we have pointers !




Type Ships
Array(100)
EndType

Dim Objects(100) as Ships
Dim ptr as integer pointer

For lp=0 to 100
   Objects(50).Array(lp)=1000+lp
next

Ptr=Objects(50).Array
For lp=0 to 100
print *(ptr+lp)
next

Sync
waitkey


Alex

#2
ok,
how come this doesn't work?

Dim ptr As Integer Pointer
ptr = temp(t1).bubblerecord
brecord = GetFreeCell(ptr)
ptr(brecord) = t2

gives an error saying the 1st parameter of getfreecell is incorrect type and is expecting a handle type

this doesnt work either:

Dim ptr As Integer Pointer
ptr = temp(t1).bubblerecord
If FindArrayCell(ptr,0,1,GetArrayElements(ptr,1),t2) = -1
brecord = GetFreeCell(ptr)
ptr(brecord) = t2
EndIf

kevin


erm, because A pointer is not an Array !