[Gambas-user] basics of dynamic arrays of structures

Kevin Fishburne kevinfishburne at ...1887...
Sat Dec 21 06:39:23 CET 2013


On 12/21/2013 12:36 AM, Kevin Fishburne wrote:
> I've gotten some flak about how I declare arrays and want to change my
> ways. Previously I would do something like:
>
> Public SomeArray[300,300] as Integer
>
> I have a case now where I need an array whose number of elements will be
> incremented and that will be cleared occasionally. Of course I can't
> figure out how to do it. My code looks like this (I stripped it down):
>
> ---
>
> Public Struct PlanWallStructure
>     Created As Boolean
> End Struct
>
> Public Struct PlanStructure
>     Wall As Struct PlanWallStructure
> End Struct
>
> Public Plan[10] As Struct PlanStructure
>
> ---
>
> So I need, for example, Plan[0].Wall to be an array where I can do
> something like:
>
> ---
>
> Plan[0].Wall.Clear
> Index = Plan[0].Wall.Count
> Plan[0].Wall[Index] = True
> Index = Plan[0].Wall.Count
> Plan[0].Wall[Plan[0].Wall.Count] = False
>
> ---
>
> Is this possible? I've tried every syntax I can think of and looked at
> the documentation but get errors every time.
>

Whoops. Meant for that last bit of code to be:

Plan[0].Wall.Clear
Index = Plan[0].Wall.Count
Plan[0].Wall[Index] = True
Index = Plan[0].Wall.Count
Plan[0].Wall[Index] = False


Same thing basically for the purpose of the example.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list