Scripting Label Values

round( (({CO2 Tanks/Tank 2 Level Row}/380)*100), 0 ) gives me the value I want.
I see prefix and Suffix fields that I am using. I see Font options, but if I change this it changes all Prefix, Suffix and values to a static setting.

How can I script this to dynamically change font and color based on value?

Tank_Value = round( (({CO2 Tanks/Tank 2 Level Row}/380)*100), 0 )
Tank_Value_Color = “red”

If(
Tank_Value > 60,
Tank_Value_Color = “green”,
if(
Tank_Value > 30 ,
Tank_Value_Color = “black”,
Tank_Value_Color = “red”
)
)

How do I return the tank value with the correct formatting?
I cannot even declare Tank_Value as a variable equal to round( (({CO2 Tanks/Tank 2 Level Row}/380)*100), 0 )

Users browsing this forum: jantonevich, JordanCClark, MSN NewsBlogs and 4 guests

Wow… MSN on the ignition board? Interesting.

Bots will browse the forums to add/update their search engines.

Right-click on the label. Go to Customizers → Style Customizer. You should then be able to change the style of the label however you wish. :slight_smile:

For the tank value try:

toInt(round( (({CO2 Tanks/Tank 2 Level Row}/380)*100), 0 ))

I think the round function coerces the value to a float, even though it (the value) needs to be an integer…

I am looking for a way to script so that my labels will dynamically change.

so if my value is 88 my output would look like this:
My Value is [color=#00FF00] 88[/color]

so if my value is 40 my output would look like this:
My Value is [color=#FFFF00] 40[/color]

so if my value is 15 my output would look like this:
My Value is [color=#FF0000]15 [/color]

Ah! You should be abel to do it as html. I can’t give an example quite yet 'cause I’m on my way to a meeting.

After it’s over, I’ll post an example window… :slight_smile:

I would really appreciate that. I am having a hard time knowing where I can input logic and how and where to return to and from. If only it was as simple as php or .net....

css/html formatting options would be great. I don't know how to make it dynamic. The user manual only gives snip-its.

Here you go.

I added a dynamic property to the label called StatusColor. It holds the color name according to the setpoint values (I used the cascaded If-Then you posted earlier. :wink: )

The Text property is a concatenated string that puts together all the html code to get the disired output.
Tank with html label.vwin (6.49 KB)

Oh this is beautiful.

Do you have anymore examples of how to use scripting. I learned more with your exported window in minutes than I have from reading the user manual for days.

Thank you sir. I wish there are some kind of like or mod points for this. Thumbs up and thank you for your time.

The answer is, of course, "It depends"... :laughing:

I've got quite a bit of stuff scattered around on the forum, some more stuff here at work. Whether it's actually useful or not is a matter of some conjecture! :mrgreen:

Usually, I'll make a window for whatever someone is trying to do, keeping it as self-contained as possible.

go easy,first post, only started messing with this today (in my “spare” time)
My question is to confirm whether I need scripting to do the value conversions on a window from the PLC counts. I searched for “4095” and found nothing.
SO, Ignition is such that one embeds a script for such conversion for each indiv value, everytime it is used?
I’ll continue to mess about, but I read 2 PLC registers and the values did not match the counts I saw in my PLC view. The tags just declared as unsigned 16bit if I recall. It’s probably something basic.
Also, I presume the *.vwin scripts I see in posts must be viewed in Ignition?
Thanks

[quote="billymac00"]go easy,first post, only started messing with this today (in my "spare" time)
[/quote]

No worries! Everyone is new at one time! :slight_smile:

I get to use my stock answer for such things: "It depends." Seriously, though, an example of what is in the PLC register to what you're seeing in Ignition will go a long way. My gut tells me that that the PLC register is in BCD, but it's something to verify before I go completely off-base.

Oh! Almost forgot… okay, I did forget. But I remembered, and that’s the important thing! :laughing: What PLC are you using? A PLC side solution likely exists as well. That way you have extra options. That whole “multiple ways to skin a cat” thing, which is good… unless you’re a cat… :unamused: