Heres a SWAP function to try.
It needs expanding to cover all of your fields:
It needs expanding to cover all of your fields:
Type Gems Field name$ Field worth End Type Global gem.Gems Global swap.Gems gem=New Gems gem\name="silver" : gem\worth=120 gem=New Gems gem\name="red" : gem\worth=250 gem=New Gems gem\name="gold" : gem\worth=170 gem=New Gems gem\name="ruby" : gem\worth=135 ListGems Print "Swapping 'red' and 'ruby'" SwapGems "red","ruby" ListGems WaitKey End Function ListGems() Print "" Print "------[START]------" For g.Gems=Each Gems Print "Name = "+g\name+" Worth = "+g\worth Next Print "-------[END]-------" Print "" End Function ; swap 2 gems by name Function SwapGems(n1$,n2$) Local flag=False For g1.Gems=Each Gems If g1\name=n1$ For g2.Gems=Each Gems If g2\name=n2$ ; swap the variables of the 2 types swap.Gems=New Gems swap\name=g1\name : g1\name=g2\name : g2\name=swap\name swap\worth=g1\worth : g1\worth=g2\worth : g2\worth=swap\worth Delete swap flag=True : Exit EndIf Next EndIf If flag=True Exit Next End Function