Keep lists and named fields together
THE BASIC LANGUAGE
A list answers “which item is second?” A dictionary answers “who owns the list?” BASIC can store one inside the other.
FUNCTION Run()
DIM items = ["lamp", "key", "map"]
DIM card = {"owner": "Ada", "items": items}
RETURN card.owner & " carries the " & card.items[1]
END FUNCTIONWhat you should see The function returns Ada carries the key. The sequence is lamp at 0, key at 1 and map at 2.
card.owner reads a named field. card.items[1] reads the items field and then selects its second entry. In a list of length 3, the valid indexes are 0 through 2. Use Len(items) when the list length depends on the game.
When players add their own data#
Use stable field names like owner and items. Keep a displayed sentence, an internal record ID and a numeric index distinct when you pass them to another function. For a potentially empty list, check its length before reading entry 0.
