Start a new topic

Swapping values using a dictionary?

Hi guys,

Does anyone know a way to swap two values using a dictionary? For instance, our data file might have values of TRUE when we need FALSE, and vice versa.

When I've tried the most obvious approach (matching True, replacing False; matching False, replacing True) IOM complains that "Entry exists already as a replacement value or value to match on."

Doing it with the API is relatively straightforward, but dictionaries are easier to use and maintain. Besides, this feels like the sort of thing that ought to be well suited to a dictionary.

Very interested to hear your ideas.

Cheers,
Tom


Keep in mind that dictionaries always try all of the matches in order. So if you do TRUE->FALSE and then FALSE->TRUE you will get all TRUE no matter what you had originally.

To get around then you can do something like:
^FALSE$ -> 1TRUE
^TRUE$ -> 1FALSE
^(1)(.+)$ -> $2

NOTE: I have not actually tested this so the syntax might be a little off but you get the idea :)

-Wayne
Thanks Wayne - just needs a bit of a conceptual shift I guess. :)
Login or Signup to post a comment