I guess using TokenAt and TokenCount would work for this..
tokenat(src, index, separator)
Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.
tokencount(src, separator)
Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.
just add 1 to a variable as long as it's less than tokencount-1 else set it to 0
use that variable in the TokenAt expression..