This is somewhat messy, but it does give you the functionality you are looking for using a multidimensional typed array:
type propertyData
property as string
value as string
endtype
dim level(7, 3) as propertyData
level(0, 0).property = "id" : level(0, 0).value = "1"
level(0, 1).property = "name1" : level(0, 1).value = "Sam"
level(0, 2).property = "name2" : level(0, 2).value = "Sally"
level(0, 3).property = "name3" : level(0, 3).value = "Sarah"
level(1, 0).property = "id" : level(1, 0).value = "2"
level(1, 1).property = "name1" : level(1, 1).value = "Bob"
level(1, 2).property = "name2" : level(1, 2).value = "Boris"
level(1, 3).property = "name3" : level(1, 3).value = "Barnaby"
lineY = 0
for x = 0 to 1
for y = 0 to 3
text 0, lineY, level(x, y).property + ": " + level(x, y).value
inc lineY, 20
next y
next x
sync
wait key
I am not sure that I would recommend this though, the whole purpose of being able to iterate over the types by numerical index is if you don't know the types. In the example given, the types name1, name2, name3 aren't really different types, they are just different items in a list of similar items, I am not sure why you would need to access them in the manner you are requesting and not just do something like:
type levelData
id as integer
name as string
endtype
dim level() as levelData
array insert at bottom level()
level().id = 1 : level().name = "Sam"
array insert at bottom level()
level().id = 1 : level().name = "Sally"
array insert at bottom level()
level().id = 1 : level().name = "Sarah"
array insert at bottom level()
level().id = 2 : level().name = "Bob"
array insert at bottom level()
level().id = 2 : level().name = "Boris"
array insert at bottom level()
level().id = 2 : level().name = "Barnaby"
lineY = 0
for i = 0 to array count(level())
text 0, lineY, level(i).id + ", " + level(i).name
inc lineY, 20
next i
sync
wait key
I guess the question is, does it really matter that "Sam" is exactly "name1" and "Sally" is exactly "name2" or do you really just need to know that both Sam and Sally are names within level 1?