Ways to store and retrieve values from arbitrarily long strings, or other solutions

First, what I have done:

I have implemented a unit shuffling system for a block wargame, where you select X pieces, and shuffle them so your opponent no longer knows which is which. That was relatively simple: store the cursor coordinates as global properties, send all selected pieces to shuffle deck, send them back to the coordinates one by one with an incrementing loop increasing the y-coordinate value.

What I want to do:

The same thing, but return each of the pieces to a different one of the set of coordinates that they started at.

One problem:

I don’t really want to arbitrarily cap the number of pieces this can be done with, so I don’t want to have X * 2 global properties to store all the coordinate sets. So I was thinking maybe the initial command can have each selected piece write its coordinates to a single global property using string functions somehow? But I have no idea how to approach this or whether it is feasible.

Anyone have any solutions? Not necessarily restricted to the vague idea I had. Or just tell me it’s impossible without custom code. Any contribution would be appreciated!

OK, I figured this out, no-one else needs spend time on it =)

Using a Global Property “Positions”, the selected pieces each write {Positions + CurrentX + "," + CurrentY + ";"}.

They all get sent to the shuffle deck.

The first one out gets sent to {Positions.substring(0, Positions.indexOf(","))} for X and {Positions.substring(Positions.indexOf(",") + 1, Positions.indexOf(";"))} for Y then writes {Positions.substring(Positions.indexOf(";") + 1)} to delete the first coordinate set.

There’s some more shenanigans to make sure all the pieces do some of the sequence and only one does the whole sequence, but that’s basically all there is to it. I had no idea strings could be so handy, or easy to use. After figuring this out, I feel like I’ve been using Vassal with blinkers on…