[Gambas-user] Multidimensional dynamic array basics
Kevin Fishburne
kevinfishburne at ...1887...
Mon Aug 24 23:09:36 CEST 2015
On 08/22/2015 06:43 AM, Fabien Bodard wrote:
> Well you need to understand that you make an array of array of models
>
> To fill it :
>
>
> Public StageListWall As New ObjModel[][]
>
> StageListWall.Resize(200)
>
> 'Instanciate each x Level
>
> For i = 1 to StageListWall.Max
>
> StageListWall[i] = new objModel[]
>
> next
>
>
> 'Adding a Model :
>
> hModel = new ObjModel
>
> StageListWall[0].Add(hModel)
>
> 'To get the Model name if you have a property name :
>
> StageListWall[0][0].Name
>
>
> To Delete a model
>
>
> StageListWall[0].Delete(0)
>
>
> To clear All model of x level
>
> StageListWall[x].Clear
Okay, I think I got the basics here (finally). Here's the
modified/simplified code that essentially does what I need:
Public Sub Main()
Dim a As New String[][]
' Add element to first dimension.
a.Add([])
' Add elements to second dimension.
a[0].Add("0Hello")
a[0].Add("0Goodbye")
a[0].Add("0Marco")
a[0].Add("0Polo")
Print a[0][0]
Print a[0][1]
Print a[0][2]
Print a[0][3]
' Add element to first dimension.
a.Add([])
' Add elements to second dimension.
a[1].Add("1Hello")
a[1].Add("1Goodbye")
a[1].Add("1Marco")
a[1].Add("1Polo")
Print a[1][0]
Print a[1][1]
Print a[1][2]
Print a[1][3]
End
I attached a screenshot showing the output. It's a good thing everyone's
brain works a little differently; otherwise we'd all be screwed. :)
Thanks everyone immeasurable tons for the help.
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Array Madness.jpg
Type: image/jpeg
Size: 177033 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20150824/9c26a543/attachment.jpg>
More information about the User
mailing list