If you use this pattern: |index,value
pets="|1,dog|2,cat|3,fish"
To get the value at slot:
tokenat(tokenat(pets, slot, "|"), 1, ",")
To change the value of slot to newvalue:
Set value pets to replace(pets, "|" & tokenat(pets, slot, "|"), "|" & slot & "," & newvalue)
If you just add variables to the list then just append to the end increasing the index each time.
eg. "|4,cow|5,rock"
If you want to remove values from the list then instead of "|index,value" think of it as "|id,value".
pets="|1,dog|2,cat|3,fish"
Getting the value of a slot is the same:
tokenat(tokenat(pets, slot, "|"), 1, ",")
To change the value of slot to newvalue is a bit more complicated:
Set value pets to replace(pets, "|" & tokenat(pets, slot, "|"), "|" & tokenat(tokenat(pets, slot, "|"), 0, ",") & "," & newvalue)
Then you can also remove a slot like so:
Set value pets to replace(pets, "|" & tokenat(pets, slot, "|"), "")
You could also try using a plugin instead of dealing with just text as it would probably be simpler.