Dynamic Arrays

In addition to the standard declared arrays, sdlBasic supports dynamic arrays. If you declare an array without listing the indexes:

Dim myArray[]
 
sdlBasic will treat it as a dynamic array. Dynamic arrays use strings as their indexes:

myArray["cat"] = "Chester"
 
You can use numeric values for indexes, but they will be stored internally as strings. So the following declarations are equivalent:

myArray[1,2,3] = 23
myArray["1,2,3"] = 23
 
You can use the  For Each  construct to iterate through dynamic arrays:

For Each key In myArray
    Print key, myArray[key]
Next