Table

A Table is an unordered collection of dynamic size. Like all other collections, they are passed by reference. You create a table by declaring a collection within curly brackets. The following declares an empty Table:

   Dim myTable = {}
A collection is indexed by keys, which can either be Integer or String values (Numbers will be automatically converted to Integers). For example:

   Dim myCats = { 1:"Chester", 2:"Charlotte", 3:"Chloe", 4:"Julius" }
is the same as writing:

   Dim myCats = {}
   myCats[1] = "Chester"
   myCats[2] = "Charlotte"
   myCats[3] = "Chloe"
   myCats[4] = "Julius"
Note here that if the key does not exist in the List, wxb will insert a new key/value pair.
If you leave off the key in the declaration, wxb will assign a sequential value, so this produces the same result as the prior example:

   Dim myCats = { "Chester", "Charlotte", "Chloe", "Julius" }
You can retrieve data by specifying the index, the same as an array:

   Print myCats[1]
If a key does not exist in the Table, wxb returns the value Nothing. If a List contains another List, you can access it as if it were an array:

   Dim myCats = {}
   myKids[ "Chester", "favorite food" ] = "Pounce"
is the same as writing:

   Dim myCats = {}
   myKids[ "Chester" ] = { "favorite food":"Pounce" }
which is also the same as:

   Dim myCats = { "Chester":{ "favorite food":"Pounce" } }
and it can be accessed similarly:

   Print myKids[ "Chester", "favorite food" ]
prints "Pounce".

As with the other collections, you can iterate through it with the For Each loop:

   For Each index, name In myCats
      Print index, name
   End For
Note that the List is unordered, so there is no guarantee that the data will come back in any order.
You can remove items from the list by removing the key from the collection:

   myCats.Remove( "Julius" )