Expression, weird return

How is this expression returning 2??

Do you have a tag named 'test'?

2 Likes

i have a style class named test

You're not doing this in the right place. Move that expression to the expression tab (the third one in the menu on the left)

A tag binding is meant to get data from a tag, and a tag expression binding uses an expression to build the path of that tag. In your particular case, you're trying to read a tag named "test"

7 Likes

Ah i get it!

This actually comes from another issue i was having. I have this expression tag:

image
the expression is this:
if({[.]../../SA_HTR_OV/UDT/18/PumpBlock_Pct_Out} < 1.00 && {[.]../Heater Monitoring/SA_18_PB_1_amps} <= '0.2', true, false)

As you can see its returning False.
Those tag values are as follows:
image
and
image
Shouldnt this be returning True?

You are comparing to a string, not a number. Why are there quotes?

That me trying both ways, I get the same result even if its just numbers, just poo and giggles, lol.

if({[.]../../SA_HTR_OV/UDT/18/PumpBlock_Pct_Out} < 1.00 && {[.]../Heater Monitoring/SA_18_PB_1_amps} <= 0.2, true, false)
image

First, get rid of the if(...., true, false). Wherever you do that, just put the ..... You're adding visual noise that prevents seeing possible problems.

Then, split the remaining expression at the && and test the two parts separately.

1 Like

OK, so when I do just this I get an error, just says error:
{[.]../../SA_HTR_OV/UDT/18/PumpBlock_Pct_Out} < 1.00
image
image

the other part gives me the same results:
{[.]../Heater Monitoring/SA_18_PB_1_amps} <= 0.2
image
image

Now look to see what the Error_ExpressionEval is.

when i hover over the error it just displays Error_ExpressionEval

Please see Wiki - how to post code on this forum.

Run the tag's diagnostics to get more detail.

Perhaps you should use the tag picker in the expression editor to verify that tag path.

You could also use my Integration Toolkit's debugMe() function to log the evaluation errors in detail. (Be aware that recent versions of Ignition have a bug that prevents newly installed modules' expression functions from working in expression tags until the gateway itself is restarted.)

I am using 8.1.32. I dont have the option for diags when i right click the tag.

Open the tag editor. Click the diagnostics button in the upper right. This isn't available in a right-click menu.

OK I see, thanks.

Here is what i am seeing, looks like a null value was returned:

See the dots with the text icon next to it? Click that. Paste the result here and use the preformatted text button.

Looks like when i used the tag() finction this works correctly:

tag("[default]Phase 1 Extrusion/SA18/Heater Monitoring/SA_18_PB_1_amps") <= 0.2 && tag("[default]Phase 1 Extrusion/SA_HTR_OV/UDT/18/PumpBlock_Pct_Out") < 1.0

Right, but that isn't an apples-to-apples comparison. One is using relative paths and the other is using absolute paths.

1 Like

When I change it back to relative paths the result is good.
{[.]../../../SA_HTR_OV/UDT/18/PumpBlock_Pct_Out} <1.0 && {[.]../../Heater Monitoring/SA_18_PB_1_amps} <= 0.2
Last published value [true, Good, Fri Aug 02 09:51:19 CDT 2024 (1722610279205)] INFO

??