My, my, how things have become entangled. Here I am working with my spiffy new system and I run into what looks like a minor snag: when the user edits a token string while in the role editor, we need to write the new version of the token string to the permanent records. But the immediate version is a conflation of the activation equation, the substitution equations, and the various consequence equations. Thus, we really can't disentangle them and store them separately. Who gets the substitution equations? The role or the consequence?
I decided that this means that all the token data must be stored at the level of the role; this implied that I would eliminate the token string information from the individual consequences. But this has created a new problem: when I delete a consequence, I have to delve into the role token string and delete all material related to that consequence, including any substitution variables that are used exclusively by the deleted consequence. What a pain! Yes, I suppose it's computable, but gad, what a mess.
There is another way. What if the substitution variables are stored at the role level, but the consequence stuff is retained in the individual consequences?
And another problem: inside the consequence equations, I use the consequence index as a token just before the final pop, but what if one consequence is deleted during editing? Then the index numbers buried inside the token strings are off by one, and nobody's the wiser.
Oh, jeez, what a mess. I suppose that I have to go with the complicated approach. When a consequence is deleted, I'll run through the entire token string, handling both the deletion of all pop-tokens whose indeces equal the deleted items, and also decrementing the indeces of all higher pop-tokens. This is going to be a pain.