Transform (Perspective) In Vision

In Perspective you can bind to a tag and then Transform the value using a script. I am trying to figure out how to do something similar in Vision. I have a tag that is an integer and I have a dataset. I need to use the integer value to lookup a string value in the dataset. The lookup script is written and works fine in Perspective. I feel like it is something simple that I am missing.

The only way to perform a “transform” in vision similar to what is present in perspective is to use the transform expression in Phil’s Integration Toolkit module.

However, I think you’re making it more complex than it really needs to be. Create a custom property, probably on the root container, and the use an expression binding with a lookup() expression to pull the value out of the dataset. The. You can reference that property anywhere you need in the window.

5 Likes

I will try that. Is there a way to do it with scripting without using an expression?

Any reason why you are shying away from expressions? Expressions are markedly more performant than scripts.

There is an expression function for exactly this, lookup.

3 Likes

Of course, but my initial response would be why?

Obviously I don't know the context of what else is going on. In a script context this is a simple as reading the tag value and then filtering the dataset for the value you are looking for (probably with a named query).

That however is realtively poor advice.

  1. This feels like a side effect, which generally should be avoided.
  2. Scripts should be the last resort, pure bindings and expressions should be the go to. See @ryan.white's post for the reason.
  3. There is an expression that does exactly (what I believe) you're looking for.

Can you provide a little more context to the problem you're trying to solve?

2 Likes

In case the replies haven't made clear, using a script to do this is a mistake, even in Perspective. Use the native lookup() expression function in an expression binding.

(Perspective's conveniences are often big sledgehammers with which to bash your thumb. Script transforms are an example. Use only as a last resort.)

2 Likes

The script that I need to run is what gives me the table that I need to use for the lookup.

I figured out how to do what I wanted.

  1. I created a custom property on the control that is affected
  2. Linked that property to the index
  3. Created a propertyChange script that does the lookup and populates the text field