[Gambas-user] gb3: clearing a public embedded array from a procedure

Benoît Minisini gambas at ...1...
Tue Jul 5 02:25:53 CEST 2011

> I've declared an array like this:
> Public QueueObject[1024] As String
> and tried to clear it in a procedure like this:
> QueueObject.Clear()
> but receive the error "Embedded array...".

> I just need to erase all the values in the array so I can reassign new
> ones. Obviously I can do this manually, but it looked like the .Clear
> method would do the trick. Any idea why it is throwing this error?
> I looked over the documentation here:
> http://gambasdoc.org/help/cat/arraydecl?v3
> and see that there are local arrays and embedded arrays. I guess some or
> all array methods are only available for local arrays? The docs are a
> bit confusing to me on this, but it's probably because I'm out of my
> depth. I can otherwise read and write to the array normally from the
> procedure, and do a function such as "QueueSorted =
> QueueObject.Sort(gb.Descent)".

Embedded arrays are not Gambas object, their memory is allocated directly 
inside the object where they are declared.

So you can't use Clear(), as that method resizes the array to zero elements.

If you don't want to be confused, just use normal arrays:

	Public QueueObject As New String[1024]


Benoît Minisini

More information about the User mailing list