Convert tag int to string

I have a string and an integer memory tag, I’d like to perform translation like:
int tag str tag
1 Hello
2 Hi
3 Bye
etc.

Is it possible to do the above without scripting? If yes, how?

It depends where you’re trying to do this and what version you’re using.

Ignition 8.0 or greater has Map transforms in bindings in which the Map takes discrete values and maps them to alternate values (complete with a fall back if no match is found). This would only output the value to some property somewhere, and would not write back to the tag.

I would create a expression tag that uses this integer memory tag inside a case statement. The expression would be for example case(“tagpath”, 1, “Hello”, 2, “Hi”, 3, “Bye”, 4, “Etc.”, “Error”). (Error is a fallback, if a number comes back that is not within the case statement it will go back to the fallback value). You could also use this expression inside any page or popup instead of making another tag. Or You can use the map transforms mentioned above. Just thought i would provide another option.

If you have many translations, consider using a static dataset memory tag with the two columns. Then your string expression tag(s) can use the lookup() function.

1 Like

Thanks for the responses, both b.ellison and pturmel work well.

I have this same issue, but have no clue what the expression should look like. I have an integer in the PLC that will drive what should be displayed from the string column the memory dataset. Can anyone give me an example of what the expression should be?

Best example you can find is in the manual: https://docs.inductiveautomation.com/display/DOC80/lookup

1 Like