Variable Within An Expression


Recommended Posts

Been searching and experimenting, but unsuccessful in finding a way to do the following.

I've created a cluster group of instruments (gauges) that monitor for example, the following named channels with expressions like:

MotorRPM6[0]*10

MotorAmps6[0]*10

MotorVolts6[0]*10

MotorError6[0]

MotorTemp6[0]*100

I would like to have a single edit box that when I enter a value therein, would change all of

the values (indicated in red in above expressions to the edit box value.

This is to allow the instrument cluster as a whole to switch to monitoring other named channels like:

MotorRPM8[0]*10

MotorAmps8[0]*10

MotorVolts8[0]*10

MotorError8[0]

MotorTemp8[0]*100

Any help greatly appreciated, as always.

Link to comment
Share on other sites

OK, if I understand you right, in your example, you want an edit box or other way to change the 6 to an 8 (or other number). To do this, you'll need to use evaluate() and create a variable to hold that number. Lets say that variable is "index". Then when you reference your motor channels, you'd do something like:

evaluate("MotorRPM" + index + "[0]") * 10

Rinse and repeat for the others...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.